From 59d3600d9258f5b131b21b1655ddd19ba286fa42 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 20 Nov 2024 09:02:07 +0100 Subject: [PATCH] [MCHANGES-426] Require Maven 3.6.3, Doxia 2.x --- pom.xml | 163 ++++---------- .../pom.xml | 2 +- .../pom.xml | 2 +- src/it/announce-generate-no-url/pom.xml | 2 +- src/it/announce-generate/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 4 +- src/it/report-changes-generation/pom.xml | 4 +- src/it/report-changes-interpolation/pom.xml | 4 +- src/it/report-changes-nofile/pom.xml | 9 +- src/it/report-changes-skip-snapshots/pom.xml | 4 +- .../pom.xml | 4 +- src/it/report-changes-system/pom.xml | 4 +- src/it/report-changes-system/verify.bsh | 2 +- .../pom.xml | 4 +- .../announcement/AnnouncementMojo.java | 2 +- .../changes/AbstractChangesReport.java | 160 +------------ .../plugins/changes/ChangesCheckMojo.java | 2 +- .../{ChangesMojo.java => ChangesReport.java} | 11 +- .../changes/ChangesReportGenerator.java | 12 +- .../maven/plugins/changes/FeedGenerator.java | 4 +- .../{GitHubMojo.java => GitHubReport.java} | 2 +- .../plugins/issues/IssuesReportGenerator.java | 3 +- .../plugins/jira/AbstractJiraDownloader.java | 25 +-- .../jira/{JiraMojo.java => JiraReport.java} | 4 +- .../loader/ProjectResourceLoader.java | 210 ------------------ .../trac/{TracMojo.java => TracReport.java} | 2 +- .../resources/META-INF/plexus/components.xml | 44 ---- src/site/site.xml | 7 + .../announcement/AnnouncementMojoTest.java | 2 +- ...{JiraMojoTest.java => JiraReportTest.java} | 6 +- .../plugins/jira/JiraUnicodeTestCase.java | 36 ++- 32 files changed, 134 insertions(+), 610 deletions(-) rename src/main/java/org/apache/maven/plugins/changes/{ChangesMojo.java => ChangesReport.java} (98%) rename src/main/java/org/apache/maven/plugins/github/{GitHubMojo.java => GitHubReport.java} (99%) rename src/main/java/org/apache/maven/plugins/jira/{JiraMojo.java => JiraReport.java} (99%) delete mode 100644 src/main/java/org/apache/maven/plugins/resource/loader/ProjectResourceLoader.java rename src/main/java/org/apache/maven/plugins/trac/{TracMojo.java => TracReport.java} (99%) delete mode 100644 src/main/resources/META-INF/plexus/components.xml rename src/test/java/org/apache/maven/plugins/jira/{JiraMojoTest.java => JiraReportTest.java} (89%) diff --git a/pom.xml b/pom.xml index de302b78..4d6ef85a 100644 --- a/pom.xml +++ b/pom.xml @@ -73,11 +73,14 @@ under the License. 8 - 1.9.1 - 1.9.2 - 3.0.5 - 3.3 - 2.4 + 2.0.0 + 3.6.3 + 1.4.1 + + 3.21.0 + 2.0.0 + + ${version.maven-site-plugin} 2020-04-07T21:04:00Z @@ -123,41 +126,18 @@ under the License. org.apache.maven.reporting maven-reporting-api - 3.0 + 4.0.0 org.apache.maven.reporting maven-reporting-impl - 2.3 - - - org.apache.maven - maven-project - - + 4.0.0 org.apache.maven.shared maven-filtering 3.2.0 - - org.apache.maven.shared - maven-artifact-transfer - 0.13.1 - - - org.codehaus.plexus - plexus-interpolation - 1.26 - - - - - org.apache.maven.wagon - wagon-provider-api - ${wagonVersion} - @@ -211,12 +191,8 @@ under the License. org.codehaus.plexus plexus-i18n - 1.0-beta-7 + 1.0-beta-10 - - org.codehaus.plexus - plexus-container-default - org.codehaus.plexus plexus-component-api @@ -234,21 +210,7 @@ under the License. org.codehaus.plexus plexus-velocity - 1.2 - - - org.codehaus.plexus - plexus-container-default - - - org.codehaus.plexus - plexus-component-api - - - velocity - velocity - - + 2.2.0 @@ -279,16 +241,6 @@ under the License. - - org.apache.maven.doxia - doxia-core - ${doxiaVersion} - - - org.apache.maven.doxia - doxia-module-xhtml - ${doxiaVersion} - org.apache.maven.doxia doxia-sink-api @@ -296,23 +248,8 @@ under the License. org.apache.maven.doxia - doxia-decoration-model - ${doxiaSitetoolsVersion} - - - org.apache.maven.doxia - doxia-site-renderer - ${doxiaSitetoolsVersion} - - - org.codehaus.plexus - plexus-component-api - - - org.codehaus.plexus - plexus-container-default - - + doxia-core + ${doxiaVersion} @@ -324,23 +261,12 @@ under the License. com.fasterxml.jackson.core jackson-core - 2.1.0 + 2.18.1 com.fasterxml.jackson.core jackson-databind - 2.12.7.1 - - - - org.apache.velocity - velocity - 1.7 - - - org.apache.velocity - velocity-tools - 2.0 + 2.18.1 @@ -354,23 +280,13 @@ under the License. org.eclipse.mylyn.github org.eclipse.egit.github.core - 5.3.0.201903130848-r + 2.1.5 com.google.code.gson gson 2.10.1 - - org.apache.httpcomponents - httpcore - 4.2.3 - - - org.apache.httpcomponents - httpclient - 4.2.3 - @@ -389,13 +305,13 @@ under the License. org.mockito mockito-core - 2.28.2 + 4.11.0 test org.apache.maven.plugin-testing maven-plugin-testing-harness - 2.1 + 3.3.0 test @@ -405,31 +321,38 @@ under the License. test - org.sonatype.aether - aether-connector-wagon - 1.13.1 + org.apache.maven.resolver + maven-resolver-connector-basic + ${mavenResolverVersion} test - org.apache.maven.wagon - wagon-http - ${wagonVersion} + org.apache.maven.resolver + maven-resolver-transport-http + ${mavenResolverVersion} test - - - - true - - eclipse-egit - https://repo.eclipse.org/content/repositories/egit-releases/ - - - + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${settings.localRepository} + + + + + + + org.eclipse.sisu + sisu-maven-plugin + org.codehaus.modello modello-maven-plugin @@ -575,7 +498,7 @@ under the License. org.codehaus.mojo l10n-maven-plugin - 1.0-alpha-2 + 1.1.0 **/log4j.properties diff --git a/src/it/announce-generate-inconsistent-issue-management/pom.xml b/src/it/announce-generate-inconsistent-issue-management/pom.xml index 85754a23..c6f8ff12 100644 --- a/src/it/announce-generate-inconsistent-issue-management/pom.xml +++ b/src/it/announce-generate-inconsistent-issue-management/pom.xml @@ -43,7 +43,7 @@ http://localhost/bla - @pom.version@ + @project.version@ diff --git a/src/it/announce-generate-no-issue-management/pom.xml b/src/it/announce-generate-no-issue-management/pom.xml index 1ea84778..36c34768 100644 --- a/src/it/announce-generate-no-issue-management/pom.xml +++ b/src/it/announce-generate-no-issue-management/pom.xml @@ -40,7 +40,7 @@ - @pom.version@ + @project.version@ diff --git a/src/it/announce-generate-no-url/pom.xml b/src/it/announce-generate-no-url/pom.xml index f34d3aca..2d5ccf01 100644 --- a/src/it/announce-generate-no-url/pom.xml +++ b/src/it/announce-generate-no-url/pom.xml @@ -43,7 +43,7 @@ - @pom.version@ + @project.version@ diff --git a/src/it/announce-generate/pom.xml b/src/it/announce-generate/pom.xml index 348b061c..2a43b66d 100644 --- a/src/it/announce-generate/pom.xml +++ b/src/it/announce-generate/pom.xml @@ -42,7 +42,7 @@ http://localhost/bla - @pom.version@ + @project.version@ diff --git a/src/it/announcement-generate-custom-template/pom.xml b/src/it/announcement-generate-custom-template/pom.xml index dc806276..7e71bcd2 100644 --- a/src/it/announcement-generate-custom-template/pom.xml +++ b/src/it/announcement-generate-custom-template/pom.xml @@ -42,7 +42,7 @@ http://localhost - @pom.version@ + @project.version@ diff --git a/src/it/report-aggregated-changes-generation/pom.xml b/src/it/report-aggregated-changes-generation/pom.xml index 50ece243..f3b5cdb1 100644 --- a/src/it/report-aggregated-changes-generation/pom.xml +++ b/src/it/report-aggregated-changes-generation/pom.xml @@ -41,7 +41,7 @@ http://localhost/bla - @pom.version@ + @project.version@ module1 @@ -94,7 +94,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ true diff --git a/src/it/report-changes-generation/pom.xml b/src/it/report-changes-generation/pom.xml index 892e2a96..33a446ae 100644 --- a/src/it/report-changes-generation/pom.xml +++ b/src/it/report-changes-generation/pom.xml @@ -41,7 +41,7 @@ http://localhost/bla - @pom.version@ + @project.version@ @@ -89,7 +89,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ http://myjira/browse/%ISSUE% diff --git a/src/it/report-changes-interpolation/pom.xml b/src/it/report-changes-interpolation/pom.xml index c5784625..e425f354 100644 --- a/src/it/report-changes-interpolation/pom.xml +++ b/src/it/report-changes-interpolation/pom.xml @@ -41,7 +41,7 @@ http://localhost/bla - @pom.version@ + @project.version@ @@ -84,7 +84,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ true diff --git a/src/it/report-changes-nofile/pom.xml b/src/it/report-changes-nofile/pom.xml index ba10c45e..5385b793 100644 --- a/src/it/report-changes-nofile/pom.xml +++ b/src/it/report-changes-nofile/pom.xml @@ -41,7 +41,7 @@ http://localhost/bla - @pom.version@ + @project.version@ @@ -51,6 +51,11 @@ maven-changes-plugin ${changesPluginVersion} + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + @@ -79,7 +84,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ http://myjira/browse/%ISSUE% diff --git a/src/it/report-changes-skip-snapshots/pom.xml b/src/it/report-changes-skip-snapshots/pom.xml index 9cf47a26..f06c8f49 100644 --- a/src/it/report-changes-skip-snapshots/pom.xml +++ b/src/it/report-changes-skip-snapshots/pom.xml @@ -41,7 +41,7 @@ http://localhost/bla - @pom.version@ + @project.version@ @@ -79,7 +79,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ http://myjira/browse/%ISSUE% diff --git a/src/it/report-changes-system-noissuemanagement/pom.xml b/src/it/report-changes-system-noissuemanagement/pom.xml index 09ec388d..69ce5253 100644 --- a/src/it/report-changes-system-noissuemanagement/pom.xml +++ b/src/it/report-changes-system-noissuemanagement/pom.xml @@ -37,7 +37,7 @@ - @pom.version@ + @project.version@ @@ -80,7 +80,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ http://myjira/browse/%ISSUE% diff --git a/src/it/report-changes-system/pom.xml b/src/it/report-changes-system/pom.xml index e87e8af9..abf9a656 100644 --- a/src/it/report-changes-system/pom.xml +++ b/src/it/report-changes-system/pom.xml @@ -41,7 +41,7 @@ http://localhost - @pom.version@ + @project.version@ @@ -87,7 +87,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ http://myjira/browse/%ISSUE% diff --git a/src/it/report-changes-system/verify.bsh b/src/it/report-changes-system/verify.bsh index 318921cd..f40d27c7 100644 --- a/src/it/report-changes-system/verify.bsh +++ b/src/it/report-changes-system/verify.bsh @@ -27,7 +27,7 @@ boolean result = true; try { - File report = new File( basedir, "target/site/changes-report.html" ); + File report = new File( basedir, "target/site/en/changes-report.html" ); if ( !report.exists() || report.isDirectory() ) { System.err.println( "report file is missing or a directory." ); diff --git a/src/it/report-jira-invalid-issuemanagement/pom.xml b/src/it/report-jira-invalid-issuemanagement/pom.xml index fb53f58e..ea4ab6f1 100644 --- a/src/it/report-jira-invalid-issuemanagement/pom.xml +++ b/src/it/report-jira-invalid-issuemanagement/pom.xml @@ -37,7 +37,7 @@ - @pom.version@ + @project.version@ jira @@ -84,7 +84,7 @@ org.apache.maven.plugins maven-changes-plugin - @pom.version@ + @project.version@ diff --git a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java index a2aa13ad..4fd7a8f3 100644 --- a/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java +++ b/src/main/java/org/apache/maven/plugins/announcement/AnnouncementMojo.java @@ -232,7 +232,7 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo { /** * Velocity Component. */ - @Component(role = VelocityComponent.class, hint = "maven-changes-plugin") + @Component private VelocityComponent velocity; /** diff --git a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java index 60249de4..383599e1 100644 --- a/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java +++ b/src/main/java/org/apache/maven/plugins/changes/AbstractChangesReport.java @@ -18,39 +18,11 @@ */ package org.apache.maven.plugins.changes; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import org.apache.commons.io.IOUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.doxia.site.decoration.Body; -import org.apache.maven.doxia.site.decoration.DecorationModel; -import org.apache.maven.doxia.site.decoration.Skin; -import org.apache.maven.doxia.siterenderer.Renderer; -import org.apache.maven.doxia.siterenderer.RendererException; -import org.apache.maven.doxia.siterenderer.RenderingContext; -import org.apache.maven.doxia.siterenderer.SiteRenderingContext; -import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.reporting.AbstractMavenReport; -import org.apache.maven.reporting.MavenReportException; -import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.codehaus.plexus.i18n.I18N; -import org.codehaus.plexus.util.ReaderFactory; /** * Base class with the things that should be in AbstractMavenReport anyway. Note: This file was copied from r415312 of @@ -67,24 +39,6 @@ public abstract class AbstractChangesReport extends AbstractMavenReport { @Parameter(property = "basedir", required = true) protected String basedir; - /** - * Report output directory. Note that this parameter is only relevant if the goal is run from the command line or - * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output - * directory configured in the Maven Site Plugin is used instead. - */ - @Parameter(defaultValue = "${project.reporting.outputDirectory}") - private File outputDirectory; - - /** - * Report output encoding. Note that this parameter is only relevant if the goal is run from the command line or - * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output encoding - * configured in the Maven Site Plugin is used instead. - * - * @since 2.4 - */ - @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") - private String outputEncoding; - /** * This will cause the execution to be run only at the top of a given module tree. That is, run in the project * contained in the same folder where the mvn execution was launched. @@ -102,116 +56,12 @@ public abstract class AbstractChangesReport extends AbstractMavenReport { @Parameter(defaultValue = "${session}", readonly = true, required = true) protected MavenSession mavenSession; - /** - * Doxia Site Renderer. - */ - @Component - protected Renderer siteRenderer; - - /** - * The Maven Project. - */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) - protected MavenProject project; - - /** - */ - @Component - protected ArtifactResolver resolver; - /** * Internationalization. */ @Component protected I18N i18n; - private Artifact getSkinArtifact() throws MojoExecutionException { - Skin skin = Skin.getDefaultSkin(); - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId(skin.getGroupId()); - coordinate.setArtifactId(skin.getArtifactId()); - coordinate.setVersion(skin.getVersion()); - ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest(mavenSession.getProjectBuildingRequest()); - pbr.setRemoteRepositories(project.getRemoteArtifactRepositories()); - try { - return resolver.resolveArtifact(pbr, coordinate).getArtifact(); - } catch (ArtifactResolverException e) { - throw new MojoExecutionException("Couldn't resolve the skin.", e); - } - } - - public void execute() throws MojoExecutionException { - if (!canGenerateReport()) { - return; - } - - // TODO: push to a helper? Could still be improved by taking more of the site information from the site plugin - Writer writer = null; - try { - DecorationModel model = new DecorationModel(); - model.setBody(new Body()); - Map attributes = new HashMap<>(); - attributes.put("outputEncoding", getOutputEncoding()); - Locale locale = Locale.getDefault(); - SiteRenderingContext siteContext = - siteRenderer.createContextForSkin(getSkinArtifact(), attributes, model, getName(locale), locale); - siteContext.setOutputEncoding(getOutputEncoding()); - - RenderingContext context = new RenderingContext(outputDirectory, getOutputName() + ".html"); - - SiteRendererSink sink = new SiteRendererSink(context); - generate(sink, null, locale); - - outputDirectory.mkdirs(); - - File file = new File(outputDirectory, getOutputName() + ".html"); - writer = new OutputStreamWriter(new FileOutputStream(file), getOutputEncoding()); - - siteRenderer.generateDocument(writer, sink, siteContext); - - writer.close(); - writer = null; - - siteRenderer.copyResources(siteContext, outputDirectory); - } catch (RendererException | IOException | MavenReportException e) { - throw new MojoExecutionException( - "An error has occurred in " + getName(Locale.ENGLISH) + " report generation.", e); - } finally { - IOUtils.closeQuietly(writer); - } - } - - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory() - */ - protected String getOutputDirectory() { - return outputDirectory.getAbsolutePath(); - } - - /** - * Get the effective reporting output file encoding. - * - * @return The effective reporting output file encoding, never null. - * @since 2.4 - */ - protected String getOutputEncoding() { - return (outputEncoding != null) ? outputEncoding : ReaderFactory.UTF_8; - } - - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getProject() - */ - protected MavenProject getProject() { - return project; - } - - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() - */ - protected Renderer getSiteRenderer() { - return siteRenderer; - } - /** * Returns true if the current project is located at the Execution Root Directory (where mvn was * launched). @@ -219,14 +69,6 @@ protected Renderer getSiteRenderer() { * @return true if the current project is at the Execution Root */ protected boolean isThisTheExecutionRoot() { - getLog().debug("Root Folder:" + mavenSession.getExecutionRootDirectory()); - getLog().debug("Current Folder:" + basedir); - boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir); - if (result) { - getLog().debug("This is the execution root."); - } else { - getLog().debug("This is NOT the execution root."); - } - return result; + return getProject().isExecutionRoot(); } } diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java b/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java index 0ec1232e..47b86226 100644 --- a/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java +++ b/src/main/java/org/apache/maven/plugins/changes/ChangesCheckMojo.java @@ -23,7 +23,7 @@ import java.text.SimpleDateFormat; import java.util.Locale; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java b/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java similarity index 98% rename from src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java rename to src/main/java/org/apache/maven/plugins/changes/ChangesReport.java index 58307fdc..da2c8a0f 100644 --- a/src/main/java/org/apache/maven/plugins/changes/ChangesMojo.java +++ b/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java @@ -35,7 +35,6 @@ import org.apache.commons.collections.map.CaseInsensitiveMap; import org.apache.commons.io.input.XmlStreamReader; -import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -54,7 +53,7 @@ * @version $Id$ */ @Mojo(name = "changes-report", threadSafe = true) -public class ChangesMojo extends AbstractChangesReport { +public class ChangesReport extends AbstractChangesReport { /** * A flag whether the report should also include changes from child modules. If set to false, only the * changes from current project will be written to the report. @@ -168,12 +167,6 @@ public class ChangesMojo extends AbstractChangesReport { @Parameter(defaultValue = "en") private String publishDateLocale; - /** - * @since 2.2 - */ - @Parameter(defaultValue = "${session}", readonly = true, required = true) - protected MavenSession session; - /** * @since 2.4 */ @@ -397,7 +390,7 @@ private ChangesXML getChangesFromFile(File changesXml, MavenProject project, Pro Collections.emptyList(), false, encoding, - session, + mavenSession, additionalProperties); mavenFileFilter.copyFile(mavenFileFilterRequest); changesXml = resultFile; diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java b/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java index a1ff1dfb..e92e84d9 100644 --- a/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java +++ b/src/main/java/org/apache/maven/plugins/changes/ChangesReportGenerator.java @@ -25,11 +25,11 @@ import java.util.Map; import java.util.ResourceBundle; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; 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.doxia.util.DoxiaUtils; import org.apache.maven.plugins.changes.model.Action; import org.apache.maven.plugins.changes.model.Component; import org.apache.maven.plugins.changes.model.DueTo; @@ -384,6 +384,7 @@ private void constructReleaseHistory(Sink sink, ResourceBundle bundle, List getEntries(final List releases) { final SyndEntry entry = new SyndEntryImpl(); entry.setTitle(release.getVersion()); - entry.setLink(link + "#" + HtmlTools.encodeId(release.getVersion())); + entry.setLink(link + "#" + DoxiaUtils.encodeId(release.getVersion())); entry.setDescription(getSyndContent(release)); entry.setPublishedDate(getDate(release.getDateRelease(), dateFormat)); diff --git a/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java b/src/main/java/org/apache/maven/plugins/github/GitHubReport.java similarity index 99% rename from src/main/java/org/apache/maven/plugins/github/GitHubMojo.java rename to src/main/java/org/apache/maven/plugins/github/GitHubReport.java index 60937665..4a54b0fd 100644 --- a/src/main/java/org/apache/maven/plugins/github/GitHubMojo.java +++ b/src/main/java/org/apache/maven/plugins/github/GitHubReport.java @@ -45,7 +45,7 @@ * @since 2.8 */ @Mojo(name = "github-report", threadSafe = true) -public class GitHubMojo extends AbstractChangesReport { +public class GitHubReport extends AbstractChangesReport { /** * Valid Github columns. diff --git a/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java b/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java index ed1ea320..8a1abb62 100644 --- a/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java +++ b/src/main/java/org/apache/maven/plugins/issues/IssuesReportGenerator.java @@ -82,6 +82,7 @@ private void constructHeaderRow(Sink sink, List issueList, ResourceBundle } sink.table(); + sink.tableRows(); sink.tableRow(); @@ -245,7 +246,7 @@ private void constructDetailRows(Sink sink, List issueList, ResourceBundl sink.tableRow_(); } - + sink.tableRows_(); sink.table_(); } } diff --git a/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java b/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java index 020b0c18..21329356 100644 --- a/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java +++ b/src/main/java/org/apache/maven/plugins/jira/AbstractJiraDownloader.java @@ -19,8 +19,6 @@ package org.apache.maven.plugins.jira; import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; @@ -30,8 +28,6 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Settings; -import org.apache.maven.wagon.proxy.ProxyInfo; -import org.apache.maven.wagon.proxy.ProxyUtils; /** * Abstract API, more or less, to retrieving issue information from JIRA. Intended to have subclasses for the old (RSS) @@ -153,26 +149,7 @@ protected void getProxyInfo(String jiraUrl) { } if (proxy != null) { - - ProxyInfo proxyInfo = new ProxyInfo(); - proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts()); - - // Get the host out of the JIRA URL - URL url = null; - try { - url = new URL(jiraUrl); - } catch (MalformedURLException e) { - getLog().error("Invalid JIRA URL: " + jiraUrl + ". " + e.getMessage()); - } - String jiraHost = null; - if (url != null) { - jiraHost = url.getHost(); - } - - if (ProxyUtils.validateNonProxyHosts(proxyInfo, jiraHost)) { - return; - } - + /// TODO check proxy.getNonProxyHosts() proxyHost = settings.getActiveProxy().getHost(); proxyPort = settings.getActiveProxy().getPort(); proxyUser = settings.getActiveProxy().getUsername(); diff --git a/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java b/src/main/java/org/apache/maven/plugins/jira/JiraReport.java similarity index 99% rename from src/main/java/org/apache/maven/plugins/jira/JiraMojo.java rename to src/main/java/org/apache/maven/plugins/jira/JiraReport.java index 03ea4c0c..ea2eea51 100644 --- a/src/main/java/org/apache/maven/plugins/jira/JiraMojo.java +++ b/src/main/java/org/apache/maven/plugins/jira/JiraReport.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.ResourceBundle; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.changes.AbstractChangesReport; @@ -45,7 +45,7 @@ * @version $Id$ */ @Mojo(name = "jira-report", threadSafe = true) -public class JiraMojo extends AbstractChangesReport { +public class JiraReport extends AbstractChangesReport { /** * Valid JIRA columns. */ diff --git a/src/main/java/org/apache/maven/plugins/resource/loader/ProjectResourceLoader.java b/src/main/java/org/apache/maven/plugins/resource/loader/ProjectResourceLoader.java deleted file mode 100644 index bfd3b761..00000000 --- a/src/main/java/org/apache/maven/plugins/resource/loader/ProjectResourceLoader.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.resource.loader; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -import org.apache.commons.collections.ExtendedProperties; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.runtime.resource.Resource; -import org.apache.velocity.runtime.resource.loader.ResourceLoader; -import org.apache.velocity.util.StringUtils; - -/** - * Resource Loader for external projects. - * - * @version $Id$ - */ -public class ProjectResourceLoader extends ResourceLoader { - /** - * The paths to search for templates. - */ - private List paths = null; - - /** - * Used to map the path that a template was found on so that we can properly check the modification times of the - * files. - */ - private Hashtable templatePaths = new Hashtable<>(); - - public void init(ExtendedProperties configuration) { - rsvc.getLog().info("ProjectResourceLoader : initialization starting."); - - String separator = System.getProperty("file.separator"); - - String path = System.getProperty("user.dir") + separator + "src" + separator + "main" + separator + "resources" - + separator; - - rsvc.getLog().info("path :" + path); - - paths = new ArrayList<>(); - - paths.add(path); - - for (String path1 : paths) { - rsvc.getLog().info("ProjectResourceLoader : adding path '" + path1 + "'"); - } - rsvc.getLog().info("ProjectResourceLoader : initialization complete."); - } - - /** - * Get an InputStream so that the Runtime can build a template with it. - * - * @param templateName name of template to get - * @return InputStream containing the template - * @throws ResourceNotFoundException if template not found in the file template path. - */ - public synchronized InputStream getResourceStream(String templateName) throws ResourceNotFoundException { - /* - * Make sure we have a valid templateName. - */ - if (templateName == null || templateName.length() == 0) { - /* - * If we don't get a properly formed templateName then there's not much we can do. So we'll forget about - * trying to search any more paths for the template. - */ - throw new ResourceNotFoundException("Need to specify a file name or file path!"); - } - - String template = StringUtils.normalizePath(templateName); - if (template == null || template.length() == 0) { - String msg = "Project Resource loader error : argument " + template - + " contains .. and may be trying to access " + "content outside of template root. Rejected."; - - rsvc.getLog().error("ProjectResourceLoader : " + msg); - - throw new ResourceNotFoundException(msg); - } - - /* - * if a / leads off, then just nip that :) - */ - if (template.startsWith("/")) { - template = template.substring(1); - } - - // MCHANGES-118 adding the basedir path - paths.add((String) rsvc.getApplicationAttribute("baseDirectory")); - - for (String path : paths) { - InputStream inputStream = findTemplate(path, template); - - if (inputStream != null) { - /* - * Store the path that this template came from so that we can check its modification time. - */ - - templatePaths.put(templateName, path); - return inputStream; - } - } - - /* - * We have now searched all the paths for templates and we didn't find anything so throw an exception. - */ - String msg = "ProjectResourceLoader Error: cannot find resource " + template; - - throw new ResourceNotFoundException(msg); - } - - /** - * Try to find a template given a normalized path. - * - * @param path a normalized path - * @return InputStream input stream that will be parsed - */ - private InputStream findTemplate(String path, String template) { - try { - File file = new File(path, template); - - if (file.canRead()) { - return new BufferedInputStream(new FileInputStream(file.getAbsolutePath())); - } else { - return null; - } - } catch (FileNotFoundException fnfe) { - /* - * log and convert to a general Velocity ResourceNotFoundException - */ - return null; - } - } - - /** - * How to keep track of all the modified times across the paths. Note that a file might have appeared in a directory - * which is earlier in the path; so we should search the path and see if the file we find that way is the same as - * the one that we have cached. - */ - public boolean isSourceModified(Resource resource) { - /* - * we assume that the file needs to be reloaded; if we find the original file and it's unchanged, then we'll - * flip this. - */ - boolean modified = true; - - String fileName = resource.getName(); - String path = templatePaths.get(fileName); - File currentFile = null; - - for (int i = 0; currentFile == null && i < paths.size(); i++) { - String testPath = paths.get(i); - File testFile = new File(testPath, fileName); - if (testFile.canRead()) { - currentFile = testFile; - } - } - File file = new File(path, fileName); - if (currentFile == null || !file.exists()) { - /* - * noop: if the file is missing now (either the cached file is gone, or the file can no longer be found) - * then we leave modified alone (it's set to true); a reload attempt will be done, which will either use a - * new template or fail with an appropriate message about how the file couldn't be found. - */ - } else if (currentFile.equals(file) && file.canRead()) { - /* - * if only if currentFile is the same as file and file.lastModified() is the same as - * resource.getLastModified(), then we should use the cached version. - */ - modified = (file.lastModified() != resource.getLastModified()); - } - - /* - * rsvc.debug("isSourceModified for " + fileName + ": " + modified); - */ - return modified; - } - - public long getLastModified(Resource resource) { - String path = templatePaths.get(resource.getName()); - File file = new File(path, resource.getName()); - - if (file.canRead()) { - return file.lastModified(); - } else { - return 0; - } - } -} diff --git a/src/main/java/org/apache/maven/plugins/trac/TracMojo.java b/src/main/java/org/apache/maven/plugins/trac/TracReport.java similarity index 99% rename from src/main/java/org/apache/maven/plugins/trac/TracMojo.java rename to src/main/java/org/apache/maven/plugins/trac/TracReport.java index 7c2b1482..979acc82 100644 --- a/src/main/java/org/apache/maven/plugins/trac/TracMojo.java +++ b/src/main/java/org/apache/maven/plugins/trac/TracReport.java @@ -43,7 +43,7 @@ * @since 2.1 */ @Mojo(name = "trac-report", threadSafe = true) -public class TracMojo extends AbstractChangesReport { +public class TracReport extends AbstractChangesReport { /** * Deprecated Trac columns. */ diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 3c7408c0..00000000 --- a/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - org.codehaus.plexus.velocity.VelocityComponent - maven-changes-plugin - org.codehaus.plexus.velocity.DefaultVelocityComponent - - - - resource.loader - file,class - - - class.resource.loader.class - org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader - - - file.resource.loader.class - org.apache.maven.plugins.resource.loader.ProjectResourceLoader - - - - - - \ No newline at end of file diff --git a/src/site/site.xml b/src/site/site.xml index e6242582..41198034 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -22,6 +22,13 @@ under the License. + + + org.apache.maven.skins + maven-fluido-skin + ${version.maven-fluido-skin} + + diff --git a/src/test/java/org/apache/maven/plugins/announcement/AnnouncementMojoTest.java b/src/test/java/org/apache/maven/plugins/announcement/AnnouncementMojoTest.java index 52ace024..32e69202 100644 --- a/src/test/java/org/apache/maven/plugins/announcement/AnnouncementMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/announcement/AnnouncementMojoTest.java @@ -48,7 +48,7 @@ public void testAnnounceGeneration() throws Exception { setVariableValueToObject(mojo, "version", "1.1"); setVariableValueToObject(mojo, "template", "announcement.vm"); setVariableValueToObject( - mojo, "templateDirectory", "/src/main/resources/org/apache/maven/plugins/announcement/"); + mojo, "templateDirectory", "src/main/resources/org/apache/maven/plugins/announcement/"); setVariableValueToObject(mojo, "basedir", getBasedir()); setVariableValueToObject(mojo, "introduction", "Nice library"); mojo.execute(); diff --git a/src/test/java/org/apache/maven/plugins/jira/JiraMojoTest.java b/src/test/java/org/apache/maven/plugins/jira/JiraReportTest.java similarity index 89% rename from src/test/java/org/apache/maven/plugins/jira/JiraMojoTest.java rename to src/test/java/org/apache/maven/plugins/jira/JiraReportTest.java index 869949bd..a27babf0 100644 --- a/src/test/java/org/apache/maven/plugins/jira/JiraMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/jira/JiraReportTest.java @@ -21,13 +21,13 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; /** - * Unit tests for {@link JiraMojo}. + * Unit tests for {@link JiraReport}. * * @author jrh3k5 * @since 2.8 */ -public class JiraMojoTest extends AbstractMojoTestCase { - private final JiraMojo mojo = new JiraMojo(); +public class JiraReportTest extends AbstractMojoTestCase { + private final JiraReport mojo = new JiraReport(); /** * If the mojo has been marked to be skipped, then it should indicate that the report cannot be generated. diff --git a/src/test/java/org/apache/maven/plugins/jira/JiraUnicodeTestCase.java b/src/test/java/org/apache/maven/plugins/jira/JiraUnicodeTestCase.java index dc25af65..b4297045 100644 --- a/src/test/java/org/apache/maven/plugins/jira/JiraUnicodeTestCase.java +++ b/src/test/java/org/apache/maven/plugins/jira/JiraUnicodeTestCase.java @@ -20,14 +20,20 @@ import java.io.File; import java.io.InputStream; +import java.util.Collections; +import java.util.List; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.MavenProject; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.util.DefaultRepositorySystemSession; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; import static java.nio.charset.StandardCharsets.UTF_8; @@ -47,13 +53,33 @@ public void testUnicodeReport() throws Exception { assertNotNull(pom); assertTrue(pom.exists()); - JiraMojo mojo = (JiraMojo) lookupMojo("jira-report", pom); + JiraReport mojo = (JiraReport) lookupMojo("jira-report", pom); MavenProject project = new JiraUnicodeTestProjectStub(); MavenSession session = newMavenSession(project); - DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); - repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager("target/local-repo")); + + RepositorySystem repositorySystem = lookup(RepositorySystem.class); + + DefaultRepositorySystemSession repositorySystemSession = + (DefaultRepositorySystemSession) session.getRepositorySession(); + repositorySystemSession.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager( + repositorySystemSession, new LocalRepository(System.getProperty("localRepository")))); + + // Test need to download a maven-fluido-skin if not present in local repo + List remoteRepositories = repositorySystem.newResolutionRepositories( + repositorySystemSession, + Collections.singletonList( + new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2") + .build())); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); + setVariableValueToObject(mojo, "repoSession", repositorySystemSession); + setVariableValueToObject(mojo, "remoteProjectRepositories", remoteRepositories); + + setVariableValueToObject(mojo, "siteDirectory", new File("non-existing")); setVariableValueToObject(mojo, "mavenSession", session); + setVariableValueToObject(mojo, "mojoExecution", new MojoExecution(new Plugin(), "jira-report", "default")); + String jiraXml; try (InputStream testJiraXmlStream = JiraUnicodeTestCase.class.getResourceAsStream("unicode-jira-results.xml")) {