This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch doxia-2.0.0 in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git
commit 563c3b849bd64cbc31e727514f16ed276a169f09 Author: Michael Osipov <micha...@apache.org> AuthorDate: Sat Jul 2 23:58:47 2022 +0200 Prepare for Doxia 2.0.0 --- pom.xml | 81 +++++++------- src/it/MPIR-431/verify.groovy | 53 +++++----- src/it/MPIR-437/verify.groovy | 14 +-- src/it/dependencies-java-1.7-and-1.8/verify.groovy | 28 ++--- src/it/full-pom/pom.xml | 2 +- src/it/minimal-pom/pom.xml | 2 +- src/it/multi-module/pom.xml | 3 - src/it/multi-module/verify.groovy | 4 +- .../projectinfo/AbstractProjectInfoRenderer.java | 31 ------ .../projectinfo/AbstractProjectInfoReport.java | 23 ++-- .../projectinfo/DependencyConvergenceReport.java | 8 +- .../maven/report/projectinfo/TeamReport.java | 2 +- .../renderer/DependenciesRenderer.java | 116 --------------------- .../projectinfo/AbstractProjectInfoTestCase.java | 49 +++++++-- .../report/projectinfo/CiManagementReportTest.java | 20 ++-- .../report/projectinfo/DependenciesReportTest.java | 23 ++-- .../DependencyConvergenceReportTest.java | 9 +- .../DependencyManagementReportTest.java | 11 +- .../maven/report/projectinfo/IndexReportTest.java | 11 +- .../projectinfo/IssueManagementReportTest.java | 15 ++- .../report/projectinfo/LicensesReportTest.java | 33 +++--- .../report/projectinfo/MailingListsReportTest.java | 33 +++--- .../report/projectinfo/ModulesReportTest.java | 16 ++- .../projectinfo/PluginManagementReportTest.java | 13 ++- .../maven/report/projectinfo/ScmReportTest.java | 24 +++-- .../report/projectinfo/SummaryReportTest.java | 17 +-- .../maven/report/projectinfo/TeamReportTest.java | 24 +++-- .../projectinfo/stubs/ProjectInfoProjectStub.java | 7 ++ .../mailing-lists-plugin-config-fr.xml | 62 +++++++++++ 29 files changed, 370 insertions(+), 364 deletions(-) diff --git a/pom.xml b/pom.xml index bc29c99..11a8b14 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. </parent> <artifactId>maven-project-info-reports-plugin</artifactId> - <version>3.4.6-SNAPSHOT</version> + <version>4.0.0-M1-SNAPSHOT</version> <packaging>maven-plugin</packaging> <name>Apache Maven Project Info Reports Plugin</name> @@ -114,13 +114,13 @@ under the License. </distributionManagement> <properties> - <doxiaVersion>1.11.1</doxiaVersion> - <doxiaSitetoolsVersion>1.11.1</doxiaSitetoolsVersion> + <doxiaVersion>2.0.0-M6</doxiaVersion> + <doxiaSitetoolsVersion>2.0.0-M10</doxiaSitetoolsVersion> <mavenVersion>3.2.5</mavenVersion> <scmVersion>1.13.0</scmVersion> <aetherVersion>1.0.0.v20140518</aetherVersion> - <sitePluginVersion>3.12.1</sitePluginVersion> - <fluidoSkinVersion>1.11.1</fluidoSkinVersion> + <sitePluginVersion>4.0.0-M8</sitePluginVersion> + <fluidoSkinVersion>2.0.0-M6</fluidoSkinVersion> <surefire.version>3.1.0</surefire.version> <checkstyle.violation.ignore>ParameterNumber,MethodLength</checkstyle.violation.ignore> <project.build.outputTimestamp>2023-06-03T12:55:40Z</project.build.outputTimestamp> @@ -130,12 +130,12 @@ under the License. <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-api</artifactId> - <version>3.1.1</version> + <version>4.0.0-M6</version> </dependency> <dependency> <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-impl</artifactId> - <version>3.2.0</version> + <version>4.0.0-M8</version> <exclusions> <exclusion> <groupId>org.apache.maven</groupId> @@ -303,56 +303,18 @@ under the License. <groupId>org.apache.maven.doxia</groupId> <artifactId>doxia-sink-api</artifactId> <version>${doxiaVersion}</version> - <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> <groupId>org.apache.maven.doxia</groupId> <artifactId>doxia-core</artifactId> <version>${doxiaVersion}</version> - <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> - </exclusions> </dependency> <!-- Doxia Sitetools --> - <dependency> - <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-decoration-model</artifactId> - <version>${doxiaSitetoolsVersion}</version> - </dependency> - <dependency> - <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-site-renderer</artifactId> - <version>${doxiaSitetoolsVersion}</version> - <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-api</artifactId> - </exclusion> - </exclusions> - </dependency> <dependency> <groupId>org.apache.maven.doxia</groupId> <artifactId>doxia-integration-tools</artifactId> <version>${doxiaSitetoolsVersion}</version> - <exclusions> - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </exclusion> - </exclusions> </dependency> <!-- Plexus --> @@ -559,6 +521,35 @@ under the License. </properties> <build> <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <!-- + This is necessary if "mvn site" has been invoked previously with 3.x + and leaves 0-byte files in the local repository for MRM Maven Plugin + to serve which are broken from a consumer's PoV. + --> + <executions> + <execution> + <id>delete-0-byte-site-descriptors</id> + <goals> + <goal>clean</goal> + </goals> + <phase>pre-integration-test</phase> + <configuration> + <excludeDefaultDirectories>true</excludeDefaultDirectories> + <filesets> + <fileset> + <directory>${settings.localRepository}/org/apache/apache</directory> + <includes> + <include>**/*-site*.xml</include> + </includes> + </fileset> + </filesets> + </configuration> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-invoker-plugin</artifactId> diff --git a/src/it/MPIR-431/verify.groovy b/src/it/MPIR-431/verify.groovy index d5e8e38..e13ac75 100644 --- a/src/it/MPIR-431/verify.groovy +++ b/src/it/MPIR-431/verify.groovy @@ -18,36 +18,37 @@ */ String html = new File( basedir, 'target/site/dependencies.html' ).text +// Revise after DOXIA-704 def summaryLine = '''\ <tr class="b"> -<td align="right">compile: 1</td> -<td align="right">compile: 45.5 kB</td> -<td align="right">compile: 47</td> -<td align="right">compile: 36</td> -<td align="right">compile: 4</td> -<td rowspan="3" style="vertical-align: middle;" align="center">1.3</td> -<td align="right">compile: 1</td></tr> +<td style="text-align: right;">compile: 1</td> +<td style="text-align: right;">compile: 45.5 kB</td> +<td style="text-align: right;">compile: 47</td> +<td style="text-align: right;">compile: 36</td> +<td style="text-align: right;">compile: 4</td> +<td rowspan="3" style="vertical-align: middle;">1.3</td> +<td style="text-align: right;">compile: 1</td></tr> <tr class="a"> -<td align="right">runtime: 1</td> -<td align="right">runtime: 284.2 kB</td> -<td align="right">runtime: 155</td> -<td align="right">runtime: 133</td> -<td align="right">runtime: 10</td> -<td align="right">runtime: 1</td></tr> +<td style="text-align: right;">runtime: 1</td> +<td style="text-align: right;">runtime: 284.2 kB</td> +<td style="text-align: right;">runtime: 155</td> +<td style="text-align: right;">runtime: 133</td> +<td style="text-align: right;">runtime: 10</td> +<td style="text-align: right;">runtime: 1</td></tr> <tr class="b"> -<td align="right">provided: 1</td> -<td align="right">provided: 85.7 kB</td> -<td align="right">provided: 209</td> -<td align="right">provided: 192</td> -<td align="right">provided: 4</td> -<td align="right">-</td></tr> +<td style="text-align: right;">provided: 1</td> +<td style="text-align: right;">provided: 85.7 kB</td> +<td style="text-align: right;">provided: 209</td> +<td style="text-align: right;">provided: 192</td> +<td style="text-align: right;">provided: 4</td> +<td style="text-align: right;">-</td></tr> <tr class="a"> -<td align="right">test: 3</td> -<td align="right">test: 2.2 MB</td> -<td align="right">test: 1619</td> -<td align="right">test: 1493</td> -<td align="right">test: 91</td> -<td align="center">1.8</td> -<td align="right">test: 3</td></tr>''' +<td style="text-align: right;">test: 3</td> +<td style="text-align: right;">test: 2.2 MB</td> +<td style="text-align: right;">test: 1619</td> +<td style="text-align: right;">test: 1493</td> +<td style="text-align: right;">test: 91</td> +<td style="text-align: center;">1.8</td> +<td style="text-align: right;">test: 3</td></tr>''' assert html.contains( summaryLine.replaceAll( "\n", System.lineSeparator() ) ) diff --git a/src/it/MPIR-437/verify.groovy b/src/it/MPIR-437/verify.groovy index 343724b..7b79e84 100644 --- a/src/it/MPIR-437/verify.groovy +++ b/src/it/MPIR-437/verify.groovy @@ -19,13 +19,13 @@ File dependencies = new File( basedir, 'target/site/dependencies.html' ) def summaryRow = '''\ <tr class="b"> -<td align="right">1</td> -<td align="right">78.8 kB</td> -<td align="right">141</td> -<td align="right">-</td> -<td align="right">-</td> -<td align="center">-</td> -<td align="right">-</td></tr> +<td style="text-align: right;">1</td> +<td style="text-align: right;">78.8 kB</td> +<td style="text-align: right;">141</td> +<td style="text-align: right;">-</td> +<td style="text-align: right;">-</td> +<td style="text-align: center;">-</td> +<td style="text-align: right;">-</td></tr> ''' assert dependencies.text.contains( summaryRow.replaceAll( "\n", System.lineSeparator() ) ) diff --git a/src/it/dependencies-java-1.7-and-1.8/verify.groovy b/src/it/dependencies-java-1.7-and-1.8/verify.groovy index 2edcd4e..2a344fe 100644 --- a/src/it/dependencies-java-1.7-and-1.8/verify.groovy +++ b/src/it/dependencies-java-1.7-and-1.8/verify.groovy @@ -19,24 +19,24 @@ File dependencies = new File( basedir, 'target/site/dependencies.html' ) def mavenModel = '''\ <tr class="a"> -<td align="left">maven-model-3.3.9.jar</td> -<td align="right">164 kB</td> -<td align="right">71</td> -<td align="right">54</td> -<td align="right">3</td> -<td align="center">1.7</td> -<td align="center">Yes</td></tr> +<td style="text-align: left;">maven-model-3.3.9.jar</td> +<td style="text-align: right;">164 kB</td> +<td style="text-align: right;">71</td> +<td style="text-align: right;">54</td> +<td style="text-align: right;">3</td> +<td style="text-align: center;">1.7</td> +<td style="text-align: center;">Yes</td></tr> ''' def jacksonDataTypeJsr310 = '''\ <tr class="a"> -<td align="left">jackson-datatype-jsr310-2.6.4.jar</td> -<td align="right">78.1 kB</td> -<td align="right">69</td> -<td align="right">51</td> -<td align="right">5</td> -<td align="center">1.8</td> -<td align="center">Yes</td></tr> +<td style="text-align: left;">jackson-datatype-jsr310-2.6.4.jar</td> +<td style="text-align: right;">78.1 kB</td> +<td style="text-align: right;">69</td> +<td style="text-align: right;">51</td> +<td style="text-align: right;">5</td> +<td style="text-align: center;">1.8</td> +<td style="text-align: center;">Yes</td></tr> ''' assert dependencies.text.contains( mavenModel.replaceAll( "\n", System.getProperty( "line.separator" ) ) ) diff --git a/src/it/full-pom/pom.xml b/src/it/full-pom/pom.xml index 5edf25c..97cccb2 100644 --- a/src/it/full-pom/pom.xml +++ b/src/it/full-pom/pom.xml @@ -192,7 +192,7 @@ <artifactId>maven-site-plugin</artifactId> <version>@sitePluginVersion@</version> <configuration> - <locales>en,cs,de,en,es,fr,gl,hu,it,ja,ko,lt,nl,no,pl,pt,pt_BR,ru,sk,sv,tr,zh_CN,zh_TW</locales> + <locales>default,en,cs,de,en,es,fr,gl,hu,it,ja,ko,lt,nl,no,pl,pt,pt_BR,ru,sk,sv,tr,zh_CN,zh_TW</locales> </configuration> </plugin> </plugins> diff --git a/src/it/minimal-pom/pom.xml b/src/it/minimal-pom/pom.xml index a2c013b..0c92814 100644 --- a/src/it/minimal-pom/pom.xml +++ b/src/it/minimal-pom/pom.xml @@ -44,7 +44,7 @@ <artifactId>maven-site-plugin</artifactId> <version>@sitePluginVersion@</version> <configuration> - <locales>en,cs,de,es,fr,hu,it,ja,ko,nl,no,pl,pt,pt_BR,sk,sv,tr,zh_CN,zh_TW</locales> + <locales>default,en,cs,de,es,fr,hu,it,ja,ko,nl,no,pl,pt,pt_BR,sk,sv,tr,zh_CN,zh_TW</locales> </configuration> </plugin> </plugins> diff --git a/src/it/multi-module/pom.xml b/src/it/multi-module/pom.xml index 0cbf1da..50d8223 100644 --- a/src/it/multi-module/pom.xml +++ b/src/it/multi-module/pom.xml @@ -79,9 +79,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>@sitePluginVersion@</version> - <configuration> - <locales>en</locales> - </configuration> </plugin> </plugins> </build> diff --git a/src/it/multi-module/verify.groovy b/src/it/multi-module/verify.groovy index 7fdfb6b..afc2cb4 100644 --- a/src/it/multi-module/verify.groovy +++ b/src/it/multi-module/verify.groovy @@ -21,5 +21,5 @@ File mainDependencies = new File( basedir, 'main/target/site/dependencies.html' // Dependency File Details section should display dep-1.0-SNAPSHOT.jar packaged from previous build (package phase), // not dep/target/classes from current build (site phase) -assert !mainDependencies.text.contains( '<td align="left">dep/target/classes</td>' ) -assert mainDependencies.text.contains( '<td align="left">dep-1.0-SNAPSHOT.jar</td>' ) +assert !mainDependencies.text.contains( '<td style="text-align: left;">dep/target/classes</td>' ) +assert mainDependencies.text.contains( '<td style="text-align: left;">dep-1.0-SNAPSHOT.jar</td>' ) diff --git a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java index 12aaa68..5a7f505 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java +++ b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoRenderer.java @@ -91,36 +91,5 @@ public abstract class AbstractProjectInfoRenderer extends AbstractMavenReportRen } } - /* FIXME The next two methods need to be retained until Doxia and Maven Reporting Impl properly implement - * the difference of a (boxed) real verbatim text and (boxed) source code. - */ - /** - * {@inheritDoc} - */ - @Override - protected void verbatimText(String text) { - sink.verbatim(null); - - text(text); - - sink.verbatim_(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void verbatimLink(String text, String href) { - if (href == null || href.isEmpty()) { - verbatimText(text); - } else { - sink.verbatim(null); - - link(href, text); - - sink.verbatim_(); - } - } - protected abstract String getI18Nsection(); } 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 9829e94..91c8d55 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java @@ -35,6 +35,7 @@ import java.util.ResourceBundle; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -91,6 +92,9 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { @Parameter(defaultValue = "${session}", readonly = true, required = true) private MavenSession session; + @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) + protected List<ArtifactRepository> remoteRepositories; + /** * Plugin repositories used for the project. * @@ -99,14 +103,6 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { @Parameter(defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true) protected List<ArtifactRepository> pluginRepositories; - /** - * The reactor projects. - * - * @since 2.10 - */ - @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) - protected List<MavenProject> reactorProjects; - /** * The current user system settings for use in Maven. * @@ -149,6 +145,12 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { @Parameter private List<LicenseMapping> licenseMappings; + /** + * The local repository. + */ + @Parameter(defaultValue = "${localRepository}", readonly = true, required = true) + protected ArtifactRepository localRepository; + // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- @@ -215,6 +217,10 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { return reactorProjects; } + protected MojoExecution getMojoExecution() { + return mojoExecution; + } + /** * @param pluginId The id of the plugin * @return The information about the plugin. @@ -301,6 +307,7 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { return getI18nString(locale, "description"); } + // TODO Review, especially Locale.getDefault() private static class CustomI18N implements I18N { private final MavenProject project; diff --git a/src/main/java/org/apache/maven/report/projectinfo/DependencyConvergenceReport.java b/src/main/java/org/apache/maven/report/projectinfo/DependencyConvergenceReport.java index 579829a..b143aa7 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/DependencyConvergenceReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/DependencyConvergenceReport.java @@ -273,7 +273,7 @@ public class DependencyConvergenceReport extends AbstractProjectInfoReport { */ private void generateDependencyDetails(Locale locale, Sink sink, List<ReverseDependencyLink> depList) { sink.table(); - sink.tableRows(null, false); + sink.tableRows(); Map<String, List<ReverseDependencyLink>> artifactMap = getSortedUniqueArtifactMap(depList); @@ -288,7 +288,7 @@ public class DependencyConvergenceReport extends AbstractProjectInfoReport { sink.tableCell(); sink.table(); - sink.tableRows(null, false); + sink.tableRows(); for (String version : artifactMap.keySet()) { sink.tableRow(); @@ -474,7 +474,7 @@ public class DependencyConvergenceReport extends AbstractProjectInfoReport { */ private void generateLegend(Locale locale, Sink sink) { sink.table(); - sink.tableRows(null, false); + sink.tableRows(); sink.tableCaption(); sink.bold(); sink.text(getI18nString(locale, "legend")); @@ -514,7 +514,7 @@ public class DependencyConvergenceReport extends AbstractProjectInfoReport { // Create report sink.table(); - sink.tableRows(null, false); + sink.tableRows(); sink.tableCaption(); sink.bold(); sink.text(getI18nString(locale, "stats.caption")); diff --git a/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java b/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java index df36d69..46e3f69 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java @@ -233,7 +233,7 @@ public class TeamReport extends AbstractProjectInfoReport { if (id == null) { tableCell(null); } else { - tableCell("<a name=\"" + id + "\"></a>" + id, true); + tableCell("<a id=\"" + id + "\"></a>" + id, true); } } } diff --git a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java index 6b9925f..ce81c3a 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java +++ b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java @@ -45,7 +45,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; -import org.apache.maven.doxia.util.HtmlTools; import org.apache.maven.model.License; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; @@ -97,10 +96,6 @@ public class DependenciesRenderer extends AbstractProjectInfoRenderer { private final MessageFormat javaVersionFormat = new MessageFormat("{0,choice,0#|1.1#{0,number,0.0}|9#{0,number,0}}", Locale.ROOT); - /** - * @since 2.1.1 - */ - private int section; /** Counter for unique IDs that is consistent across generations. */ private int idCounter = 0; @@ -230,117 +225,6 @@ public class DependenciesRenderer extends AbstractProjectInfoRenderer { } } - // ---------------------------------------------------------------------- - // Protected methods - // ---------------------------------------------------------------------- - - /** {@inheritDoc} */ - // workaround for MPIR-140 - // TODO Remove me when MSHARED-390 has been resolved - @Override - protected void startSection(String name) { - startSection(name, name); - } - - /** - * Start section with a name and a specific anchor. - * - * @param anchor not null - * @param name not null - */ - // TODO Remove me when MSHARED-390 has been resolved - protected void startSection(String name, String anchor) { - section = section + 1; - - super.sink.anchor(HtmlTools.encodeId(anchor)); - super.sink.anchor_(); - - switch (section) { - case 1: - sink.section1(); - sink.sectionTitle1(); - break; - case 2: - sink.section2(); - sink.sectionTitle2(); - break; - case 3: - sink.section3(); - sink.sectionTitle3(); - break; - case 4: - sink.section4(); - sink.sectionTitle4(); - break; - case 5: - sink.section5(); - sink.sectionTitle5(); - break; - - default: - // TODO: warning - just don't start a section - break; - } - - text(name); - - switch (section) { - case 1: - sink.sectionTitle1_(); - break; - case 2: - sink.sectionTitle2_(); - break; - case 3: - sink.sectionTitle3_(); - break; - case 4: - sink.sectionTitle4_(); - break; - case 5: - sink.sectionTitle5_(); - break; - - default: - // TODO: warning - just don't start a section - break; - } - } - - /** {@inheritDoc} */ - // workaround for MPIR-140 - // TODO Remove me when MSHARED-390 has been resolved - @Override - protected void endSection() { - switch (section) { - case 1: - sink.section1_(); - break; - case 2: - sink.section2_(); - break; - case 3: - sink.section3_(); - break; - case 4: - sink.section4_(); - break; - case 5: - sink.section5_(); - break; - - default: - // TODO: warning - just don't start a section - break; - } - - section = section - 1; - - if (section < 0) { - throw new IllegalStateException("Too many closing sections"); - } - } - // ---------------------------------------------------------------------- // Private methods // ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java b/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java index a7aa239..6b2f8ef 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java +++ b/src/test/java/org/apache/maven/report/projectinfo/AbstractProjectInfoTestCase.java @@ -20,9 +20,16 @@ package org.apache.maven.report.projectinfo; import java.io.File; import java.io.IOException; -import java.util.Locale; +import java.util.Collections; +import java.util.List; +import com.meterware.httpunit.HttpUnitOptions; +import org.apache.maven.doxia.tools.SiteTool; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -46,11 +53,6 @@ import org.eclipse.aether.repository.LocalRepository; public abstract class AbstractProjectInfoTestCase extends AbstractMojoTestCase { private ArtifactStubFactory artifactStubFactory; - /** - * The default locale is English. - */ - protected static final Locale DEFAULT_LOCALE = Locale.ENGLISH; - /** * The current project to be test. */ @@ -66,14 +68,13 @@ public abstract class AbstractProjectInfoTestCase extends AbstractMojoTestCase { // required for mojo lookups to work super.setUp(); + HttpUnitOptions.setScriptingEnabled(false); + i18n = getContainer().lookup(I18N.class); setVariableValueToObject(i18n, "defaultBundleName", "project-info-reports"); artifactStubFactory = new DependencyArtifactStubFactory(getTestFile("target"), true, false); artifactStubFactory.getWorkingDir().mkdirs(); - - // Set the default Locale - Locale.setDefault(DEFAULT_LOCALE); } @Override @@ -92,7 +93,7 @@ public abstract class AbstractProjectInfoTestCase extends AbstractMojoTestCase { throw new IllegalArgumentException("The key cannot be empty"); } - return i18n.getString(key, Locale.getDefault()).trim(); + return i18n.getString(key, SiteTool.DEFAULT_LOCALE).trim(); } /** @@ -168,9 +169,19 @@ public abstract class AbstractProjectInfoTestCase extends AbstractMojoTestCase { repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() .newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir()))); + List<MavenProject> reactorProjects = + mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList(); + + setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution()); setVariableValueToObject(mojo, "session", legacySupport.getSession()); + setVariableValueToObject(mojo, "repoSession", legacySupport.getRepositorySession()); + setVariableValueToObject(mojo, "reactorProjects", reactorProjects); + setVariableValueToObject( + mojo, "remoteProjectRepositories", mojo.getProject().getRemoteProjectRepositories()); setVariableValueToObject(mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories()); setVariableValueToObject(mojo, "pluginRepositories", mojo.getProject().getPluginArtifactRepositories()); + setVariableValueToObject( + mojo, "siteDirectory", new File(mojo.getProject().getBasedir(), "src/site")); return mojo; } @@ -189,4 +200,22 @@ public abstract class AbstractProjectInfoTestCase extends AbstractMojoTestCase { return new File(outputDir, filename); } + + private MojoExecution getMockMojoExecution() { + MojoDescriptor md = new MojoDescriptor(); + md.setGoal(getGoal()); + + MojoExecution me = new MojoExecution(md); + + PluginDescriptor pd = new PluginDescriptor(); + Plugin p = new Plugin(); + p.setGroupId("org.apache.maven.plugins"); + p.setArtifactId("maven-project-info-reports-plugin"); + pd.setPlugin(p); + md.setPluginDescriptor(pd); + + return me; + } + + protected abstract String getGoal(); } diff --git a/src/test/java/org/apache/maven/report/projectinfo/CiManagementReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/CiManagementReportTest.java index 6b6b4bf..95cb717 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/CiManagementReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/CiManagementReportTest.java @@ -44,7 +44,7 @@ public class CiManagementReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("ci-management", "ci-management-plugin-config.xml"); + generateReport(getGoal(), "ci-management-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("ci-management.html").exists()); @@ -65,8 +65,8 @@ public class CiManagementReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.ci-management.name"), textBlocks[0].getText()); - assertEquals(getString("report.ci-management.nocim"), textBlocks[1].getText()); + assertEquals(getString("report.ci-management.name"), textBlocks[1].getText()); + assertEquals(getString("report.ci-management.nocim"), textBlocks[2].getText()); } /** @@ -76,7 +76,7 @@ public class CiManagementReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testCiNameReport() throws Exception { - generateReport("ci-management", "ci-management-plugin-with-ci-section-config.xml"); + generateReport(getGoal(), "ci-management-plugin-with-ci-section-config.xml"); assertTrue( "Test html generated", getGeneratedReport("ci-management.html").exists()); @@ -93,11 +93,17 @@ public class CiManagementReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertTrue(textBlocks[1].getText().startsWith("This project uses ")); - assertEquals(3, textBlocks[1].getNode().getChildNodes().getLength()); + TextBlock textBlock = textBlocks[2]; + assertTrue(textBlock.getText().startsWith("This project uses ")); + assertEquals(3, textBlock.getNode().getChildNodes().getLength()); HTMLAnchorElement anchor = - (HTMLAnchorElement) textBlocks[1].getNode().getChildNodes().item(1); + (HTMLAnchorElement) textBlock.getNode().getChildNodes().item(1); assertEquals("https://www.jetbrains.com/teamcity/", anchor.getAttribute("href")); assertEquals("TeamCity", anchor.getFirstChild().getNodeValue()); } + + @Override + protected String getGoal() { + return "ci-management"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/DependenciesReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/DependenciesReportTest.java index 1a2f36e..742f6b5 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/DependenciesReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/DependenciesReportTest.java @@ -44,7 +44,7 @@ public class DependenciesReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("dependencies", "dependencies-plugin-config.xml"); + generateReport(getGoal(), "dependencies-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("dependencies.html").exists()); @@ -75,13 +75,18 @@ public class DependenciesReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.dependencies.title"), textBlocks[0].getText()); - assertEquals("test", textBlocks[1].getText()); - assertEquals(getString("report.dependencies.intro.test"), textBlocks[2].getText()); - assertEquals(getString("report.dependencies.transitive.title"), textBlocks[3].getText()); - assertEquals(getString("report.dependencies.transitive.nolist"), textBlocks[4].getText()); - assertEquals(getString("report.dependencies.graph.title"), textBlocks[5].getText()); - assertEquals(getString("report.dependencies.graph.tree.title"), textBlocks[6].getText()); - assertEquals(getString("report.dependencies.graph.tables.licenses"), textBlocks[7].getText()); + assertEquals(getString("report.dependencies.title"), textBlocks[1].getText()); + assertEquals("test", textBlocks[2].getText()); + assertEquals(getString("report.dependencies.intro.test"), textBlocks[3].getText()); + assertEquals(getString("report.dependencies.transitive.title"), textBlocks[4].getText()); + assertEquals(getString("report.dependencies.transitive.nolist"), textBlocks[5].getText()); + assertEquals(getString("report.dependencies.graph.title"), textBlocks[6].getText()); + assertEquals(getString("report.dependencies.graph.tree.title"), textBlocks[7].getText()); + assertEquals(getString("report.dependencies.graph.tables.licenses"), textBlocks[8].getText()); + } + + @Override + protected String getGoal() { + return "dependencies"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/DependencyConvergenceReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/DependencyConvergenceReportTest.java index c4df533..f8c7c33 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/DependencyConvergenceReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/DependencyConvergenceReportTest.java @@ -43,7 +43,7 @@ public class DependencyConvergenceReportTest extends AbstractProjectInfoTestCase * @throws Exception if any */ public void testReport() throws Exception { - generateReport("dependency-convergence", "dependency-convergence-plugin-config.xml"); + generateReport(getGoal(), "dependency-convergence-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("dependency-convergence.html").exists()); @@ -67,6 +67,11 @@ public class DependencyConvergenceReportTest extends AbstractProjectInfoTestCase // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.dependency-convergence.reactor.name"), textBlocks[0].getText()); + assertEquals(getString("report.dependency-convergence.reactor.name"), textBlocks[1].getText()); + } + + @Override + protected String getGoal() { + return "dependency-convergence"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/DependencyManagementReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/DependencyManagementReportTest.java index d3075aa..2a3bc62 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/DependencyManagementReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/DependencyManagementReportTest.java @@ -44,7 +44,7 @@ public class DependencyManagementReportTest extends AbstractProjectInfoTestCase * @throws Exception if any */ public void testReport() throws Exception { - generateReport("dependency-management", "dependency-management-plugin-config.xml"); + generateReport(getGoal(), "dependency-management-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("dependency-management.html").exists()); @@ -80,7 +80,12 @@ public class DependencyManagementReportTest extends AbstractProjectInfoTestCase // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.dependency-management.title"), textBlocks[0].getText()); - assertEquals("test", textBlocks[1].getText()); + assertEquals(getString("report.dependency-management.title"), textBlocks[1].getText()); + assertEquals("test", textBlocks[2].getText()); + } + + @Override + protected String getGoal() { + return "dependency-management"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/IndexReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/IndexReportTest.java index e7aee3a..09450c5 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/IndexReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/IndexReportTest.java @@ -43,7 +43,7 @@ public class IndexReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("index", "index-plugin-config.xml"); + generateReport(getGoal(), "index-plugin-config.xml"); assertTrue("Test html generated", getGeneratedReport("index.html").exists()); URL reportURL = getGeneratedReport("index.html").toURI().toURL(); @@ -65,7 +65,12 @@ public class IndexReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); assertEquals( - getString("report.index.title") + " " + getTestMavenProject().getName(), textBlocks[0].getText()); - assertEquals(getString("report.index.nodescription"), textBlocks[1].getText()); + getString("report.index.title") + " " + getTestMavenProject().getName(), textBlocks[1].getText()); + assertEquals(getString("report.index.nodescription"), textBlocks[2].getText()); + } + + @Override + protected String getGoal() { + return "index"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/IssueManagementReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/IssueManagementReportTest.java index abc506f..c968b5d 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/IssueManagementReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/IssueManagementReportTest.java @@ -44,7 +44,7 @@ public class IssueManagementReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("issue-management", "issue-management-plugin-config.xml"); + generateReport(getGoal(), "issue-management-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("issue-management.html").exists()); @@ -67,7 +67,7 @@ public class IssueManagementReportTest extends AbstractProjectInfoTestCase { // Test the links WebLink[] weblinks = response.getLinks(); - assertEquals(3, weblinks.length); + assertEquals(4, weblinks.length); assertEquals("JIRA", weblinks[1].getText()); @@ -75,8 +75,13 @@ public class IssueManagementReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.issue-management.overview.title"), textBlocks[0].getText()); - assertEquals("This project uses JIRA.", textBlocks[1].getText()); // due to link pattern - assertEquals(getString("report.issue-management.name"), textBlocks[2].getText()); + assertEquals(getString("report.issue-management.overview.title"), textBlocks[1].getText()); + assertEquals("This project uses JIRA.", textBlocks[2].getText()); // due to link pattern + assertEquals(getString("report.issue-management.name"), textBlocks[3].getText()); + } + + @Override + protected String getGoal() { + return "issue-management"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/LicensesReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/LicensesReportTest.java index b487eb1..5e0320d 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/LicensesReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/LicensesReportTest.java @@ -44,7 +44,7 @@ public class LicensesReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("licenses", "licenses-plugin-config.xml"); + generateReport(getGoal(), "licenses-plugin-config.xml"); assertTrue("Test html generated", getGeneratedReport("licenses.html").exists()); URL reportURL = getGeneratedReport("licenses.html").toURI().toURL(); @@ -64,19 +64,19 @@ public class LicensesReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.licenses.overview.title"), textBlocks[0].getText()); - assertEquals(getString("report.licenses.overview.intro"), textBlocks[1].getText()); - assertEquals(getString("report.licenses.title"), textBlocks[2].getText()); - assertEquals("The Apache Software License, Version 2.0", textBlocks[3].getText()); + assertEquals(getString("report.licenses.overview.title"), textBlocks[1].getText()); + assertEquals(getString("report.licenses.overview.intro"), textBlocks[2].getText()); + assertEquals(getString("report.licenses.title"), textBlocks[3].getText()); + assertEquals("The Apache Software License, Version 2.0", textBlocks[4].getText()); // only 1 link in default report final WebLink[] links = response.getLinks(); - assertEquals(1, links.length); - assertEquals("http://maven.apache.org/", links[0].getURLString()); + assertEquals(2, links.length); + assertEquals("http://maven.apache.org/", links[1].getURLString()); } public void testReportLinksOnly() throws Exception { - generateReport("licenses", "licenses-plugin-config-linkonly.xml"); + generateReport(getGoal(), "licenses-plugin-config-linkonly.xml"); assertTrue("Test html generated", getGeneratedReport("licenses.html").exists()); URL reportURL = getGeneratedReport("licenses.html").toURI().toURL(); @@ -96,16 +96,21 @@ public class LicensesReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.licenses.overview.title"), textBlocks[0].getText()); - assertEquals(getString("report.licenses.overview.intro"), textBlocks[1].getText()); - assertEquals(getString("report.licenses.title"), textBlocks[2].getText()); - assertEquals("The Apache Software License, Version 2.0", textBlocks[3].getText()); + assertEquals(getString("report.licenses.overview.title"), textBlocks[1].getText()); + assertEquals(getString("report.licenses.overview.intro"), textBlocks[2].getText()); + assertEquals(getString("report.licenses.title"), textBlocks[3].getText()); + assertEquals("The Apache Software License, Version 2.0", textBlocks[4].getText()); // here's our specific test final WebLink[] links = response.getLinks(); - assertEquals(2, links.length); - assertEquals("http://maven.apache.org/", links[0].getURLString()); + assertEquals(3, links.length); + assertEquals("http://maven.apache.org", links[0].getURLString()); assertEquals("https://www.apache.org/licenses/LICENSE-2.0.txt", links[1].getURLString()); assertEquals("https://www.apache.org/licenses/LICENSE-2.0.txt", links[1].getText()); } + + @Override + protected String getGoal() { + return "licenses"; + } } 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 9bb86b7..61a63e5 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java @@ -19,7 +19,6 @@ package org.apache.maven.report.projectinfo; import java.net.URL; -import java.util.Locale; import com.meterware.httpunit.GetMethodWebRequest; import com.meterware.httpunit.TextBlock; @@ -45,7 +44,7 @@ public class MailingListsReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("mailing-lists", "mailing-lists-plugin-config.xml"); + generateReport(getGoal(), "mailing-lists-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("mailing-lists.html").exists()); @@ -66,8 +65,8 @@ public class MailingListsReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.mailing-lists.title"), textBlocks[0].getText()); - assertEquals(getString("report.mailing-lists.intro"), textBlocks[1].getText()); + assertEquals(getString("report.mailing-lists.title"), textBlocks[1].getText()); + assertEquals(getString("report.mailing-lists.intro"), textBlocks[2].getText()); // MPIR-385 + MPIR-401: Test links are URIs otherwise assume a plain email address String post = getString("report.mailing-lists.column.post"); @@ -107,8 +106,8 @@ public class MailingListsReportTest extends AbstractProjectInfoTestCase { // 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()); + assertEquals(getString("report.mailing-lists.title"), textBlocks[1].getText()); + assertEquals("mail list intro text foo", textBlocks[2].getText()); } /** @@ -117,18 +116,9 @@ public class MailingListsReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testFrenchReport() throws Exception { - Locale oldLocale = Locale.getDefault(); - - try { - Locale.setDefault(Locale.FRENCH); - - generateReport("mailing-lists", "mailing-lists-plugin-config.xml"); - assertTrue( - "Test html generated", - getGeneratedReport("mailing-lists.html").exists()); - } finally { - Locale.setDefault(oldLocale); - } + generateReport(getGoal(), "mailing-lists-plugin-config-fr.xml"); + assertTrue( + "Test html generated", getGeneratedReport("mailing-lists.html").exists()); } /** @@ -137,8 +127,13 @@ public class MailingListsReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testInvalidLink() throws Exception { - generateReport("mailing-lists", "mailing-lists-plugin-config-invalidlink.xml"); + generateReport(getGoal(), "mailing-lists-plugin-config-invalidlink.xml"); assertTrue( "Test html generated", getGeneratedReport("mailing-lists.html").exists()); } + + @Override + protected String getGoal() { + return "mailing-lists"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java index 79a3b4a..5bf70cd 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java @@ -58,7 +58,7 @@ public class ModulesReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("modules", "modules-plugin-config.xml"); + generateReport(getGoal(), "modules-plugin-config.xml"); assertTrue("Test html generated", getGeneratedReport("modules.html").exists()); URL reportURL = getGeneratedReport("modules.html").toURI().toURL(); @@ -78,9 +78,10 @@ public class ModulesReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(2, textBlocks.length); - assertEquals(getString("report.modules.title"), textBlocks[0].getText()); - assertEquals(getString("report.modules.intro"), textBlocks[1].getText()); + // Last one is footer noise + assertEquals(4, textBlocks.length - 1); + assertEquals(getString("report.modules.title"), textBlocks[1].getText()); + assertEquals(getString("report.modules.intro"), textBlocks[2].getText()); String[][] cellTexts = response.getTables()[0].asText(); assertEquals(3, cellTexts.length); @@ -101,7 +102,7 @@ public class ModulesReportTest extends AbstractProjectInfoTestCase { public void testReportModuleLinksVariableSettingsInterpolated() throws Exception { String pluginXml = "modules-variable-settings-interpolated-plugin-config.xml"; File pluginXmlFile = new File(getBasedir(), "src/test/resources/plugin-configs/" + pluginXml); - AbstractProjectInfoReport mojo = createReportMojo("modules", pluginXmlFile); + AbstractProjectInfoReport mojo = createReportMojo(getGoal(), pluginXmlFile); class SubProjectStub extends SubProject1Stub { @Override @@ -124,4 +125,9 @@ public class ModulesReportTest extends AbstractProjectInfoTestCase { "Variable 'sitePublishLocation' should be interpolated", FileUtils.readFileToString(getGeneratedReport("modules.html")).contains("sitePublishLocation")); } + + @Override + protected String getGoal() { + return "modules"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java index 4fa7704..eae4984 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/PluginManagementReportTest.java @@ -74,7 +74,7 @@ public class PluginManagementReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("plugin-management", "plugin-management-plugin-config.xml"); + generateReport(getGoal(), "plugin-management-plugin-config.xml"); assertTrue( "Test html generated", getGeneratedReport("plugin-management.html").exists()); @@ -104,7 +104,7 @@ public class PluginManagementReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.plugin-management.title"), textBlocks[0].getText()); + assertEquals(getString("report.plugin-management.title"), textBlocks[1].getText()); } /** @@ -113,7 +113,7 @@ public class PluginManagementReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReportEclipseM2EPluginLifecycleMapping() throws Exception { - generateReport("plugin-management", "plugin-management-plugin-config-MPIR-375.xml"); + generateReport(getGoal(), "plugin-management-plugin-config-MPIR-375.xml"); assertTrue( "Test html generated", getGeneratedReport("plugin-management.html").exists()); @@ -149,7 +149,7 @@ public class PluginManagementReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.plugin-management.title"), textBlocks[0].getText()); + assertEquals(getString("report.plugin-management.title"), textBlocks[1].getText()); } private static ProjectBuildingResult createProjectBuildingResult(Artifact artifact, String url) { @@ -164,4 +164,9 @@ public class PluginManagementReportTest extends AbstractProjectInfoTestCase { return result; } + + @Override + protected String getGoal() { + return "plugin-management"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/ScmReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/ScmReportTest.java index 3570b1e..95b9884 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/ScmReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/ScmReportTest.java @@ -45,7 +45,7 @@ public class ScmReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("scm", "scm-plugin-config.xml"); + generateReport(getGoal(), "scm-plugin-config.xml"); assertTrue("Test html generated", getGeneratedReport("scm.html").exists()); URL reportURL = getGeneratedReport("scm.html").toURI().toURL(); @@ -65,13 +65,14 @@ public class ScmReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(6, textBlocks.length); - assertEquals(getString("report.scm.overview.title"), textBlocks[0].getText()); - assertEquals(getString("report.scm.general.intro"), textBlocks[1].getText()); - assertEquals(getString("report.scm.webaccess.title"), textBlocks[2].getText()); - assertEquals(getString("report.scm.webaccess.nourl"), textBlocks[3].getText()); - assertEquals(getString("report.scm.accessbehindfirewall.title"), textBlocks[4].getText()); - assertEquals(getString("report.scm.accessbehindfirewall.general.intro"), textBlocks[5].getText()); + // Last one is footer noise + assertEquals(8, textBlocks.length - 1); + assertEquals(getString("report.scm.overview.title"), textBlocks[1].getText()); + assertEquals(getString("report.scm.general.intro"), textBlocks[2].getText()); + assertEquals(getString("report.scm.webaccess.title"), textBlocks[3].getText()); + assertEquals(getString("report.scm.webaccess.nourl"), textBlocks[4].getText()); + assertEquals(getString("report.scm.accessbehindfirewall.title"), textBlocks[5].getText()); + assertEquals(getString("report.scm.accessbehindfirewall.general.intro"), textBlocks[6].getText()); } /** @@ -82,7 +83,7 @@ public class ScmReportTest extends AbstractProjectInfoTestCase { public void testReportWithWrongUrl() throws Exception { File pluginXmlFile = new File(getBasedir(), "src/test/resources/plugin-configs/" + "scm-wrong-url-plugin-config.xml"); - Mojo mojo = createReportMojo("scm", pluginXmlFile); + Mojo mojo = createReportMojo(getGoal(), pluginXmlFile); setVariableValueToObject(mojo, "anonymousConnection", "scm:svn"); try { @@ -118,4 +119,9 @@ public class ScmReportTest extends AbstractProjectInfoTestCase { assertTrue("IllegalArgumentException catched", true); } } + + @Override + protected String getGoal() { + return "scm"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/SummaryReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/SummaryReportTest.java index 878025c..56c6ad7 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/SummaryReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/SummaryReportTest.java @@ -43,7 +43,7 @@ public class SummaryReportTest extends AbstractProjectInfoTestCase { * @throws Exception if any */ public void testReport() throws Exception { - generateReport("summary", "summary-plugin-config.xml"); + generateReport(getGoal(), "summary-plugin-config.xml"); assertTrue("Test html generated", getGeneratedReport("summary.html").exists()); URL reportURL = getGeneratedReport("summary.html").toURI().toURL(); @@ -64,10 +64,15 @@ public class SummaryReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(getString("report.summary.title"), textBlocks[0].getText()); - assertEquals(getString("report.summary.general.title"), textBlocks[1].getText()); - assertEquals(getString("report.summary.organization.title"), textBlocks[2].getText()); - assertEquals(getString("report.summary.noorganization"), textBlocks[3].getText()); - assertEquals(getString("report.summary.build.title"), textBlocks[4].getText()); + assertEquals(getString("report.summary.title"), textBlocks[1].getText()); + assertEquals(getString("report.summary.general.title"), textBlocks[2].getText()); + assertEquals(getString("report.summary.organization.title"), textBlocks[3].getText()); + assertEquals(getString("report.summary.noorganization"), textBlocks[4].getText()); + assertEquals(getString("report.summary.build.title"), textBlocks[5].getText()); + } + + @Override + protected String getGoal() { + return "summary"; } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/TeamReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/TeamReportTest.java index e0b2c2a..e9d9340 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/TeamReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/TeamReportTest.java @@ -48,7 +48,7 @@ public class TeamReportTest extends AbstractProjectInfoTestCase { */ public void testReport() throws Exception { File pluginXmlFile = new File(getBasedir(), "src/test/resources/plugin-configs/" + "team-plugin-config.xml"); - AbstractProjectInfoReport mojo = createReportMojo("team", pluginXmlFile); + AbstractProjectInfoReport mojo = createReportMojo(getGoal(), pluginXmlFile); setVariableValueToObject(mojo, "showAvatarImages", Boolean.TRUE); generateReport(mojo, pluginXmlFile); assertTrue("Test html generated", getGeneratedReport("team.html").exists()); @@ -72,14 +72,15 @@ public class TeamReportTest extends AbstractProjectInfoTestCase { // Test the texts TextBlock[] textBlocks = response.getTextBlocks(); - assertEquals(7, textBlocks.length); - assertEquals(getString("report.team.intro.title"), textBlocks[0].getText()); - assertEquals(getString("report.team.intro.description1"), textBlocks[1].getText()); - assertEquals(getString("report.team.intro.description2"), textBlocks[2].getText()); - assertEquals(getString("report.team.developers.title"), textBlocks[3].getText()); - assertEquals(getString("report.team.developers.intro"), textBlocks[4].getText()); - assertEquals(getString("report.team.contributors.title"), textBlocks[5].getText()); - assertEquals(getString("report.team.nocontributor"), textBlocks[6].getText()); + // Last one is footer noise + assertEquals(9, textBlocks.length - 1); + assertEquals(getString("report.team.intro.title"), textBlocks[1].getText()); + assertEquals(getString("report.team.intro.description1"), textBlocks[2].getText()); + assertEquals(getString("report.team.intro.description2"), textBlocks[3].getText()); + assertEquals(getString("report.team.developers.title"), textBlocks[4].getText()); + assertEquals(getString("report.team.developers.intro"), textBlocks[5].getText()); + assertEquals(getString("report.team.contributors.title"), textBlocks[6].getText()); + assertEquals(getString("report.team.nocontributor"), textBlocks[7].getText()); WebTable[] tables = response.getTables(); assertEquals(1, tables.length); @@ -89,4 +90,9 @@ public class TeamReportTest extends AbstractProjectInfoTestCase { assertEquals(1, links.length); assertEquals("mailto:vsive...@apache.org", links[0].getURLString()); } + + @Override + protected String getGoal() { + return "team"; + } } diff --git a/src/test/java/org/apache/maven/report/projectinfo/stubs/ProjectInfoProjectStub.java b/src/test/java/org/apache/maven/report/projectinfo/stubs/ProjectInfoProjectStub.java index 14b4006..5df9241 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/stubs/ProjectInfoProjectStub.java +++ b/src/test/java/org/apache/maven/report/projectinfo/stubs/ProjectInfoProjectStub.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; @@ -42,6 +43,7 @@ import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.shared.utils.io.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.eclipse.aether.repository.RemoteRepository; /** * @author Edwin Punzalan @@ -150,6 +152,11 @@ public abstract class ProjectInfoProjectStub extends MavenProjectStub { return Collections.singletonList(repository); } + @Override + public List<RemoteRepository> getRemoteProjectRepositories() { + return RepositoryUtils.toRepos(getRemoteArtifactRepositories()); + } + @Override public Set<Artifact> getDependencyArtifacts() { Artifact artifact = new DefaultArtifact( diff --git a/src/test/resources/plugin-configs/mailing-lists-plugin-config-fr.xml b/src/test/resources/plugin-configs/mailing-lists-plugin-config-fr.xml new file mode 100644 index 0000000..c50e7eb --- /dev/null +++ b/src/test/resources/plugin-configs/mailing-lists-plugin-config-fr.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> + <locale>fr</locale> + <project implementation="org.apache.maven.report.projectinfo.stubs.MailingListsStub"/> + </configuration> + </plugin> + </plugins> + </build> +</project>