This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git

commit c0316996419929a2a846711f95e532d274103917
Author: Michael Osipov <micha...@apache.org>
AuthorDate: Tue May 9 00:11:00 2023 +0200

    [MPIR-435] Custom bundle sometimes not loaded due to parent-first class 
loading
    
    This closes #48
---
 .../site/custom/project-info-reports.properties    |  6 +--
 ...operties => project-info-reports_de.properties} |  6 +--
 ...operties => project-info-reports_fr.properties} |  6 +--
 src/it/full-pom/verify.bsh                         | 30 +++++++++--
 .../projectinfo/AbstractProjectInfoReport.java     |  2 +-
 .../report/projectinfo/MailingListsReportTest.java | 27 ++++++++++
 .../projectinfo/stubs/MailingListsStub2.java       | 37 +++++++++++++
 .../plugin-configs/custom-bundle/plugin-config.xml | 62 ++++++++++++++++++++++
 .../site/custom/project-info-reports.properties    |  0
 9 files changed, 163 insertions(+), 13 deletions(-)

diff --git a/src/it/full-pom/src/site/custom/project-info-reports.properties 
b/src/it/full-pom/src/site/custom/project-info-reports.properties
index 644d0b9..66ca731 100644
--- a/src/it/full-pom/src/site/custom/project-info-reports.properties
+++ b/src/it/full-pom/src/site/custom/project-info-reports.properties
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-report.mailing-lists.intro = mail list intro text foo
\ No newline at end of file
+report.mailing-lists.intro = mail list intro text foo
diff --git a/src/it/full-pom/src/site/custom/project-info-reports.properties 
b/src/it/full-pom/src/site/custom/project-info-reports_de.properties
similarity index 92%
copy from src/it/full-pom/src/site/custom/project-info-reports.properties
copy to src/it/full-pom/src/site/custom/project-info-reports_de.properties
index 644d0b9..63bfed3 100644
--- a/src/it/full-pom/src/site/custom/project-info-reports.properties
+++ b/src/it/full-pom/src/site/custom/project-info-reports_de.properties
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-report.mailing-lists.intro = mail list intro text foo
\ No newline at end of file
+report.mailing-lists.intro = mail list intro text foo ("de")
diff --git a/src/it/full-pom/src/site/custom/project-info-reports.properties 
b/src/it/full-pom/src/site/custom/project-info-reports_fr.properties
similarity index 92%
copy from src/it/full-pom/src/site/custom/project-info-reports.properties
copy to src/it/full-pom/src/site/custom/project-info-reports_fr.properties
index 644d0b9..5cef9a6 100644
--- a/src/it/full-pom/src/site/custom/project-info-reports.properties
+++ b/src/it/full-pom/src/site/custom/project-info-reports_fr.properties
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-report.mailing-lists.intro = mail list intro text foo
\ No newline at end of file
+report.mailing-lists.intro = mail list intro text foo ("fr")
diff --git a/src/it/full-pom/verify.bsh b/src/it/full-pom/verify.bsh
index df74b5a..73ca2b7 100644
--- a/src/it/full-pom/verify.bsh
+++ b/src/it/full-pom/verify.bsh
@@ -91,6 +91,30 @@ try
         return false;
     }
 
+    mailinglists = new File( siteDir, "de/mailing-lists.html");
+    content = FileUtils.fileRead( mailinglists, "UTF-8" );
+    if ( !content.contains( "mail list intro text foo (&quot;de&quot;)" ) )
+    {
+        System.err.println( "de/mailing-lists.html doesn't contain mail list 
intro text foo (\"de\")" );
+        return false;
+    }
+
+    mailinglists = new File( siteDir, "fr/mailing-lists.html");
+    content = FileUtils.fileRead( mailinglists, "UTF-8" );
+    if ( !content.contains( "mail list intro text foo (&quot;fr&quot;)" ) )
+    {
+        System.err.println( "fr/mailing-lists.html doesn't contain mail list 
intro text foo (\"fr\")" );
+        return false;
+    }
+
+    mailinglists = new File( siteDir, "sv/mailing-lists.html");
+    content = FileUtils.fileRead( mailinglists, "UTF-8" );
+    if ( !content.contains( "mail list intro text foo" ) )
+    {
+        System.err.println( "sv/mailing-lists.html doesn't contain mail list 
intro text foo" );
+        return false;
+    }
+
     File dependencies = new File( siteDir, "dependencies.html");
     content = FileUtils.fileRead( dependencies, "UTF-8" );
     if ( !content.contains( "doxia-core-1.2.jar" ) )
@@ -107,16 +131,16 @@ try
         System.err.println( "MPIR-216: dependency-management doesn't contain 
doxia-sink-api url https://maven.apache.org/doxia/doxia/doxia-sink-api/"; );
         return false;
     }
-    
+
     File dependencyConvergence = new File( siteDir, 
"dependency-convergence.html");
     content = FileUtils.fileRead( dependencyConvergence, "UTF-8" );
-    
+
     if ( !content.contains( "You do not have 100% convergence." ) )
     {
         System.err.println( "dependency-convergence not rendered correctly" );
         return false;
     }
-    
+
 }
 catch ( Throwable t )
 {
diff --git 
a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
 
b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
index 2ad27bf..9829e94 100644
--- 
a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
+++ 
b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
@@ -329,7 +329,7 @@ public abstract class AbstractProjectInfoReport extends 
AbstractMavenReport {
             URLClassLoader classLoader = null;
             try {
                 classLoader = new URLClassLoader(
-                        new URL[] 
{customBundleFile.getParentFile().toURI().toURL()});
+                        new URL[] 
{customBundleFile.getParentFile().toURI().toURL()}, null);
             } catch (MalformedURLException e) {
                 // could not happen.
             }
diff --git 
a/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java 
b/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
index 6404eae..9bb86b7 100644
--- 
a/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
+++ 
b/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
@@ -84,6 +84,33 @@ public class MailingListsReportTest extends 
AbstractProjectInfoTestCase {
         assertEquals("https://example.com/unsubscribe";, 
unsubscribeLinks[0].getAttribute("href"));
     }
 
+    /**
+     * Test custom bundle
+     *
+     * @throws Exception if any
+     */
+    public void testCustomBundle() throws Exception {
+        generateReport("mailing-lists", "custom-bundle/plugin-config.xml");
+        assertTrue(
+                "Test html generated", 
getGeneratedReport("mailing-lists.html").exists());
+
+        URL reportURL = 
getGeneratedReport("mailing-lists.html").toURI().toURL();
+        assertNotNull(reportURL);
+
+        // HTTPUnit
+        WebRequest request = new GetMethodWebRequest(reportURL.toString());
+        WebResponse response = WEB_CONVERSATION.getResponse(request);
+
+        // Basic HTML tests
+        assertTrue(response.isHTML());
+        assertTrue(response.getContentLength() > 0);
+
+        // Test the texts
+        TextBlock[] textBlocks = response.getTextBlocks();
+        assertEquals(getString("report.mailing-lists.title"), 
textBlocks[0].getText());
+        assertEquals("mail list intro text foo", textBlocks[1].getText());
+    }
+
     /**
      * Test report in French (MPIR-59)
      *
diff --git 
a/src/test/java/org/apache/maven/report/projectinfo/stubs/MailingListsStub2.java
 
b/src/test/java/org/apache/maven/report/projectinfo/stubs/MailingListsStub2.java
new file mode 100644
index 0000000..7b3380c
--- /dev/null
+++ 
b/src/test/java/org/apache/maven/report/projectinfo/stubs/MailingListsStub2.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.report.projectinfo.stubs;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:vincent.sive...@gmail.com";>Vincent Siveton</a>
+ * @version $Id$
+ */
+public class MailingListsStub2 extends ProjectInfoProjectStub {
+    @Override
+    public File getBasedir() {
+        return new File(super.getBasedir() + "/custom-bundle/");
+    }
+
+    @Override
+    protected String getPOM() {
+        return "plugin-config.xml";
+    }
+}
diff --git a/src/test/resources/plugin-configs/custom-bundle/plugin-config.xml 
b/src/test/resources/plugin-configs/custom-bundle/plugin-config.xml
new file mode 100644
index 0000000..0b3b9ee
--- /dev/null
+++ b/src/test/resources/plugin-configs/custom-bundle/plugin-config.xml
@@ -0,0 +1,62 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.projectinfo.tests</groupId>
+  <artifactId>mailing-lists</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>mailing lists project info</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <mailingLists>
+    <mailingList>
+      <name>Test List</name>
+      <post>t...@maven.apache.org</post>
+      <subscribe>MAILTO:test-subscr...@maven.apache.org</subscribe>
+    </mailingList>
+    <mailingList>
+      <name>Test List 2</name>
+      <post>te...@maven.apache.org</post>
+      <subscribe>MAILTO:test-subscri...@maven.apache.org</subscribe>
+      <unsubscribe>https://example.com/unsubscribe</unsubscribe>
+    </mailingList>
+  </mailingLists>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <configuration>
+          <outputDirectory>target/test-harness/mailing-lists</outputDirectory>
+          <localRepository>${localRepository}</localRepository>
+          <project 
implementation="org.apache.maven.report.projectinfo.stubs.MailingListsStub2"/>
+          
<customBundle>${basedir}/src/test/resources/plugin-configs/custom-bundle/src/site/custom/project-info-reports.properties</customBundle>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/full-pom/src/site/custom/project-info-reports.properties 
b/src/test/resources/plugin-configs/custom-bundle/src/site/custom/project-info-reports.properties
similarity index 100%
copy from src/it/full-pom/src/site/custom/project-info-reports.properties
copy to 
src/test/resources/plugin-configs/custom-bundle/src/site/custom/project-info-reports.properties

Reply via email to