diff --git a/pom.xml b/pom.xml index 6430edb8..a8bed590 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-project-info-reports-plugin - 3.5.1-SNAPSHOT + 4.0.0-M1-SNAPSHOT maven-plugin Apache Maven Project Info Reports Plugin @@ -114,14 +114,13 @@ under the License. - 1.11.1 - 1.11.1 + 2.0.0-M8 + 2.0.0-M16 3.2.5 2.0.1 1.0.0.v20140518 - 3.12.1 - 1.11.1 - 3.1.0 + 4.0.0-M12 + 2.0.0-M8 ParameterNumber,MethodLength 2023-11-17T21:50:41Z @@ -130,12 +129,12 @@ under the License. org.apache.maven.reporting maven-reporting-api - 3.1.1 + 4.0.0-M9 org.apache.maven.reporting maven-reporting-impl - 3.2.0 + 4.0.0-M13 org.apache.maven @@ -270,56 +269,18 @@ under the License. org.apache.maven.doxia doxia-sink-api ${doxiaVersion} - - - org.codehaus.plexus - plexus-container-default - - org.apache.maven.doxia doxia-core ${doxiaVersion} - - - org.codehaus.plexus - plexus-container-default - - - - org.apache.maven.doxia - doxia-decoration-model - ${doxiaSitetoolsVersion} - - - org.apache.maven.doxia - doxia-site-renderer - ${doxiaSitetoolsVersion} - - - org.codehaus.plexus - plexus-container-default - - - org.codehaus.plexus - plexus-component-api - - - org.apache.maven.doxia doxia-integration-tools ${doxiaSitetoolsVersion} - - - org.codehaus.plexus - plexus-container-default - - @@ -459,6 +420,13 @@ under the License. RSA + + org.apache.maven.plugins + maven-surefire-plugin + + -Dfile.encoding=UTF-8 + + @@ -523,6 +491,35 @@ under the License. + + org.apache.maven.plugins + maven-clean-plugin + + + + delete-0-byte-site-descriptors + + clean + + pre-integration-test + + true + + + ${settings.localRepository}/org/apache/apache + + **/*-site*.xml + + + + + + + org.apache.maven.plugins maven-invoker-plugin diff --git a/src/it/MPIR-300/verify.groovy b/src/it/MPIR-300/verify.groovy index 19084de9..1aaeb1ba 100644 --- a/src/it/MPIR-300/verify.groovy +++ b/src/it/MPIR-300/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -plugins = new File( basedir, 'target/site/plugins.html' ).text; +plugins = new File( basedir, 'target/reports/plugins.html' ).text; // version of maven-invoker-plugin is defined in pluginManagement assert plugins.contains( '1.invoker-pluginManagement' ); @@ -31,4 +31,4 @@ assert plugins.contains( '2.checkstyle-plugin' ); // version of maven-changes-plugin is defined in reporting (overriding pluginManagement and plugins) assert plugins.contains( '3.changes-reporting' ); -return true; \ No newline at end of file +return true; diff --git a/src/it/MPIR-349/parent/verify.groovy b/src/it/MPIR-349/parent/verify.groovy index 78079298..39493c65 100644 --- a/src/it/MPIR-349/parent/verify.groovy +++ b/src/it/MPIR-349/parent/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -File indexPage = new File( basedir, 'target/site/index.html' ) +File indexPage = new File( basedir, 'target/reports/index.html' ) assert !indexPage.text.contains( 'sitePublishLocation' ) -File modulesPage = new File( basedir, 'target/site/modules.html' ) +File modulesPage = new File( basedir, 'target/reports/modules.html' ) assert !modulesPage.text.contains( 'sitePublishLocation' ) diff --git a/src/it/MPIR-375/verify.groovy b/src/it/MPIR-375/verify.groovy index 3bf172ba..976582dd 100644 --- a/src/it/MPIR-375/verify.groovy +++ b/src/it/MPIR-375/verify.groovy @@ -19,11 +19,11 @@ File log = new File( basedir, 'build.log' ); assert !( log.text.contains("org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find org.eclipse.m2e:lifecycle-mapping:pom") ); -plugins = new File( basedir, 'target/site/plugin-management.html' ).text; +plugins = new File( basedir, 'target/reports/plugin-management.html' ).text; // maven-javadoc-plugin is defined in pluginManagement and not excluded assert plugins.contains( 'maven-javadoc-plugin' ); // org.eclipse.m2e:lifecycle-mapping plugin is excluded assert !( plugins.contains( 'org.eclipse.m2e' ) ); -assert !( plugins.contains( 'lifecycle-mapping' ) ); \ No newline at end of file +assert !( plugins.contains( 'lifecycle-mapping' ) ); diff --git a/src/it/MPIR-407/verify.groovy b/src/it/MPIR-407/verify.groovy index 570c5d2f..33fa6698 100644 --- a/src/it/MPIR-407/verify.groovy +++ b/src/it/MPIR-407/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -dependencies = new File( basedir, 'target/site/dependencies.html' ).text; +dependencies = new File( basedir, 'target/reports/dependencies.html' ).text; assert !( dependencies.contains( 'The Apache Software License, Version 2.0' ) ); assert !( dependencies.contains( 'Apache Public License 2.0' ) ); diff --git a/src/it/MPIR-412/verify.groovy b/src/it/MPIR-412/verify.groovy index 16a68c7e..8e9e8af7 100644 --- a/src/it/MPIR-412/verify.groovy +++ b/src/it/MPIR-412/verify.groovy @@ -22,5 +22,5 @@ import groovy.xml.XmlParser // should be able to parse the output as XML parser = new XmlParser(); parser.setFeature( 'http://apache.org/xml/features/disallow-doctype-decl', false ); -result = parser.parse( new File( basedir, 'target/site/dependencies.html' ) ); +result = parser.parse( new File( basedir, 'target/reports/dependencies.html' ) ); assert result instanceof Node; diff --git a/src/it/MPIR-431/verify.groovy b/src/it/MPIR-431/verify.groovy index d5e8e38a..11b6b710 100644 --- a/src/it/MPIR-431/verify.groovy +++ b/src/it/MPIR-431/verify.groovy @@ -16,38 +16,39 @@ * specific language governing permissions and limitations * under the License. */ -String html = new File( basedir, 'target/site/dependencies.html' ).text +String html = new File( basedir, 'target/reports/dependencies.html' ).text +// Revise after DOXIA-704 def summaryLine = '''\ -compile: 1 -compile: 45.5 kB -compile: 47 -compile: 36 -compile: 4 -1.3 -compile: 1 +compile: 1 +compile: 45.5 kB +compile: 47 +compile: 36 +compile: 4 +1.3 +compile: 1 -runtime: 1 -runtime: 284.2 kB -runtime: 155 -runtime: 133 -runtime: 10 -runtime: 1 +runtime: 1 +runtime: 284.2 kB +runtime: 155 +runtime: 133 +runtime: 10 +runtime: 1 -provided: 1 -provided: 85.7 kB -provided: 209 -provided: 192 -provided: 4 -- +provided: 1 +provided: 85.7 kB +provided: 209 +provided: 192 +provided: 4 +- -test: 3 -test: 2.2 MB -test: 1619 -test: 1493 -test: 91 -1.8 -test: 3''' +test: 3 +test: 2.2 MB +test: 1619 +test: 1493 +test: 91 +1.8 +test: 3''' 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 343724b0..65e9c8e3 100644 --- a/src/it/MPIR-437/verify.groovy +++ b/src/it/MPIR-437/verify.groovy @@ -16,16 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -File dependencies = new File( basedir, 'target/site/dependencies.html' ) +File dependencies = new File( basedir, 'target/reports/dependencies.html' ) def summaryRow = '''\ -1 -78.8 kB -141 -- -- -- -- +1 +78.8 kB +141 +- +- +- +- ''' 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 2edcd4e6..2a344fe9 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 = '''\ -maven-model-3.3.9.jar -164 kB -71 -54 -3 -1.7 -Yes +maven-model-3.3.9.jar +164 kB +71 +54 +3 +1.7 +Yes ''' def jacksonDataTypeJsr310 = '''\ -jackson-datatype-jsr310-2.6.4.jar -78.1 kB -69 -51 -5 -1.8 -Yes +jackson-datatype-jsr310-2.6.4.jar +78.1 kB +69 +51 +5 +1.8 +Yes ''' 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 5edf25c3..97cccb29 100644 --- a/src/it/full-pom/pom.xml +++ b/src/it/full-pom/pom.xml @@ -192,7 +192,7 @@ maven-site-plugin @sitePluginVersion@ - 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 + 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 diff --git a/src/it/java-version/verify.groovy b/src/it/java-version/verify.groovy index e65beba1..1f9ef0c7 100644 --- a/src/it/java-version/verify.groovy +++ b/src/it/java-version/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -assert new File( basedir, 'plugin/target/site/summary.html' ).text.contains( '1.5' ) -assert new File( basedir, 'pluginManagement/target/site/summary.html' ).text.contains( '1.4' ) -assert new File( basedir, 'property/target/site/summary.html' ).text.contains( '1.3' ) +assert new File( basedir, 'plugin/target/reports/summary.html' ).text.contains( '1.5' ) +assert new File( basedir, 'pluginManagement/target/reports/summary.html' ).text.contains( '1.4' ) +assert new File( basedir, 'property/target/reports/summary.html' ).text.contains( '1.3' ) -return true; \ No newline at end of file +return true; diff --git a/src/it/minimal-pom/pom.xml b/src/it/minimal-pom/pom.xml index a2c013b7..0c928146 100644 --- a/src/it/minimal-pom/pom.xml +++ b/src/it/minimal-pom/pom.xml @@ -44,7 +44,7 @@ maven-site-plugin @sitePluginVersion@ - en,cs,de,es,fr,hu,it,ja,ko,nl,no,pl,pt,pt_BR,sk,sv,tr,zh_CN,zh_TW + default,en,cs,de,es,fr,hu,it,ja,ko,nl,no,pl,pt,pt_BR,sk,sv,tr,zh_CN,zh_TW diff --git a/src/it/mpir-229/verify.groovy b/src/it/mpir-229/verify.groovy index 4d7db4b8..6cf4daa0 100644 --- a/src/it/mpir-229/verify.groovy +++ b/src/it/mpir-229/verify.groovy @@ -17,4 +17,4 @@ * under the License. */ File modulesPage = new File( basedir, 'target/site/modules.html' ) -assert modulesPage.text.contains( 'mpir-229-module1' ) \ No newline at end of file +assert modulesPage.text.contains( 'mpir-229-module1' ) diff --git a/src/it/multi-module/pom.xml b/src/it/multi-module/pom.xml index 0cbf1da1..50d8223d 100644 --- a/src/it/multi-module/pom.xml +++ b/src/it/multi-module/pom.xml @@ -79,9 +79,6 @@ org.apache.maven.plugins maven-site-plugin @sitePluginVersion@ - - en - diff --git a/src/it/multi-module/verify.groovy b/src/it/multi-module/verify.groovy index 7fdfb6b9..afc2cb45 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( 'dep/target/classes' ) -assert mainDependencies.text.contains( 'dep-1.0-SNAPSHOT.jar' ) +assert !mainDependencies.text.contains( 'dep/target/classes' ) +assert mainDependencies.text.contains( 'dep-1.0-SNAPSHOT.jar' ) 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 12aaa681..5a7f5054 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 @@ protected void text(String text) { } } - /* 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 04d913e1..a621423d 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java @@ -35,11 +35,13 @@ 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; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; @@ -91,6 +93,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 remoteRepositories; + /** * Plugin repositories used for the project. * @@ -99,14 +104,6 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { @Parameter(defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true) protected List pluginRepositories; - /** - * The reactor projects. - * - * @since 2.10 - */ - @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) - protected List reactorProjects; - /** * The current user system settings for use in Maven. * @@ -149,12 +146,18 @@ public abstract class AbstractProjectInfoReport extends AbstractMavenReport { @Parameter private List licenseMappings; + /** + * The local repository. + */ + @Parameter(defaultValue = "${localRepository}", readonly = true, required = true) + protected ArtifactRepository localRepository; + // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { return !skip; } @@ -200,6 +203,10 @@ protected List getReactorProjects() { return reactorProjects; } + protected MojoExecution getMojoExecution() { + return mojoExecution; + } + /** * @param pluginId The id of the plugin * @return The information about the plugin. @@ -286,6 +293,7 @@ public String getDescription(Locale locale) { 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/CiManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/CiManagementReport.java index 93f668bd..dc3fbf40 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/CiManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/CiManagementReport.java @@ -29,6 +29,7 @@ import org.apache.maven.model.Model; import org.apache.maven.model.Notifier; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; /** @@ -44,7 +45,7 @@ public class CiManagementReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { CiManagement cim = getProject().getModel().getCiManagement(); diff --git a/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java b/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java index 41da98e3..2d60f2af 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java @@ -42,6 +42,7 @@ import org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration; import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils; import org.apache.maven.report.projectinfo.dependencies.renderer.DependenciesRenderer; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; import org.apache.maven.shared.dependency.graph.DependencyNode; @@ -109,7 +110,7 @@ public class DependenciesReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { // This seems to be a bit too much but the DependenciesRenderer applies the same logic 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 579829a7..b143aa7d 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 @@ private void generateConvergence(Locale locale, Sink sink, DependencyAnalyzeResu */ private void generateDependencyDetails(Locale locale, Sink sink, List depList) { sink.table(); - sink.tableRows(null, false); + sink.tableRows(); Map> artifactMap = getSortedUniqueArtifactMap(depList); @@ -288,7 +288,7 @@ private void generateDependencyDetails(Locale locale, Sink sink, List> getSortedUniqueArtifactMap(List */ 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 @@ private void generateStats(Locale locale, Sink sink, DependencyAnalyzeResult res // 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/DependencyManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java index ca688289..e44a54d1 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java @@ -30,6 +30,7 @@ import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies; import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils; import org.apache.maven.report.projectinfo.dependencies.renderer.DependencyManagementRenderer; +import org.apache.maven.reporting.MavenReportException; /** * Generates the Project Dependency Management report. @@ -73,7 +74,7 @@ public class DependencyManagementReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = getManagementDependencies().hasDependencies(); diff --git a/src/main/java/org/apache/maven/report/projectinfo/DistributionManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/DistributionManagementReport.java index 5cddd2e9..59b3d1a7 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/DistributionManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/DistributionManagementReport.java @@ -24,6 +24,7 @@ import org.apache.maven.model.DistributionManagement; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; @@ -40,7 +41,7 @@ public class DistributionManagementReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = getProject().getDistributionManagement() != null; diff --git a/src/main/java/org/apache/maven/report/projectinfo/IssueManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/IssueManagementReport.java index 0be572a6..60823485 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/IssueManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/IssueManagementReport.java @@ -24,6 +24,7 @@ import org.apache.maven.model.IssueManagement; import org.apache.maven.model.Model; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; /** @@ -39,7 +40,7 @@ public class IssueManagementReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = getProject().getModel().getIssueManagement() != null; diff --git a/src/main/java/org/apache/maven/report/projectinfo/LicensesReport.java b/src/main/java/org/apache/maven/report/projectinfo/LicensesReport.java index 837408fb..25d166d2 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/LicensesReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/LicensesReport.java @@ -29,11 +29,12 @@ import org.apache.commons.validator.routines.UrlValidator; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.util.HtmlTools; +import org.apache.maven.doxia.util.DoxiaUtils; import org.apache.maven.model.License; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; @@ -79,7 +80,7 @@ public class LicensesReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = !isEmpty(getProject().getModel().getLicenses()); @@ -255,7 +256,7 @@ protected void renderBody() { } sink.listItem(); - link("#" + HtmlTools.encodeId(name), name); + link("#" + DoxiaUtils.encodeId(name), name); sink.listItem_(); } sink.list_(); diff --git a/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java b/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java index 2e10d264..2d4e4252 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java @@ -29,6 +29,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; @@ -46,7 +47,7 @@ public class MailingListsReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = !isEmpty(getProject().getModel().getMailingLists()); diff --git a/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java b/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java index 15854ffa..3863f5da 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java @@ -36,6 +36,7 @@ import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; /** @@ -51,7 +52,7 @@ public class ModulesReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = !isEmpty(getProject().getModel().getModules()); diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java index c67f435c..2c2c7aab 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java @@ -37,6 +37,7 @@ import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.codehaus.plexus.i18n.I18N; @@ -92,7 +93,7 @@ protected String getI18Nsection() { } @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = getProject().getPluginManagement() != null diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java index 70836ac2..83a6f98b 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java @@ -37,6 +37,7 @@ import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; @@ -54,7 +55,7 @@ public class PluginsReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = !isEmpty(getProject().getBuildPlugins()) diff --git a/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java b/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java index 6828af68..71e60263 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java @@ -29,6 +29,7 @@ import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.reporting.MavenReportException; import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; import org.apache.maven.scm.provider.hg.repository.HgScmProviderRepository; @@ -100,7 +101,7 @@ public class ScmReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { Scm scm = getProject().getModel().getScm(); 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 df36d694..10e0823d 100644 --- a/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java +++ b/src/main/java/org/apache/maven/report/projectinfo/TeamReport.java @@ -33,6 +33,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; @@ -62,7 +63,7 @@ public class TeamReport extends AbstractProjectInfoReport { // ---------------------------------------------------------------------- @Override - public boolean canGenerateReport() { + public boolean canGenerateReport() throws MavenReportException { boolean result = super.canGenerateReport(); if (result && skipEmptyReport) { result = !isEmpty(getProject().getModel().getDevelopers()) @@ -233,7 +234,7 @@ private void renderTeamMember(Contributor member, Map headersMa if (id == null) { tableCell(null); } else { - tableCell("" + id, true); + tableCell("" + 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 4981acc1..0b13eb97 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.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 @@ protected void renderBody() { } } - // ---------------------------------------------------------------------- - // 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 a7aa2391..6b2f8ef7 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 @@ 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 @@ 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 @@ protected void setUp() throws Exception { // 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 @@ protected String getString(String key) { 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 @@ protected AbstractProjectInfoReport createReportMojo(String goal, File pluginXml repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() .newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir()))); + List 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 @@ protected File generateReport(AbstractProjectInfoReport mojo, File pluginXmlFile 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 6b6b4bf3..95cb7173 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 void testReport() throws Exception { // 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 void testReport() throws Exception { * @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 void testCiNameReport() throws Exception { // 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 1a2f36e3..742f6b5d 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 void testReport() throws Exception { // 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 c4df5333..f8c7c332 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 void testReport() throws Exception { // 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 d3075aa9..2a3bc62b 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 void testReport() throws Exception { // 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 e7aee3a0..09450c5c 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 void testReport() throws Exception { // 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 abc506f3..c968b5d4 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 void testReport() throws Exception { // 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 void testReport() throws Exception { // 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 b487eb1d..cfdcbe88 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 void testReport() throws Exception { // 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("https://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 void testReportLinksOnly() throws Exception { // 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 9bb86b7e..61a63e57 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 void testReport() throws Exception { // 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 void testCustomBundle() throws Exception { // 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 void testCustomBundle() throws Exception { * @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 void testFrenchReport() throws Exception { * @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 60201902..edb17957 100644 --- a/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java +++ b/src/test/java/org/apache/maven/report/projectinfo/ModulesReportTest.java @@ -59,7 +59,7 @@ protected AbstractProjectInfoReport createReportMojo(String goal, File pluginXml * @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(); @@ -79,9 +79,10 @@ public void testReport() throws Exception { // 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); @@ -102,7 +103,7 @@ public void testReport() throws Exception { 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 @@ -126,4 +127,9 @@ protected String getPOM() { new String(Files.readAllBytes(getGeneratedReport("modules.html").toPath()), StandardCharsets.UTF_8) .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 4fa77043..eae49842 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 ProjectBuildingResult answer(InvocationOnMock invocation) throws Throwabl * @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 void testReport() throws Exception { // 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 void testReport() throws Exception { * @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 void testReportEclipseM2EPluginLifecycleMapping() throws Exception { // 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 @@ private static ProjectBuildingResult createProjectBuildingResult(Artifact artifa 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 3570b1e4..95b98847 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 void testReport() throws Exception { // 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 void testReport() throws Exception { 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 void testReportWithWrongUrl() throws Exception { 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 878025c1..56c6ad76 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 void testReport() throws Exception { // 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 e0b2c2ae..e9d93401 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 void testReport() throws Exception { // 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 void testReport() throws Exception { assertEquals(1, links.length); assertEquals("mailto:vsiveton@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 14b40069..5df92416 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.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.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 List getRemoteArtifactRepositories() { return Collections.singletonList(repository); } + @Override + public List getRemoteProjectRepositories() { + return RepositoryUtils.toRepos(getRemoteArtifactRepositories()); + } + @Override public Set 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 00000000..c50e7eb9 --- /dev/null +++ b/src/test/resources/plugin-configs/mailing-lists-plugin-config-fr.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + org.apache.maven.plugin.projectinfo.tests + mailing-lists + 1.0-SNAPSHOT + jar + mailing lists project info + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + + + Test List + test@maven.apache.org + MAILTO:test-subscribe@maven.apache.org + + + Test List 2 + test2@maven.apache.org + MAILTO:test-subscribe2@maven.apache.org + https://example.com/unsubscribe + + + + + + maven-project-info-reports-plugin + + target/test-harness/mailing-lists + ${localRepository} + fr + + + + + +