From b822663bf973255a3e9c44e05f245b71f3ab3fcc Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 6 Jan 2023 23:59:58 +0100 Subject: [PATCH 001/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 62af4bf7c..b92bd0f98 100644 --- a/pom.xml +++ b/pom.xml @@ -24,11 +24,11 @@ under the License. org.apache.maven.plugins maven-plugins 38 - + maven-dependency-plugin - 3.5.0 + 3.5.1-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -92,7 +92,7 @@ under the License. 3.3.0 1.0.0.v20140518 8 - 2023-01-06T22:57:48Z + 2023-01-06T22:59:57Z 1.7.36 4.6.0 @@ -430,7 +430,7 @@ under the License. ${project.build.directory}/local-repo - + From 5cdc37ce173513d8a55355349c0a77b640ad567f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 8 Jan 2023 23:15:31 +0100 Subject: [PATCH 002/283] Fix pom format after release --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b92bd0f98..697fa0306 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ under the License. org.apache.maven.plugins maven-plugins 38 - + maven-dependency-plugin @@ -430,7 +430,7 @@ under the License. ${project.build.directory}/local-repo - + From b5f495f373dc178cf714b52a01b2d01de669afcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sat, 2 May 2020 12:43:41 +0200 Subject: [PATCH 003/283] Remove unused local variable --- .../plugins/dependency/resolvers/ResolvePluginsMojo.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index b2393f717..eac7afd88 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -146,7 +146,6 @@ protected Set resolvePluginArtifacts() throws ArtifactFilterException, final FilterArtifacts filter = getArtifactsFilter(); artifacts = filter.filter(artifacts); - Set resolvedArtifacts = new LinkedHashSet<>(artifacts.size()); // final ArtifactFilter filter = getPluginFilter(); for (final Artifact artifact : new LinkedHashSet<>(artifacts)) { // if ( !filter.include( artifact ) ) @@ -166,9 +165,7 @@ protected Set resolvePluginArtifacts() throws ArtifactFilterException, ProjectBuildingRequest buildingRequest = newResolvePluginProjectBuildingRequest(); // resolve the new artifact - resolvedArtifacts.add(getArtifactResolver() - .resolveArtifact(buildingRequest, artifact) - .getArtifact()); + getArtifactResolver().resolveArtifact(buildingRequest, artifact).getArtifact(); } return artifacts; } From 8c3b20f68bcdda469bc0452b0f6fb7d810f09d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Thu, 29 Dec 2022 10:52:05 +0100 Subject: [PATCH 004/283] Remove unused fields --- .../maven/plugins/dependency/GetMojo.java | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 283c753c4..1d7270482 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -84,38 +84,6 @@ public class GetMojo extends AbstractMojo { private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); - /** - * The groupId of the artifact to download. Ignored if {@link #artifact} is used. - */ - @Parameter(property = "groupId") - private String groupId; - - /** - * The artifactId of the artifact to download. Ignored if {@link #artifact} is used. - */ - @Parameter(property = "artifactId") - private String artifactId; - - /** - * The version of the artifact to download. Ignored if {@link #artifact} is used. - */ - @Parameter(property = "version") - private String version; - - /** - * The classifier of the artifact to download. Ignored if {@link #artifact} is used. - * - * @since 2.3 - */ - @Parameter(property = "classifier") - private String classifier; - - /** - * The packaging of the artifact to download. Ignored if {@link #artifact} is used. - */ - @Parameter(property = "packaging", defaultValue = "jar") - private String packaging = "jar"; - /** * Repositories in the format id::[layout]::url or just url, separated by comma. ie. * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com @@ -271,36 +239,53 @@ protected boolean isSkip() { } /** + * The groupId of the artifact to download. Ignored if {@link #artifact} is used. + * * @param groupId The groupId. */ + @Parameter(property = "groupId") public void setGroupId(String groupId) { this.coordinate.setGroupId(groupId); } /** + * The artifactId of the artifact to download. Ignored if {@link #artifact} is used. + * * @param artifactId The artifactId. */ + @Parameter(property = "artifactId") public void setArtifactId(String artifactId) { this.coordinate.setArtifactId(artifactId); } /** + * The version of the artifact to download. Ignored if {@link #artifact} is used. + * * @param version The version. */ + @Parameter(property = "version") public void setVersion(String version) { this.coordinate.setVersion(version); } /** + * The classifier of the artifact to download. Ignored if {@link #artifact} is used. + * * @param classifier The classifier to be used. + * + * @since 2.3 */ + @Parameter(property = "classifier") public void setClassifier(String classifier) { this.coordinate.setClassifier(classifier); } /** + * The packaging of the artifact to download. Ignored if {@link #artifact} is used. + * * @param type packaging. */ + @Parameter(property = "packaging", defaultValue = "jar") public void setPackaging(String type) { this.coordinate.setType(type); } From 9ba726395a6a63a14033c9df6fcb4fa23a756911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Mon, 9 Jan 2023 20:46:13 +0100 Subject: [PATCH 005/283] [MDEP-843] Use GAV fields to support them as parameters --- .../plugins/dependency/ListClassesMojo.java | 19 ++++++-- .../dependency/TestListClassesMojo.java | 48 +++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index 18b11b0d1..13a879d20 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -192,13 +192,24 @@ private void printClassesFromArtifactResult(ArtifactResult result) throws IOExce } } + boolean hasGAVSpecified() { + return artifact != null || (groupId != null && artifactId != null && version != null); + } + private ProjectBuildingRequest makeBuildingRequest() throws MojoExecutionException, MojoFailureException { - if (artifact == null) { - throw new MojoFailureException("You must specify an artifact, " - + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0"); + if (!hasGAVSpecified()) { + throw new MojoFailureException("You must specify an artifact OR GAV separately, " + + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0 OR " + + "-DgroupId=org.apache.maven.plugins -DartifactId=maven-downloader-plugin -Dversion=1.0"); } - String[] tokens = artifact.split(":"); + String[] tokens = artifact != null + ? artifact.split(":") + : classifier != null + ? new String[] {groupId, artifactId, version, packaging, classifier} + : packaging != null + ? new String[] {groupId, artifactId, version, packaging} + : new String[] {groupId, artifactId, version}; if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, you must specify " + "groupId:artifactId:version[:packaging[:classifier]] " + artifact); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index 88cc4c16f..f16d4aa22 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -82,6 +82,30 @@ public void testListClassesNotTransitive() throws Exception { Assert.assertEquals(expectedLogArgs, infoArgsCaptor.getAllValues()); } + public void testListClassesNotTransitiveByGAV() throws Exception { + Path path = Paths.get("src/test/resources/unit/list-test/testListClassesNotTransitive.txt"); + List expectedLogArgs = Files.readAllLines(path); + ArgumentCaptor infoArgsCaptor = ArgumentCaptor.forClass(String.class); + + setVariableValueToObject( + mojo, + "remoteRepositories", + "central::default::https://repo.maven.apache.org/maven2," + + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); + setVariableValueToObject(mojo, "groupId", "org.apache.commons"); + setVariableValueToObject(mojo, "artifactId", "commons-lang3"); + setVariableValueToObject(mojo, "version", "3.6"); + setVariableValueToObject(mojo, "transitive", Boolean.FALSE); + + Log log = Mockito.mock(Log.class); + mojo.setLog(log); + + mojo.execute(); + + Mockito.verify(log, Mockito.times(expectedLogArgs.size())).info(infoArgsCaptor.capture()); + Assert.assertEquals(expectedLogArgs, infoArgsCaptor.getAllValues()); + } + public void testListClassesTransitive() throws Exception { Path path = Paths.get("src/test/resources/unit/list-test/testListClassesTransitive.txt"); List expectedLogArgs = Files.readAllLines(path); @@ -103,4 +127,28 @@ public void testListClassesTransitive() throws Exception { Mockito.verify(log, Mockito.times(expectedLogArgs.size())).info(infoArgsCaptor.capture()); Assert.assertEquals(expectedLogArgs, infoArgsCaptor.getAllValues()); } + + public void testListClassesTransitiveByGAV() throws Exception { + Path path = Paths.get("src/test/resources/unit/list-test/testListClassesTransitive.txt"); + List expectedLogArgs = Files.readAllLines(path); + ArgumentCaptor infoArgsCaptor = ArgumentCaptor.forClass(String.class); + + setVariableValueToObject( + mojo, + "remoteRepositories", + "central::default::https://repo.maven.apache.org/maven2," + + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); + setVariableValueToObject(mojo, "groupId", "org.apache.commons"); + setVariableValueToObject(mojo, "artifactId", "commons-lang3"); + setVariableValueToObject(mojo, "version", "3.6"); + setVariableValueToObject(mojo, "transitive", Boolean.TRUE); + + Log log = Mockito.mock(Log.class); + mojo.setLog(log); + + mojo.execute(); + + Mockito.verify(log, Mockito.times(expectedLogArgs.size())).info(infoArgsCaptor.capture()); + Assert.assertEquals(expectedLogArgs, infoArgsCaptor.getAllValues()); + } } From a6866bae9673571e2c137d97847779e5b7f040d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Mon, 9 Jan 2023 21:05:29 +0100 Subject: [PATCH 006/283] [MDEP-842] Use skip field in :list-classes --- .../org/apache/maven/plugins/dependency/ListClassesMojo.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index 13a879d20..d921728cf 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -149,6 +149,11 @@ public class ListClassesMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { + if (skip) { + getLog().info("Skipping plugin execution"); + return; + } + ProjectBuildingRequest buildingRequest = makeBuildingRequest(); try { From 2e4bf81bbe1e30984cacd56ac71023ec4e7aea4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Dec 2022 22:01:22 +0000 Subject: [PATCH 007/283] Bump mockito-core from 4.9.0 to 4.11.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.9.0 to 4.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.9.0...v4.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 697fa0306..03abec2eb 100644 --- a/pom.xml +++ b/pom.xml @@ -283,7 +283,7 @@ under the License. org.mockito mockito-core - 4.9.0 + 4.11.0 test From 459bbd1877b5f8d2e85952b21f343014048d3ab3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 22:00:52 +0000 Subject: [PATCH 008/283] Bump mrm-maven-plugin from 1.4.1 to 1.5.0 Bumps [mrm-maven-plugin](https://github.com/mojohaus/mrm) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/mojohaus/mrm/releases) - [Commits](https://github.com/mojohaus/mrm/compare/mrm-1.4.1...1.5.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mrm-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03abec2eb..1bf90c37a 100644 --- a/pom.xml +++ b/pom.xml @@ -420,7 +420,7 @@ under the License. org.codehaus.mojo mrm-maven-plugin - 1.4.1 + 1.5.0 repository.proxy.url From ed15c9fdc02d71f75e7dbb9ef2571459f2f5a789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 13 Feb 2023 15:35:51 -0500 Subject: [PATCH 009/283] [MDEP-630] build project without processing plugins --- .../fromDependencies/AbstractDependencyFilterMojo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 7d1ab01a1..ee2151a7d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -348,10 +348,10 @@ protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean private MavenProject buildProjectFromArtifact(Artifact artifact) throws MojoExecutionException { try { return projectBuilder - .build(artifact, session.getProjectBuildingRequest()) + .build(artifact, session.getProjectBuildingRequest().setProcessPlugins(false)) .getProject(); } catch (ProjectBuildingException e) { - throw new MojoExecutionException(e.getMessage(), e); + throw new MojoExecutionException("Coud not build project for " + artifact.getId(), e); } } From da83f2ad30a7bc793c93198bfe12246ec62a309a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 17 Mar 2023 16:33:05 -0400 Subject: [PATCH 010/283] remove release property --- src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml b/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml index 8e8a292cf..22c2be078 100644 --- a/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml +++ b/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml @@ -28,7 +28,6 @@ UTF-8 - 1.7 1.7 From b5b6f9e02ed091fa92c37f236a13e1efd9d20e9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 21:44:18 +0000 Subject: [PATCH 011/283] Bump jettyVersion from 9.4.49.v20220914 to 9.4.51.v20230217 (#295) Bumps `jettyVersion` from 9.4.49.v20220914 to 9.4.51.v20230217. Updates `jetty-server` from 9.4.49.v20220914 to 9.4.51.v20230217 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.49.v20220914...jetty-9.4.51.v20230217) Updates `jetty-util` from 9.4.49.v20220914 to 9.4.51.v20230217 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.49.v20220914...jetty-9.4.51.v20230217) Updates `jetty-security` from 9.4.49.v20220914 to 9.4.51.v20230217 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.49.v20220914...jetty-9.4.51.v20230217) --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bf90c37a..f8f644f71 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ under the License. 3.2.5 - 9.4.49.v20220914 + 9.4.51.v20230217 3.3.0 1.0.0.v20140518 8 From a2dc6150494ff68667af008043db7fcbdc4c4409 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 21:44:41 +0000 Subject: [PATCH 012/283] Bump plexus-io from 3.4.0 to 3.4.1 (#292) Bumps [plexus-io](https://github.com/codehaus-plexus/plexus-io) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/codehaus-plexus/plexus-io/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-io/compare/plexus-io-3.4.0...plexus-io-3.4.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f8f644f71..3be80911f 100644 --- a/pom.xml +++ b/pom.xml @@ -185,7 +185,7 @@ under the License. org.codehaus.plexus plexus-io - 3.4.0 + 3.4.1 From 43c0ab2c03a296ffcadce9d45fa5870a36257f6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Mar 2023 11:19:14 +0000 Subject: [PATCH 013/283] Bump plexus-utils from 3.5.0 to 3.5.1 (#297) Bumps [plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.5.0...plexus-utils-3.5.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3be80911f..3c2c421db 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.5.0 + 3.5.1 org.codehaus.plexus From 333bfa471f64527e922d93693bde09415949a960 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Mar 2023 11:19:35 +0000 Subject: [PATCH 014/283] Bump plexus-archiver from 4.6.0 to 4.6.2 (#289) Bumps [plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.6.0 to 4.6.2. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.6.0...plexus-archiver-4.6.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c2c421db..2171748f0 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-01-06T22:59:57Z 1.7.36 - 4.6.0 + 4.6.2 From 69840a2002c209f6cb5983beae38deb0a58ddd52 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 23 Mar 2023 08:26:03 -0400 Subject: [PATCH 015/283] use Apache Commons StringUtil (#290) * replace Codehaus Plexus utils with Apache Commons * lang dependency --- pom.xml | 5 +++++ .../maven/plugins/dependency/AbstractDependencyMojo.java | 2 +- .../java/org/apache/maven/plugins/dependency/GetMojo.java | 2 +- .../maven/plugins/dependency/PurgeLocalRepositoryMojo.java | 2 +- .../maven/plugins/dependency/analyze/AnalyzeDepMgt.java | 2 +- .../fromConfiguration/AbstractFromConfigurationMojo.java | 2 +- .../plugins/dependency/fromConfiguration/UnpackMojo.java | 2 +- .../fromDependencies/AbstractDependencyFilterMojo.java | 2 +- .../dependency/fromDependencies/BuildClasspathMojo.java | 2 +- .../maven/plugins/dependency/utils/DependencyUtil.java | 2 +- .../plugins/dependency/utils/filters/DestFileFilter.java | 2 +- .../dependency/utils/markers/UnpackFileMarkerHandler.java | 2 +- .../utils/translators/ClassifierTypeTranslator.java | 2 +- .../fromDependencies/TestCopyDependenciesMojo.java | 2 +- .../fromDependencies/TestCopyDependenciesMojo2.java | 2 +- .../fromDependencies/TestUnpackDependenciesMojo.java | 2 +- .../testUtils/stubs/StubUnpackFileMarkerHandler.java | 2 +- .../maven/plugins/dependency/utils/TestDependencyUtil.java | 2 +- 18 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 2171748f0..2f9f4ef49 100644 --- a/pom.xml +++ b/pom.xml @@ -220,6 +220,11 @@ under the License. commons-collections4 4.2 + + org.apache.commons + commons-lang3 + 3.12.0 + diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 66c64c8e2..ade8347c2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; @@ -43,7 +44,6 @@ import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.ReflectionUtils; -import org.codehaus.plexus.util.StringUtils; import org.sonatype.plexus.build.incremental.BuildContext; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 1d7270482..b5e3dd01a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -48,7 +49,6 @@ import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; -import org.codehaus.plexus.util.StringUtils; /** * Resolves a single artifact, eventually transitively, from the specified remote repositories. Caveat: will always diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index 01be06394..a2438ac93 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -26,6 +26,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -61,7 +62,6 @@ import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; /** * When run on a project, remove the project dependencies from the local repository, and optionally re-resolve them. diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index afb52f999..aff848f21 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -36,7 +37,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; /** * This mojo looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 6e6dd5271..401a6f3c1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -40,7 +41,6 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.apache.maven.shared.transfer.repository.RepositoryManager; -import org.codehaus.plexus.util.StringUtils; /** * Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index b76add1e0..40eeb8ce8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -30,7 +31,6 @@ import org.apache.maven.plugins.dependency.utils.markers.MarkerHandler; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; import org.codehaus.plexus.components.io.filemappers.FileMapper; -import org.codehaus.plexus.util.StringUtils; /** * Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index ee2151a7d..8899bda09 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; @@ -51,7 +52,6 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; -import org.codehaus.plexus.util.StringUtils; /** * Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 8424f7084..564b878c1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -35,6 +35,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; @@ -47,7 +48,6 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.repository.RepositoryManager; -import org.codehaus.plexus.util.StringUtils; /** * This goal outputs a classpath string of dependencies from the local repository to a file or log. diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index 2c7c2c2a0..ae7a00ead 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -26,10 +26,10 @@ import java.io.StringReader; import java.io.Writer; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.util.StringUtils; /** * Utility class with static helper methods. diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 4c4bbbfdc..50edd77bd 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -23,12 +23,12 @@ import java.nio.file.Files; import java.util.LinkedHashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; -import org.codehaus.plexus.util.StringUtils; /** * @author Brian Fox diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 9dadf452e..3e62f9602 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -19,8 +19,8 @@ package org.apache.maven.plugins.dependency.utils.markers; import java.io.File; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; -import org.codehaus.plexus.util.StringUtils; /** * @author Damian Bradicich diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java index d9cf3caff..431a59ce3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java @@ -20,13 +20,13 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.logging.Log; import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; -import org.codehaus.plexus.util.StringUtils; /** * @author Brian Fox diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index bb92b2f63..5b7bac704 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; @@ -33,7 +34,6 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; public class TestCopyDependenciesMojo extends AbstractDependencyMojoTestCase { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 5ef9062e8..369199a0a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -44,7 +45,6 @@ import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 708832b12..75dfbe5eb 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; @@ -36,7 +37,6 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; public class TestUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java index dab1ebec8..4988c4cd0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java @@ -19,9 +19,9 @@ package org.apache.maven.plugins.dependency.testUtils.stubs; import java.io.File; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; -import org.codehaus.plexus.util.StringUtils; public class StubUnpackFileMarkerHandler extends UnpackFileMarkerHandler { public StubUnpackFileMarkerHandler(ArtifactItem artifactItem, File markerFilesDirectory) { diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java index 8302b70f5..ac0caa606 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Random; import junit.framework.TestCase; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; @@ -30,7 +31,6 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; -import org.codehaus.plexus.util.StringUtils; /** * @author brianf From 6c228d9c985feb936adb9bd7e61a4b1e44f9a270 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 30 Mar 2023 22:44:28 +0200 Subject: [PATCH 016/283] Add Jira autolink --- .asf.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.asf.yaml b/.asf.yaml index 8162c5ec3..8a7df800f 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -28,3 +28,5 @@ github: squash: true merge: false rebase: true + autolink_jira: + - MDEP \ No newline at end of file From f60f7a7955b451a913068cf5823017eff197f2a1 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 1 Apr 2023 11:32:59 +0200 Subject: [PATCH 017/283] [MDEP-849] Replace Maven shared StringUtils with Commons Lang3 Co-authored-by: Moderne --- .../maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index fe6e19c3e..cb9f8d515 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.plugin.AbstractMojo; @@ -39,7 +40,6 @@ import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; -import org.apache.maven.shared.utils.StringUtils; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; From 17a9af300618e6bd0e0a7bfefe4c76cbb5fd956c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 1 Apr 2023 12:38:49 +0200 Subject: [PATCH 018/283] [MDEP-850] Upgrade Parent to 39 --- pom.xml | 6 +++--- .../dependency/AbstractDependencyMojo.java | 1 + .../dependency/DisplayAncestorsMojo.java | 1 + .../maven/plugins/dependency/GetMojo.java | 1 + .../plugins/dependency/ListClassesMojo.java | 1 + .../plugins/dependency/PropertiesMojo.java | 1 + .../dependency/PurgeLocalRepositoryMojo.java | 1 + .../dependency/analyze/AbstractAnalyzeMojo.java | 1 + .../dependency/analyze/AnalyzeDepMgt.java | 1 + .../analyze/AnalyzeDuplicateMojo.java | 1 + .../dependency/analyze/AnalyzeReportMojo.java | 1 + .../dependency/analyze/AnalyzeReportView.java | 1 + .../AbstractFromConfigurationMojo.java | 1 + .../fromConfiguration/ArtifactItem.java | 1 + .../dependency/fromConfiguration/CopyMojo.java | 1 + .../fromConfiguration/UnpackMojo.java | 1 + .../AbstractDependencyFilterMojo.java | 1 + .../AbstractFromDependenciesMojo.java | 1 + .../fromDependencies/BuildClasspathMojo.java | 1 + .../fromDependencies/CopyDependenciesMojo.java | 1 + .../UnpackDependenciesMojo.java | 1 + .../resolvers/AbstractResolveMojo.java | 1 + .../ExcludeReactorProjectsArtifactFilter.java | 1 + .../ExcludeReactorProjectsDependencyFilter.java | 1 + .../dependency/resolvers/GoOfflineMojo.java | 1 + .../resolvers/ResolveDependenciesMojo.java | 1 + .../resolvers/ResolvePluginsMojo.java | 1 + .../tree/BuildingDependencyNodeVisitor.java | 1 + .../tree/DOTDependencyNodeVisitor.java | 1 + .../tree/GraphmlDependencyNodeVisitor.java | 1 + .../tree/TGFDependencyNodeVisitor.java | 1 + .../maven/plugins/dependency/tree/TreeMojo.java | 1 + .../dependency/utils/DependencyStatusSets.java | 1 + .../dependency/utils/DependencyUtil.java | 1 + .../utils/filters/DestFileFilter.java | 1 + .../utils/filters/MarkerFileFilter.java | 1 + .../utils/markers/DefaultFileMarkerHandler.java | 1 + .../utils/markers/SourcesFileMarkerHandler.java | 1 + .../utils/markers/UnpackFileMarkerHandler.java | 1 + .../utils/translators/ArtifactTranslator.java | 1 + .../translators/ClassifierTypeTranslator.java | 1 + .../dependency/AbstractDependencyMojoTest.java | 11 ++++++----- .../AbstractDependencyMojoTestCase.java | 1 + .../plugins/dependency/TestCollectMojo.java | 1 + .../maven/plugins/dependency/TestGetMojo.java | 1 + .../plugins/dependency/TestListClassesMojo.java | 1 + .../plugins/dependency/TestPropertiesMojo.java | 1 + .../maven/plugins/dependency/TestSkip.java | 9 +++++---- .../dependency/analyze/TestAnalyzeDepMgt.java | 5 +++-- .../analyze/TestAnalyzeDuplicateMojo.java | 1 + .../fromConfiguration/TestArtifactItem.java | 1 + .../fromConfiguration/TestCopyMojo.java | 1 + .../TestIncludeExcludeUnpackMojo.java | 1 + .../fromConfiguration/TestUnpackMojo.java | 1 + .../TestBuildClasspathMojo.java | 1 + .../TestCopyDependenciesMojo.java | 1 + .../TestCopyDependenciesMojo2.java | 1 + ...estIncludeExcludeUnpackDependenciesMojo.java | 1 + .../TestUnpackDependenciesMojo.java | 1 + .../TestUnpackDependenciesMojo2.java | 1 + ...xcludeReactorProjectsArtifactFilterTest.java | 17 +++++++++-------- ...ludeReactorProjectsDependencyFilterTest.java | 11 ++++++----- .../resolvers/ResolveDependenciesMojoTest.java | 1 + .../dependency/resolvers/TestResolveMojo.java | 1 + .../DependencyArtifactStubFactory.java | 1 + .../testUtils/stubs/DependencyProjectStub.java | 1 + .../DuplicateDependencies2ProjectStub.java | 1 + .../stubs/DuplicateDependenciesProjectStub.java | 1 + .../stubs/StubDefaultFileMarkerHandler.java | 1 + .../stubs/StubSourcesFileMarkerHandler.java | 1 + .../stubs/StubUnpackFileMarkerHandler.java | 1 + .../plugins/dependency/tree/TestTreeMojo.java | 1 + .../tree/TestTreeMojo_ContainsVersion.java | 9 +++++---- .../dependency/utils/TestDependencyUtil.java | 1 + .../utils/filters/TestDestFileFilter.java | 1 + .../utils/filters/TestMarkerFileFilter.java | 1 + .../filters/TestResolveMarkerFileFilter.java | 1 + .../markers/TestDefaultMarkerFileHandler.java | 1 + .../markers/TestSourcesMarkerFileHandler.java | 1 + .../markers/TestUnpackMarkerFileHandler.java | 1 + .../TestClassifierTypeTranslator.java | 1 + 81 files changed, 111 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 2f9f4ef49..a295ad633 100644 --- a/pom.xml +++ b/pom.xml @@ -23,8 +23,8 @@ under the License. org.apache.maven.plugins maven-plugins - 38 - + 39 + maven-dependency-plugin @@ -435,7 +435,7 @@ under the License. ${project.build.directory}/local-repo - + diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index ade8347c2..0c8b6ae59 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.List; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; diff --git a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java index 248bef790..4e1be1b30 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; + import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index b5e3dd01a..159b775b5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index d921728cf..c34ad206d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -27,6 +27,7 @@ import java.util.jar.JarFile; import java.util.regex.Matcher; import java.util.regex.Pattern; + import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; diff --git a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java index 54c0eeee6..06b692eff 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index a2438ac93..0a5ecf227 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -26,6 +26,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index cb9f8d515..9360e6074 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index aff848f21..ee77f6dde 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index fe6aa8728..11a0d6a11 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -26,6 +26,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; + import org.apache.commons.collections4.CollectionUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java index 5e3e40fa3..677ab104d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java @@ -20,6 +20,7 @@ import java.util.Locale; import java.util.ResourceBundle; + import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Execute; diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java index c36cb4e38..17f346f64 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.ResourceBundle; + import org.apache.maven.artifact.Artifact; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 401a6f3c1..28d17611f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java index 214ca924a..f56ecf896 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Objects; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugins.dependency.utils.DependencyUtil; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index b6ccb4807..244c3e243 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.List; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 40eeb8ce8..af97beac5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.List; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 8899bda09..faa8735f2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 1226c8ada..a92e8298d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.fromDependencies; import java.io.File; + import org.apache.maven.plugins.annotations.Parameter; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 564b878c1..8b7f0633b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -35,6 +35,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 31d2477d7..2de21ef36 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index e7c812688..ebcfa0595 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.fromDependencies; import java.io.File; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 20f5a9b93..aee1208a4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.LinkedHashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilter.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilter.java index 42e42fec3..a93ef2af7 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilter.java @@ -22,6 +22,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java index 98a60bfda..b796f761c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.logging.Log; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index a0f8e09ab..2fc6d8f8f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -23,6 +23,7 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Dependency; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index be09c9afb..423c467bf 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -30,6 +30,7 @@ import java.util.Set; import java.util.jar.JarFile; import java.util.jar.Manifest; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index eac7afd88..bb2d7c574 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -22,6 +22,7 @@ import java.util.LinkedHashSet; import java.util.Objects; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java index 7834c50db..b2e3ef0e1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; + import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Exclusion; import org.apache.maven.shared.dependency.graph.DependencyNode; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java index bf4e0a947..238a62ae6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java @@ -20,6 +20,7 @@ import java.io.Writer; import java.util.List; + import org.apache.maven.shared.dependency.graph.DependencyNode; import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java index 11f75ff85..77c55c413 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.tree; import java.io.Writer; + import org.apache.maven.shared.dependency.graph.DependencyNode; import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java index c76fdb984..48ebfb0e9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java @@ -21,6 +21,7 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; + import org.apache.maven.shared.dependency.graph.DependencyNode; import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index ac1131242..9e8b10f78 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; + import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java index 07c7fa3f1..483e34691 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java @@ -20,6 +20,7 @@ import java.util.LinkedHashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index ae7a00ead..c3d5fc5b0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -26,6 +26,7 @@ import java.io.StringReader; import java.io.Writer; import java.util.Objects; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 50edd77bd..7852412ff 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -23,6 +23,7 @@ import java.nio.file.Files; import java.util.LinkedHashSet; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java index 51fe65fe3..f841e6e78 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java @@ -20,6 +20,7 @@ import java.util.LinkedHashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java index a8600efef..27d7e4f6d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java index 4b0d41f31..97638cd45 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 3e62f9602..063404d21 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.utils.markers; import java.io.File; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java index aeefae1e9..a1be9dc02 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.utils.translators; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java index 431a59ce3..bbedea458 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java @@ -20,6 +20,7 @@ import java.util.LinkedHashSet; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java index 8fc1e29a6..eba047534 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java @@ -18,19 +18,20 @@ */ package org.apache.maven.plugins.dependency; -import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithArtifactRepositories; -import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithPluginRepositories; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.ProjectBuildingRequest; +import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithArtifactRepositories; +import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithPluginRepositories; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class AbstractDependencyMojoTest extends TestCase { private MavenSession session = mock(MavenSession.class); diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 89ef23129..2f5bd7cf1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; + import org.apache.commons.io.FileUtils; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 8c3045a83..30f84893b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java index 4996b6974..4dfcc284c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java @@ -23,6 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; + import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index f16d4aa22..cd73bf741 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -23,6 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; + import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.logging.Log; diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java index 8f7b7af4a..3b0a6f2c3 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java index 156ac83f1..1b1923089 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java @@ -18,15 +18,16 @@ */ package org.apache.maven.plugins.dependency; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - import java.io.File; + import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.logging.Log; import org.mockito.ArgumentCaptor; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + public class TestSkip extends AbstractDependencyMojoTestCase { public void testSkipAnalyze() throws Exception { doTest("analyze"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java index 7d351437e..7b78a6eab 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java @@ -18,8 +18,6 @@ */ package org.apache.maven.plugins.dependency.analyze; -import static org.junit.Assert.assertNotEquals; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -27,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Set; + import junit.framework.TestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; @@ -38,6 +37,8 @@ import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; +import static org.junit.Assert.assertNotEquals; + public class TestAnalyzeDepMgt extends TestCase { AnalyzeDepMgt mojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java index 1c9750f9f..23796923b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; + import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java index 34ed4ac85..9aa993f86 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.fromConfiguration; import java.io.IOException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index 1a8eee21d..cdd132f4d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 335b76be7..0483dddf8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index fa147079e..6ddd37bb6 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index 871e668e0..52beca51d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index 5b7bac704..b71ba127a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 369199a0a..629cd811a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 377a557d0..60faec3ee 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 75dfbe5eb..d24ed3c07 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index e841643f5..20f64b56a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilterTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilterTest.java index 699a2c151..203d76546 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilterTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsArtifactFilterTest.java @@ -18,16 +18,9 @@ */ package org.apache.maven.plugins.dependency.resolvers; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.util.HashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.stubs.ArtifactStub; @@ -37,6 +30,14 @@ import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.mockito.ArgumentCaptor; +import static java.util.Collections.singleton; +import static java.util.Collections.singletonList; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class ExcludeReactorProjectsArtifactFilterTest extends AbstractDependencyMojoTestCase { public void testFilter() throws ArtifactFilterException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java index e4f0e65d6..d7aca0520 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java @@ -18,14 +18,10 @@ */ package org.apache.maven.plugins.dependency.resolvers; -import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.util.Collections; import java.util.HashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.logging.Log; @@ -36,6 +32,11 @@ import org.apache.maven.shared.artifact.filter.resolve.Node; import org.mockito.ArgumentCaptor; +import static java.util.Collections.singletonList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class ExcludeReactorProjectsDependencyFilterTest extends AbstractDependencyMojoTestCase { public void testReject() { final Artifact artifact1 = new ArtifactStub(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index 3685035e5..b4de4fcb2 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 2d38335f9..8d74d2345 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java index 7c49e44a3..18ca35940 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.VersionRange; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java index a3a26f24e..9083b3887 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java index e4e779b58..a9c528382 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; + import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java index 9c0c5af5a..662248dd7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; + import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubDefaultFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubDefaultFileMarkerHandler.java index 199664fab..038ad5bca 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubDefaultFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubDefaultFileMarkerHandler.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.testUtils.stubs; import java.io.File; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubSourcesFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubSourcesFileMarkerHandler.java index 22ab432cc..8d41c8d47 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubSourcesFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubSourcesFileMarkerHandler.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.testUtils.stubs; import java.io.File; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler; diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java index 4988c4cd0..411aa048e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.testUtils.stubs; import java.io.File; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index 95d4f7da9..aef1c69db 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java index ff90ca33a..95badb0b3 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java @@ -18,16 +18,17 @@ */ package org.apache.maven.plugins.dependency.tree; -import static org.apache.maven.plugins.dependency.tree.TreeMojo.containsVersion; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.Collections; + import junit.framework.TestCase; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; +import static org.apache.maven.plugins.dependency.tree.TreeMojo.containsVersion; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + /** * Tests TreeMojo.containsVersion. */ diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java index ac0caa606..3974101f9 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; + import junit.framework.TestCase; import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java index b3e627c34..ff5d5a840 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java index 31b05e8ae..717b19421 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java index 8b4ac4078..d32550ef3 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; + import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java index 7d793e17f..c9eb2d4a3 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestSourcesMarkerFileHandler.java b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestSourcesMarkerFileHandler.java index 9024b1237..0a498e3a4 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestSourcesMarkerFileHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestSourcesMarkerFileHandler.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; + import junit.framework.TestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java index 0038d2a2b..7be795fb5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; + import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index 4fa377f23..422b36d9b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.DefaultArtifactFactory; From 2f8a2c92b01c132fcd1e61d494eb750e7e543985 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 23:43:40 +0200 Subject: [PATCH 019/283] [MDEP-851] Bump plexus-archiver from 4.6.2 to 4.6.3 (#298) Bumps [plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.6.2 to 4.6.3. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.6.2...plexus-archiver-4.6.3) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a295ad633..6c1561385 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-01-06T22:59:57Z 1.7.36 - 4.6.2 + 4.6.3 From 344e508225c4ee7fabc04a5102df418f449875dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 00:47:22 +0200 Subject: [PATCH 020/283] [MDEP-854] Bump jsoup from 1.15.3 to 1.15.4 (#288) Bumps [jsoup](https://github.com/jhy/jsoup) from 1.15.3 to 1.15.4. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.15.3...jsoup-1.15.4) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c1561385..87aaba4ca 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,7 @@ under the License. org.jsoup jsoup - 1.15.3 + 1.15.4 From d2c2f54586020af38eb0908025c0d53b382fa1c6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 6 Apr 2023 00:43:01 +0200 Subject: [PATCH 021/283] [MDEP-853] list-repositories - improvements - use Resolver API instead of m-a-t - add information about mirrored repositories --- src/it/projects/list-repositories/pom.xml | 101 ++++++------ .../projects/list-repositories/verify.groovy | 28 ++++ .../dependency/ListRepositoriesMojo.java | 149 ++++++++++++++++++ .../resolvers/ListRepositoriesMojo.java | 66 -------- src/site/apt/index.apt.vm | 3 +- 5 files changed, 233 insertions(+), 114 deletions(-) create mode 100644 src/it/projects/list-repositories/verify.groovy create mode 100644 src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java delete mode 100644 src/main/java/org/apache/maven/plugins/dependency/resolvers/ListRepositoriesMojo.java diff --git a/src/it/projects/list-repositories/pom.xml b/src/it/projects/list-repositories/pom.xml index 5b3be7983..d74bc248d 100644 --- a/src/it/projects/list-repositories/pom.xml +++ b/src/it/projects/list-repositories/pom.xml @@ -1,47 +1,54 @@ - - - - - 4.0.0 - - org.apache.maven.its.dependency - test - 1.0-SNAPSHOT - - Test - - Test dependency:list-repositories - - - - UTF-8 - - - - - org.apache.maven - maven-project - 2.0.6 - - - - + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:list-repositories + + + + UTF-8 + + + + + fake-remote-repository + http://localhost:2345 + + + + + + org.apache.maven + maven-core + 3.2.5 + + + + \ No newline at end of file diff --git a/src/it/projects/list-repositories/verify.groovy b/src/it/projects/list-repositories/verify.groovy new file mode 100644 index 000000000..be64953d9 --- /dev/null +++ b/src/it/projects/list-repositories/verify.groovy @@ -0,0 +1,28 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String buildLog = file.getText( "UTF-8" ); +assert buildLog.contains( 'Project remote repositories used by this build:'); +assert buildLog.contains( '* fake-remote-repository (http://localhost:2345, default, releases+snapshots)'); +assert buildLog.contains( '* sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots) mirrored by mrm-maven-plugin'); +assert buildLog.contains( '* central (https://repo.maven.apache.org/maven2, default, releases) mirrored by mrm-maven-plugin'); + diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java new file mode 100644 index 000000000..81d402c13 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -0,0 +1,149 @@ +/* + * 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.dependency; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.maven.RepositoryUtils; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.CollectResult; +import org.eclipse.aether.collection.DependencyCollectionException; +import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.graph.DependencyVisitor; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.graph.visitor.TreeDependencyVisitor; + +/** + * Goal that collect all project dependencies and then lists the repositories used by the build and by the transitive + * dependencies + * + * @author Brian Fox + * @since 2.2 + */ +@Mojo(name = "list-repositories", threadSafe = true) +public class ListRepositoriesMojo extends AbstractDependencyMojo { + + @Component + RepositorySystem repositorySystem; + + /** + * Displays a list of the repositories used by this build. + * + * @throws MojoExecutionException with a message if an error occurs. + */ + @Override + protected void doExecute() throws MojoExecutionException { + + CollectRequest request = new CollectRequest(); + request.setRepositories(getProject().getRemoteProjectRepositories()); + request.setRootArtifact(RepositoryUtils.toArtifact(getProject().getArtifact())); + + ArtifactTypeRegistry artifactTypeRegistry = + session.getRepositorySession().getArtifactTypeRegistry(); + + request.setDependencies(getProject().getDependencies().stream() + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList())); + + request.setManagedDependencies(Optional.ofNullable(getProject().getDependencyManagement()) + .map(DependencyManagement::getDependencies) + .orElseGet(Collections::emptyList) + .stream() + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList())); + + try { + CollectResult collectResult = repositorySystem.collectDependencies(session.getRepositorySession(), request); + Set repositories = new HashSet<>(); + collectResult.getRoot().accept(new TreeDependencyVisitor(new DependencyVisitor() { + @Override + public boolean visitEnter(DependencyNode node) { + repositories.addAll(node.getRepositories()); + return true; + } + + @Override + public boolean visitLeave(DependencyNode node) { + return true; + } + })); + + StringBuilder message = new StringBuilder(); + + Map> repoGroupByMirrors = repositories.stream() + .collect(Collectors.groupingBy( + repo -> repo.getMirroredRepositories().isEmpty())); + + prepareRemoteRepositoriesList(message, repoGroupByMirrors.get(Boolean.TRUE)); + prepareRemoteMirrorRepositoriesList(message, repoGroupByMirrors.get(Boolean.FALSE)); + + getLog().info(message); + + } catch (DependencyCollectionException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } + + private void prepareRemoteMirrorRepositoriesList( + StringBuilder message, Collection remoteProjectRepositories) { + + Map mirrorMap = new HashMap<>(); + remoteProjectRepositories.forEach(repo -> { + repo.getMirroredRepositories().forEach(mrepo -> mirrorMap.put(mrepo, repo)); + }); + + mirrorMap.forEach((repo, mirror) -> message.append(" * ") + .append(repo) + .append(" mirrored by ") + .append(mirror) + .append(System.lineSeparator())); + } + + private void prepareRemoteRepositoriesList( + StringBuilder message, Collection remoteProjectRepositories) { + + message.append("Project remote repositories used by this build:").append(System.lineSeparator()); + + remoteProjectRepositories.forEach( + repo -> message.append(" * ").append(repo).append(System.lineSeparator())); + } + + private Map getMirroredRepo(Set repositories) { + Map mirrorMap = new HashMap<>(); + + repositories.stream() + .filter(repo -> !repo.getMirroredRepositories().isEmpty()) + .forEach(repo -> repo.getMirroredRepositories().forEach(mrepo -> mirrorMap.put(mrepo, repo))); + + return mirrorMap; + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListRepositoriesMojo.java deleted file mode 100644 index 59a785ce3..000000000 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListRepositoriesMojo.java +++ /dev/null @@ -1,66 +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.dependency.resolvers; - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.plugins.dependency.AbstractDependencyMojo; -import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult; -import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector; -import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException; - -/** - * Goal that resolves all project dependencies and then lists the repositories used by the build and by the transitive - * dependencies - * - * @author Brian Fox - * @since 2.2 - */ -@Mojo(name = "list-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) -public class ListRepositoriesMojo extends AbstractDependencyMojo { - /** - * Dependency collector, needed to resolve dependencies. - */ - @Component(role = DependencyCollector.class) - private DependencyCollector dependencyCollector; - - /** - * Displays a list of the repositories used by this build. - * - * @throws MojoExecutionException with a message if an error occurs. - */ - @Override - protected void doExecute() throws MojoExecutionException { - try { - CollectorResult collectResult = dependencyCollector.collectDependencies( - session.getProjectBuildingRequest(), getProject().getModel()); - - this.getLog().info("Repositories used by this build:"); - - for (ArtifactRepository repo : collectResult.getRemoteRepositories()) { - this.getLog().info(repo.toString()); - } - } catch (DependencyCollectorException e) { - throw new MojoExecutionException("Unable to resolve artifacts", e); - } - } -} diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 07e678e26..4cae408d4 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -74,7 +74,8 @@ ${project.name} *{{{./list-classes-mojo.html}dependency:list-classes}} displays the fully package-qualified names of all classes found in a specified artifact. - *{{{./list-repositories-mojo.html}dependency:list-repositories}} displays all project dependencies and then lists the repositories used. + *{{{./list-repositories-mojo.html}dependency:list-repositories}} collect all project dependencies and then lists the repositories + used by the build and by the transitive dependencies. *{{{./properties-mojo.html}dependency:properties}} set a property for each project dependency containing the to the artifact on the file system. From 9c0f93878c0c9851650166cc75c7e344882c57ae Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 12 Apr 2023 21:06:48 +0200 Subject: [PATCH 022/283] [MDEP-853] list-repositories - fix code format --- .../apache/maven/plugins/dependency/ListRepositoriesMojo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index 81d402c13..dd4f4a0b6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -27,6 +27,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; + import org.apache.maven.RepositoryUtils; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; From 6c3e3296e87d56d7cb82971e4e961368402e1eca Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 12 Apr 2023 21:20:33 +0200 Subject: [PATCH 023/283] Remove outdated changes list --- src/changes/changes.xml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 src/changes/changes.xml diff --git a/src/changes/changes.xml b/src/changes/changes.xml deleted file mode 100644 index 065cb8404..000000000 --- a/src/changes/changes.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Dependency Maven Plugin - Brian Fox - - - - - - Initial Release of Plugin - - Issue for initial import of plugin - Add strip version functionality to copyMojo - - - From 59c8868259850c441324a5ed638f0bc146e58e23 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 13 Apr 2023 00:13:41 +0200 Subject: [PATCH 024/283] [MDEP-855] Remove unused and ignored parameter - useJvmChmod --- src/it/projects/copy-dependencies/pom.xml | 1 - .../dependency/AbstractDependencyMojo.java | 25 ------------------- .../fromConfiguration/CopyMojo.java | 6 ----- .../CopyDependenciesMojo.java | 6 ----- .../resolvers/AbstractResolveMojo.java | 6 ----- .../fromConfiguration/TestUnpackMojo.java | 2 -- .../TestUnpackDependenciesMojo.java | 1 - .../TestUnpackDependenciesMojo2.java | 1 - .../plugin-config.xml | 1 - 9 files changed, 49 deletions(-) diff --git a/src/it/projects/copy-dependencies/pom.xml b/src/it/projects/copy-dependencies/pom.xml index cff5a89f6..398aeeb27 100644 --- a/src/it/projects/copy-dependencies/pom.xml +++ b/src/it/projects/copy-dependencies/pom.xml @@ -101,7 +101,6 @@ true ${project.build.directory}/it/copy-dep-test-1 - false diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 0c8b6ae59..d1140fcab 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -72,17 +72,6 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { @Parameter(defaultValue = "false") private boolean skipDuringIncrementalBuild; - /** - *

- * will use the jvm chmod, this is available for user and all level group level will be ignored - *

- * since 2.6 is on by default - * - * @since 2.5.1 - */ - @Parameter(property = "dependency.useJvmChmod", defaultValue = "true") - private boolean useJvmChmod = true; - /** * ignore to set file permissions when unpacking a dependency * @@ -377,20 +366,6 @@ public void setArchiverManager(ArchiverManager archiverManager) { this.archiverManager = archiverManager; } - /** - * @return {@link #useJvmChmod} - */ - public boolean isUseJvmChmod() { - return useJvmChmod; - } - - /** - * @param useJvmChmod {@link #useJvmChmod} - */ - public void setUseJvmChmod(boolean useJvmChmod) { - this.useJvmChmod = useJvmChmod; - } - /** * @return {@link #skip} */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index 244c3e243..9cf85e210 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -74,12 +74,6 @@ public class CopyMojo extends AbstractFromConfigurationMojo { @Parameter(property = "artifact") private String artifact; - /** - * not used in this goal - */ - @Parameter - protected boolean useJvmChmod = true; - /** * not used in this goal */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 2de21ef36..ebf766e54 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -92,12 +92,6 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.addParentPoms", defaultValue = "false") protected boolean addParentPoms; - /** - * not used in this goal - */ - @Parameter - protected boolean useJvmChmod = true; - /** * not used in this goal */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index aee1208a4..9ed8d961a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -66,12 +66,6 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; - /** - * not used in this goal - */ - @Parameter - protected boolean useJvmChmod = true; - /** * not used in this goal */ diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 6ddd37bb6..8ca9ad8c5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -61,8 +61,6 @@ protected void setUp() throws Exception { stubFactory.setSrcFile(new File( getBasedir() + File.separatorChar + "target/test-classes/unit/unpack-dependencies-test/test.txt")); - mojo.setUseJvmChmod(true); - MavenSession session = newMavenSession(mojo.getProject()); setVariableValueToObject(mojo, "session", session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index d24ed3c07..5780feeba 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -54,7 +54,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - mojo.setUseJvmChmod(true); // mojo.silent = true; // it needs to get the archivermanager diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 20f64b56a..0811e7925 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -46,7 +46,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - mojo.setUseJvmChmod(true); // mojo.silent = true; // it needs to get the archivermanager diff --git a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml index 01a1f1904..d44f38a36 100644 --- a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml +++ b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml @@ -25,7 +25,6 @@ true - true From e03abd6c3db17444f6ff5c8d3be8b80fca8f8d0e Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 17 Apr 2023 18:13:57 +0200 Subject: [PATCH 025/283] [MDEP-856] Upgrade transitive dependency to commons-text to 1.10.0 --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 87aaba4ca..49748eebe 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,12 @@ under the License. org.eclipse.sisu.plexus 0.3.0.M1 + + + org.apache.commons + commons-text + 1.10.0 + From d6f917e18f40c123efa4fe3c5ffbe338d12da0c3 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 1 Apr 2023 12:34:35 +0200 Subject: [PATCH 026/283] Replace vulnerable dependency in integration test Co-authored-by: dependabot[bot] --- .../pom.xml | 17 ++++++++++++++--- .../verify.bsh | 8 +++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml index 2a8e65209..749dd7064 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml @@ -33,9 +33,20 @@ - dom4j - dom4j - 1.6.1 + net.java.dev.msv + xsdlib + 2022.7 + + + + maven-compiler-plugin + + 8 + 8 + + + + diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh index 35957daaf..b3300d87b 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh @@ -23,9 +23,11 @@ String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); log = StringUtils.unifyLineSeparators(log, "\n"); -String expected = "[WARNING] Used undeclared dependencies found:\n" - + "[WARNING] xml-apis:xml-apis:jar:1.0.b2:compile\n" - + "[WARNING] class org.apache.xmlcommons.Version\n"; +String expected = "[WARNING] Used undeclared dependencies found:\n" + + "[WARNING] xml-apis:xml-apis:jar:1.4.01:compile\n" + + "[WARNING] class org.apache.xmlcommons.Version\n" + + "[WARNING] Unused declared dependencies found:\n" + + "[WARNING] net.java.dev.msv:xsdlib:jar:2022.7:compile"; if ( !log.contains(expected) ) { From 2d3239120fd4f81b50a393fa09590da49bdae2b9 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 17 Apr 2023 23:53:54 +0200 Subject: [PATCH 027/283] [MDEP-848] Bump maven-dependency-analyzer to 1.13.1 (ASM 9.5 - JDK 20, 21) --- .github/workflows/maven-verify.yml | 2 ++ pom.xml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 4d67fdcf9..970433585 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,3 +25,5 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 + with: + jdk-matrix: '[ "8", "11", "17", "20" ]' diff --git a/pom.xml b/pom.xml index 49748eebe..6013603ae 100644 --- a/pom.xml +++ b/pom.xml @@ -198,7 +198,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.13.0 + 1.13.1 org.apache.maven.shared @@ -400,6 +400,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin + 3.5.1 clean From 5df7ce0f521b0c60d1f61b3bd9823661e66b3d26 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 17 Apr 2023 22:34:13 +0200 Subject: [PATCH 028/283] [MDEP-857] Remove custom plexus configuration --- .../resources/META-INF/plexus/components.xml | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 src/main/resources/META-INF/plexus/components.xml 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 91ef15de7..000000000 --- a/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - org.codehaus.plexus.archiver.UnArchiver - zip - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - jar - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - war - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - ear - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - swc - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - nar - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - esb - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - sar - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - car - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - par - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.codehaus.plexus.archiver.UnArchiver - rar - - org.codehaus.plexus.archiver.zip.ZipUnArchiver - per-lookup - - - org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer - org.apache.maven.shared.dependency.analyzer.DefaultProjectDependencyAnalyzer - - - - From 7c75bc9c7e2f39348499180428b4b953bceeba2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 24 Apr 2023 11:46:22 +0200 Subject: [PATCH 029/283] configure notifications --- .asf.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index 8a7df800f..4110a1d10 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,4 +29,9 @@ github: merge: false rebase: true autolink_jira: - - MDEP \ No newline at end of file + - MDEP +notifications: + commits: commits@maven.apache.org + issues: issues@maven.apache.org + pullrequests: issues@maven.apache.org + jira_options: link label comment From 3fb3669a30d3e56b67095018d8017da654032e4f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 20 Apr 2023 00:08:25 +0200 Subject: [PATCH 030/283] [MDEP-859] Code refactor - UnpackUtil Methods for unpack artifacts are in AbstractDependencyMojo but are only used by unpack and unpack-dependencies mojos. We can create separate component and use only where is needed. --- pom.xml | 4 + .../projects/unpack-custom-ear/verify.groovy | 44 ++-- .../dependency/AbstractDependencyMojo.java | 208 ------------------ .../fromConfiguration/UnpackMojo.java | 21 +- .../UnpackDependenciesMojo.java | 26 ++- .../plugins/dependency/utils/UnpackUtil.java | 188 ++++++++++++++++ .../TestIncludeExcludeUnpackMojo.java | 5 - .../fromConfiguration/TestUnpackMojo.java | 3 +- .../TestUnpackDependenciesMojo.java | 3 +- .../TestUnpackDependenciesMojo2.java | 3 +- 10 files changed, 262 insertions(+), 243 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java diff --git a/pom.xml b/pom.xml index 6013603ae..6970be4fd 100644 --- a/pom.xml +++ b/pom.xml @@ -389,6 +389,10 @@ under the License. + + org.eclipse.sisu + sisu-maven-plugin + diff --git a/src/it/projects/unpack-custom-ear/verify.groovy b/src/it/projects/unpack-custom-ear/verify.groovy index 36eb8352a..9b92ae56d 100644 --- a/src/it/projects/unpack-custom-ear/verify.groovy +++ b/src/it/projects/unpack-custom-ear/verify.groovy @@ -1,22 +1,22 @@ -/* - * 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. - */ -def buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() -assert buildLog.length() != 0 -assert buildLog.text.contains( "[DEBUG] Found unArchiver by type: " ) +/* + * 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. + */ +def buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() +assert buildLog.length() != 0 +assert buildLog.text.contains( "[DEBUG] Found unArchiver: org.apache.maven.archiver.LogUnArchiver by type: custom-ear" ) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index d1140fcab..68cc286c4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -20,11 +20,8 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; @@ -36,26 +33,13 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.codehaus.plexus.archiver.ArchiverException; -import org.codehaus.plexus.archiver.UnArchiver; -import org.codehaus.plexus.archiver.manager.ArchiverManager; -import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; -import org.codehaus.plexus.archiver.zip.ZipUnArchiver; -import org.codehaus.plexus.components.io.filemappers.FileMapper; -import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.ReflectionUtils; import org.sonatype.plexus.build.incremental.BuildContext; /** * @author Brian Fox */ public abstract class AbstractDependencyMojo extends AbstractMojo { - /** - * To look up Archiver/UnArchiver implementations - */ - @Component - private ArchiverManager archiverManager; /** * For IDE build support @@ -72,14 +56,6 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { @Parameter(defaultValue = "false") private boolean skipDuringIncrementalBuild; - /** - * ignore to set file permissions when unpacking a dependency - * - * @since 2.7 - */ - @Parameter(property = "dependency.ignorePermissions", defaultValue = "false") - private boolean ignorePermissions; - /** * POM */ @@ -155,13 +131,6 @@ public final void execute() throws MojoExecutionException, MojoFailureException */ protected abstract void doExecute() throws MojoExecutionException, MojoFailureException; - /** - * @return Returns the archiverManager. - */ - public ArchiverManager getArchiverManager() { - return this.archiverManager; - } - /** * Does the actual copy of the file and logging. * @@ -188,146 +157,6 @@ protected void copyFile(File artifact, File destFile) throws MojoExecutionExcept } } - /** - * @param artifact {@link Artifact} - * @param location The location. - * @param encoding The encoding. - * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting - * shall happen. - * @throws MojoExecutionException in case of an error. - */ - protected void unpack(Artifact artifact, File location, String encoding, FileMapper[] fileMappers) - throws MojoExecutionException { - unpack(artifact, location, null, null, encoding, fileMappers); - } - - /** - * Unpacks the archive file. - * - * @param artifact File to be unpacked. - * @param location Location where to put the unpacked files. - * @param includes Comma separated list of file patterns to include i.e. **/.xml, - * **/*.properties - * @param excludes Comma separated list of file patterns to exclude i.e. **/*.xml, - * **/*.properties - * @param encoding Encoding of artifact. Set {@code null} for default encoding. - * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting - * shall happen. - * @throws MojoExecutionException In case of errors. - */ - protected void unpack( - Artifact artifact, - File location, - String includes, - String excludes, - String encoding, - FileMapper[] fileMappers) - throws MojoExecutionException { - unpack(artifact, artifact.getType(), location, includes, excludes, encoding, fileMappers); - } - - /** - * @param artifact {@link Artifact} - * @param type The type. - * @param location The location. - * @param includes includes list. - * @param excludes excludes list. - * @param encoding the encoding. - * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting - * shall happen. - * @throws MojoExecutionException in case of an error. - */ - protected void unpack( - Artifact artifact, - String type, - File location, - String includes, - String excludes, - String encoding, - FileMapper[] fileMappers) - throws MojoExecutionException { - File file = artifact.getFile(); - try { - logUnpack(file, location, includes, excludes); - - location.mkdirs(); - if (!location.exists()) { - throw new MojoExecutionException( - "Location to write unpacked files to could not be created: " + location); - } - - if (file.isDirectory()) { - // usual case is a future jar packaging, but there are special cases: classifier and other packaging - throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, " - + "unpack should be executed after packaging: see MDEP-98."); - } - - UnArchiver unArchiver; - - try { - unArchiver = archiverManager.getUnArchiver(type); - getLog().debug("Found unArchiver by type: " + unArchiver); - } catch (NoSuchArchiverException e) { - unArchiver = archiverManager.getUnArchiver(file); - getLog().debug("Found unArchiver by extension: " + unArchiver); - } - - if (encoding != null && unArchiver instanceof ZipUnArchiver) { - ((ZipUnArchiver) unArchiver).setEncoding(encoding); - getLog().info("Unpacks '" + type + "' with encoding '" + encoding + "'."); - } - - unArchiver.setIgnorePermissions(ignorePermissions); - - unArchiver.setSourceFile(file); - - unArchiver.setDestDirectory(location); - - if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) { - // Create the selectors that will filter - // based on include/exclude parameters - // MDEP-47 - IncludeExcludeFileSelector[] selectors = - new IncludeExcludeFileSelector[] {new IncludeExcludeFileSelector()}; - - if (StringUtils.isNotEmpty(excludes)) { - selectors[0].setExcludes(excludes.split(",")); - } - - if (StringUtils.isNotEmpty(includes)) { - selectors[0].setIncludes(includes.split(",")); - } - - unArchiver.setFileSelectors(selectors); - } - if (this.silent) { - silenceUnarchiver(unArchiver); - } - - unArchiver.setFileMappers(fileMappers); - - unArchiver.extract(); - } catch (NoSuchArchiverException e) { - throw new MojoExecutionException("Unknown archiver type", e); - } catch (ArchiverException e) { - throw new MojoExecutionException("Error unpacking file: " + file + " to: " + location, e); - } - buildContext.refresh(location); - } - - private void silenceUnarchiver(UnArchiver unArchiver) { - // dangerous but handle any errors. It's the only way to silence the unArchiver. - try { - Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses("logger", unArchiver.getClass()); - - field.setAccessible(true); - - field.set(unArchiver, this.getLog()); - } catch (Exception e) { - // was a nice try. Don't bother logging because the log is silent. - } - } - /** * @return Returns a new ProjectBuildingRequest populated from the current session and the current project remote * repositories, used to resolve artifacts. @@ -359,13 +188,6 @@ public MavenProject getProject() { return this.project; } - /** - * @param archiverManager The archiverManager to set. - */ - public void setArchiverManager(ArchiverManager archiverManager) { - this.archiverManager = archiverManager; - } - /** * @return {@link #skip} */ @@ -399,34 +221,4 @@ public void setSilent(boolean silent) { setLog(new DependencySilentLog()); } } - - private void logUnpack(File file, File location, String includes, String excludes) { - if (!getLog().isInfoEnabled()) { - return; - } - - StringBuilder msg = new StringBuilder(); - msg.append("Unpacking "); - msg.append(file); - msg.append(" to "); - msg.append(location); - - if (includes != null && excludes != null) { - msg.append(" with includes \""); - msg.append(includes); - msg.append("\" and excludes \""); - msg.append(excludes); - msg.append("\""); - } else if (includes != null) { - msg.append(" with includes \""); - msg.append(includes); - msg.append("\""); - } else if (excludes != null) { - msg.append(" with excludes \""); - msg.append(excludes); - msg.append("\""); - } - - getLog().info(msg.toString()); - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index af97beac5..f60199406 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -24,9 +24,11 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugins.dependency.utils.markers.MarkerHandler; @@ -42,6 +44,9 @@ @Mojo(name = "unpack", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresProject = false, threadSafe = true) public class UnpackMojo extends AbstractFromConfigurationMojo { + @Component + UnpackUtil unpackUtil; + /** * Directory to store flag files after unpack */ @@ -68,6 +73,14 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { @Parameter(property = "mdep.unpack.excludes") private String excludes; + /** + * ignore to set file permissions when unpacking a dependency + * + * @since 2.7 + */ + @Parameter(property = "dependency.ignorePermissions", defaultValue = "false") + private boolean ignorePermissions; + /** * {@link FileMapper} to be used for rewriting each target path, or {@code null} if no rewriting shall happen. * @@ -122,14 +135,16 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { private void unpackArtifact(ArtifactItem artifactItem) throws MojoExecutionException { MarkerHandler handler = new UnpackFileMarkerHandler(artifactItem, this.markersDirectory); - unpack( - artifactItem.getArtifact(), + unpackUtil.unpack( + artifactItem.getArtifact().getFile(), artifactItem.getType(), artifactItem.getOutputDirectory(), artifactItem.getIncludes(), artifactItem.getExcludes(), artifactItem.getEncoding(), - artifactItem.getFileMappers()); + ignorePermissions, + artifactItem.getFileMappers(), + getLog()); handler.setMarker(); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index ebcfa0595..ba36a233c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -22,12 +22,14 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -47,6 +49,10 @@ threadSafe = true) // CHECKSTYLE_ON: LineLength public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { + + @Component + UnpackUtil unpackUtil; + /** * A comma separated list of file patterns to include when unpacking the artifact. i.e. * **/*.xml,**/*.properties NOTE: Excludes patterns override the includes. (component code = @@ -67,6 +73,14 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.unpack.excludes") private String excludes; + /** + * ignore to set file permissions when unpacking a dependency + * + * @since 2.7 + */ + @Parameter(property = "dependency.ignorePermissions", defaultValue = "false") + private boolean ignorePermissions; + /** * Encoding of artifacts. * @@ -89,7 +103,6 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { * * @throws MojoExecutionException with a message if an error occurs. * @see #getDependencySets(boolean) - * @see #unpack(Artifact, File, String, FileMapper[]) */ @Override protected void doExecute() throws MojoExecutionException { @@ -105,7 +118,16 @@ protected void doExecute() throws MojoExecutionException { stripType, outputDirectory, artifact); - unpack(artifact, destDir, getIncludes(), getExcludes(), getEncoding(), getFileMappers()); + unpackUtil.unpack( + artifact.getFile(), + artifact.getType(), + destDir, + getIncludes(), + getExcludes(), + getEncoding(), + ignorePermissions, + getFileMappers(), + getLog()); DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(artifact, this.markersDirectory); handler.setMarker(); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java new file mode 100644 index 000000000..e28bafcd1 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java @@ -0,0 +1,188 @@ +/* + * 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.dependency.utils; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; + +import org.apache.commons.lang3.StringUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.Log; +import org.codehaus.plexus.archiver.ArchiverException; +import org.codehaus.plexus.archiver.UnArchiver; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; +import org.codehaus.plexus.archiver.zip.ZipUnArchiver; +import org.codehaus.plexus.components.io.filemappers.FileMapper; +import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector; +import org.sonatype.plexus.build.incremental.BuildContext; + +/** + * Provide unpack method in one place for {@link org.apache.maven.plugins.dependency.fromConfiguration.UnpackMojo} + * and {@link org.apache.maven.plugins.dependency.fromDependencies.UnpackDependenciesMojo} + */ +@Named +@Singleton +public class UnpackUtil { + + /** + * To look up Archiver/UnArchiver implementations + */ + private final ArchiverManager archiverManager; + + /** + * For IDE build support + */ + private final BuildContext buildContext; + + /** + * Default constructor. + * + * @param archiverManager an archiver {@link ArchiverManager} to use + * @param buildContext a build context + */ + @Inject + public UnpackUtil(ArchiverManager archiverManager, BuildContext buildContext) { + this.archiverManager = archiverManager; + this.buildContext = buildContext; + } + + /** + * @param file file to unpack + * @param type file / artifact type + * @param location The location. + * @param includes includes list. + * @param excludes excludes list. + * @param encoding the encoding. + * @param ignorePermissions ignore permissions + * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no + * rewriting + * shall happen. + * @param logger a Mojo logger + * @throws MojoExecutionException in case of an error. + */ + public void unpack( + File file, + String type, + File location, + String includes, + String excludes, + String encoding, + boolean ignorePermissions, + FileMapper[] fileMappers, + Log logger) + throws MojoExecutionException { + try { + logUnpack(logger, file, location, includes, excludes); + + location.mkdirs(); + if (!location.exists()) { + throw new MojoExecutionException( + "Location to write unpacked files to could not be created: " + location); + } + + if (file.isDirectory()) { + // usual case is a future jar packaging, but there are special cases: classifier and other packaging + throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, " + + "unpack should be executed after packaging: see MDEP-98."); + } + + UnArchiver unArchiver; + + try { + unArchiver = archiverManager.getUnArchiver(type); + logger.debug("Found unArchiver: " + unArchiver.getClass().getName() + " by type: " + type); + } catch (NoSuchArchiverException e) { + unArchiver = archiverManager.getUnArchiver(file); + logger.debug("Found unArchiver: " + unArchiver.getClass().getName() + " by file extension: " + file); + } + + if (encoding != null && unArchiver instanceof ZipUnArchiver) { + ((ZipUnArchiver) unArchiver).setEncoding(encoding); + logger.info("Unpacks '" + type + "' with encoding '" + encoding + "'."); + } + + unArchiver.setIgnorePermissions(ignorePermissions); + + unArchiver.setSourceFile(file); + + unArchiver.setDestDirectory(location); + + if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) { + // Create the selectors that will filter + // based on include/exclude parameters + // MDEP-47 + IncludeExcludeFileSelector[] selectors = + new IncludeExcludeFileSelector[] {new IncludeExcludeFileSelector()}; + + if (StringUtils.isNotEmpty(excludes)) { + selectors[0].setExcludes(excludes.split(",")); + } + + if (StringUtils.isNotEmpty(includes)) { + selectors[0].setIncludes(includes.split(",")); + } + + unArchiver.setFileSelectors(selectors); + } + + unArchiver.setFileMappers(fileMappers); + + unArchiver.extract(); + } catch (NoSuchArchiverException e) { + throw new MojoExecutionException("Unknown archiver type", e); + } catch (ArchiverException e) { + throw new MojoExecutionException("Error unpacking file: " + file + " to: " + location, e); + } + buildContext.refresh(location); + } + + private void logUnpack(Log logger, File file, File location, String includes, String excludes) { + if (logger.isInfoEnabled()) { + return; + } + + StringBuilder msg = new StringBuilder(); + msg.append("Unpacking "); + msg.append(file); + msg.append(" to "); + msg.append(location); + + if (includes != null && excludes != null) { + msg.append(" with includes \""); + msg.append(includes); + msg.append("\" and excludes \""); + msg.append(excludes); + msg.append("\""); + } else if (includes != null) { + msg.append(" with includes \""); + msg.append(includes); + msg.append("\""); + } else if (excludes != null) { + msg.append(" with excludes \""); + msg.append(excludes); + msg.append("\""); + } + + logger.info(msg.toString()); + } +} diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 0483dddf8..31de69673 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -29,7 +29,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; -import org.codehaus.plexus.archiver.manager.ArchiverManager; public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase { private final String PACKED_FILE = "test.zip"; @@ -51,8 +50,6 @@ protected void setUp() throws Exception { mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); // mojo.silent = true; - // it needs to get the archivermanager - // stubFactory.setUnpackableFile( mojo.getArchiverManager() ); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + PACKED_FILE_PATH)); @@ -63,8 +60,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - mojo.setArchiverManager(lookup(ArchiverManager.class)); - mojo.setMarkersDirectory(new File(this.testDir, "markers")); mojo.setArtifactItems(list); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 8ca9ad8c5..2adc2860f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -36,6 +36,7 @@ import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.archiver.manager.ArchiverManager; public class TestUnpackMojo extends AbstractDependencyMojoTestCase { @@ -55,7 +56,7 @@ protected void setUp() throws Exception { // MavenProject project = mojo.getProject(); // init classifier things // it needs to get the archivermanager - stubFactory.setUnpackableFile(mojo.getArchiverManager()); + stubFactory.setUnpackableFile(lookup(ArchiverManager.class)); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File( diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 5780feeba..6e9948308 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -38,6 +38,7 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.archiver.manager.ArchiverManager; public class TestUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { @@ -57,7 +58,7 @@ protected void setUp() throws Exception { // mojo.silent = true; // it needs to get the archivermanager - stubFactory.setUnpackableFile(mojo.getArchiverManager()); + stubFactory.setUnpackableFile(lookup(ArchiverManager.class)); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + UNPACKABLE_FILE_PATH)); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 0811e7925..515a87c24 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -30,6 +30,7 @@ import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.archiver.manager.ArchiverManager; public class TestUnpackDependenciesMojo2 extends AbstractDependencyMojoTestCase { @@ -49,7 +50,7 @@ protected void setUp() throws Exception { // mojo.silent = true; // it needs to get the archivermanager - stubFactory.setUnpackableFile(mojo.getArchiverManager()); + stubFactory.setUnpackableFile(lookup(ArchiverManager.class)); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + UNPACKABLE_FILE_PATH)); From abc76b54236dadefdb20dcdb7f5af82343fa37e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 May 2023 13:08:31 +0200 Subject: [PATCH 031/283] [MDEP-860] Bump maven-dependency-analyzer from 1.13.1 to 1.13.2 (#312) Bumps [maven-dependency-analyzer](https://github.com/apache/maven-dependency-analyzer) from 1.13.1 to 1.13.2. - [Commits](https://github.com/apache/maven-dependency-analyzer/compare/maven-dependency-analyzer-1.13.1...maven-dependency-analyzer-1.13.2) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6970be4fd..50d12062b 100644 --- a/pom.xml +++ b/pom.xml @@ -198,7 +198,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.13.1 + 1.13.2 org.apache.maven.shared From 4c3568ee5c7c07e5f2551bbc5855bd2f5e2302ce Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 15 May 2023 13:12:23 +0200 Subject: [PATCH 032/283] [MNG-6829] Replace any StringUtils#isEmpty(String) and #isNotEmpty(String) (#318) Use this link to re-run the recipe: https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../dependency/PurgeLocalRepositoryMojo.java | 13 ++++++------- .../AbstractDependencyFilterMojo.java | 5 ++--- .../fromDependencies/BuildClasspathMojo.java | 8 ++++---- .../plugins/dependency/utils/DependencyUtil.java | 2 +- .../maven/plugins/dependency/utils/UnpackUtil.java | 7 +++---- .../utils/translators/ClassifierTypeTranslator.java | 5 ++--- .../fromDependencies/TestCopyDependenciesMojo.java | 5 ++--- .../TestUnpackDependenciesMojo.java | 5 ++--- 8 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index 0a5ecf227..69f69694a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -298,7 +297,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { return; } - if (!StringUtils.isEmpty(manualInclude)) { + if (!(manualInclude == null || manualInclude.isEmpty())) { manualIncludes = this.parseIncludes(manualInclude); } // If it's a manual purge, the only step is to delete from the local repo @@ -382,13 +381,13 @@ private void manualPurge(List theIncludes) throws MojoExecutionException .toString()); for (String gavPattern : theIncludes) { - if (StringUtils.isEmpty(gavPattern)) { + if (gavPattern == null || gavPattern.isEmpty()) { getLog().debug("Skipping empty gav pattern"); continue; } String relativePath = gavToPath(gavPattern); - if (StringUtils.isEmpty(relativePath)) { + if (relativePath == null || relativePath.isEmpty()) { getLog().debug("Skipping empty relative path for gav pattern: " + gavPattern); continue; } @@ -414,7 +413,7 @@ private void manualPurge(List theIncludes) throws MojoExecutionException * @return the corresponding path */ private String gavToPath(String gav) { - if (StringUtils.isEmpty(gav)) { + if (gav == null || gav.isEmpty()) { return null; } @@ -450,14 +449,14 @@ private TransformableFilter createPurgeArtifactsFilter( } // The CLI includes/excludes overrides configuration in the pom - if (!StringUtils.isEmpty(this.include)) { + if (!(this.include == null || this.include.isEmpty())) { this.includes = parseIncludes(this.include); } if (this.includes != null) { subFilters.add(new PatternInclusionsFilter(includes)); } - if (!StringUtils.isEmpty(this.exclude)) { + if (!(this.exclude == null || this.exclude.isEmpty())) { this.excludes = parseIncludes(this.exclude); } if (this.excludes != null) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index faa8735f2..85e395768 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -24,7 +24,6 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; @@ -337,7 +336,7 @@ protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean // transform artifacts if classifier is set DependencyStatusSets status; - if (StringUtils.isNotEmpty(classifier)) { + if (classifier != null && !classifier.isEmpty()) { status = getClassifierTranslatedDependencies(artifacts, stopOnFailure); } else { status = filterMarkedDependencies(artifacts); @@ -395,7 +394,7 @@ protected DependencyStatusSets getClassifierTranslatedDependencies(Set // possibly translate artifacts into a new set of artifacts based on the // classifier and type // if this did something, we need to resolve the new artifacts - if (StringUtils.isNotEmpty(classifier)) { + if (classifier != null && !classifier.isEmpty()) { ArtifactTranslator translator = new ClassifierTypeTranslator(artifactHandlerManager, this.classifier, this.type); Collection coordinates = translator.translate(artifacts, getLog()); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 8b7f0633b..388c47c4e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -178,11 +178,11 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements @Override protected void doExecute() throws MojoExecutionException { // initialize the separators. - boolean isFileSepSet = StringUtils.isNotEmpty(fileSeparator); - boolean isPathSepSet = StringUtils.isNotEmpty(pathSeparator); + boolean isFileSepSet = fileSeparator != null && !fileSeparator.isEmpty(); + boolean isPathSepSet = pathSeparator != null && !pathSeparator.isEmpty(); // don't allow them to have absolute paths when they attach. - if (attach && StringUtils.isEmpty(localRepoProperty)) { + if (attach && (localRepoProperty == null || localRepoProperty.isEmpty())) { localRepoProperty = "${M2_REPO}"; } @@ -264,7 +264,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { if (prefix == null) { String file = art.getFile().getPath(); // substitute the property for the local repo path to make the classpath file portable. - if (StringUtils.isNotEmpty(localRepoProperty)) { + if (localRepoProperty != null && !localRepoProperty.isEmpty()) { ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); File localBasedir = repositoryManager.getLocalRepositoryBasedir(projectBuildingRequest); diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index c3d5fc5b0..0f58d1b2d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -271,7 +271,7 @@ public static String[] tokenizer(String str) { */ public static String cleanToBeTokenizedString(String str) { String ret = ""; - if (!StringUtils.isEmpty(str)) { + if (!(str == null || str.isEmpty())) { // remove initial and ending spaces, plus all spaces next to commas ret = str.trim().replaceAll("[\\s]*,[\\s]*", ","); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java index e28bafcd1..817adb4d6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java @@ -24,7 +24,6 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.archiver.ArchiverException; @@ -127,18 +126,18 @@ public void unpack( unArchiver.setDestDirectory(location); - if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) { + if ((excludes != null && !excludes.isEmpty()) || (includes != null && !includes.isEmpty())) { // Create the selectors that will filter // based on include/exclude parameters // MDEP-47 IncludeExcludeFileSelector[] selectors = new IncludeExcludeFileSelector[] {new IncludeExcludeFileSelector()}; - if (StringUtils.isNotEmpty(excludes)) { + if (excludes != null && !excludes.isEmpty()) { selectors[0].setExcludes(excludes.split(",")); } - if (StringUtils.isNotEmpty(includes)) { + if (includes != null && !includes.isEmpty()) { selectors[0].setIncludes(includes.split(",")); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java index bbedea458..c6f858907 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java @@ -21,7 +21,6 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -67,7 +66,7 @@ public Set translate(Set artifacts, Log log) { // will use the // base artifact value if null comes in final String useType; - if (StringUtils.isNotEmpty(this.type)) { + if (this.type != null && !this.type.isEmpty()) { useType = this.type; } else { useType = artifact.getType(); @@ -83,7 +82,7 @@ public Set translate(Set artifacts, Log log) { } String useClassifier; - if (StringUtils.isNotEmpty(this.classifier)) { + if (this.classifier != null && !this.classifier.isEmpty()) { useClassifier = this.classifier; } else { useClassifier = artifact.getClassifier(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index b71ba127a..e8b5da787 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -23,7 +23,6 @@ import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; @@ -390,10 +389,10 @@ public void dotestClassifierType(String testClassifier, String testType) throws String useClassifier = artifact.getClassifier(); String useType = artifact.getType(); - if (StringUtils.isNotEmpty(testClassifier)) { + if (testClassifier != null && !testClassifier.isEmpty()) { useClassifier = "-" + testClassifier; // type is only used if classifier is used. - if (StringUtils.isNotEmpty(testType)) { + if (testType != null && !testType.isEmpty()) { useType = testType; } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 6e9948308..9f54efdda 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -24,7 +24,6 @@ import java.util.Iterator; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; @@ -465,10 +464,10 @@ public void dotestClassifierType(String testClassifier, String testType) throws String useClassifier = artifact.getClassifier(); String useType = artifact.getType(); - if (StringUtils.isNotEmpty(testClassifier)) { + if (testClassifier != null && !testClassifier.isEmpty()) { useClassifier = testClassifier; // type is only used if classifier is used. - if (StringUtils.isNotEmpty(testType)) { + if (testType != null && !testType.isEmpty()) { useType = testType; } } From 9655a1e90ff426f1ae8cfaa13774a15ee7b1f8f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 22:53:19 +0200 Subject: [PATCH 033/283] [MDEP-854] Bump jsoup from 1.15.4 to 1.16.1 (#310) Bumps [jsoup](https://github.com/jhy/jsoup) from 1.15.4 to 1.16.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.15.4...jsoup-1.16.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 50d12062b..ebcfbfb6c 100644 --- a/pom.xml +++ b/pom.xml @@ -429,7 +429,7 @@ under the License. org.jsoup jsoup - 1.15.4 + 1.16.1 From ea1a9fd9273fbac6a89898270d1bf3160d745376 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Wed, 17 May 2023 23:10:20 +0200 Subject: [PATCH 034/283] [MDEP-864] Replace AnalyzeReportView with a new AnalyzeReportRenderer This closes #319 --- pom.xml | 21 ++ .../analyze-report/invoker.properties | 6 +- src/it/projects/analyze-report/pom.xml | 42 ---- .../invoker.properties | 7 +- .../dependency/analyze/AnalyzeReportMojo.java | 45 ++-- .../analyze/AnalyzeReportRenderer.java | 125 ++++++++++ .../dependency/analyze/AnalyzeReportView.java | 216 ------------------ src/main/resources/analyze-report.properties | 16 +- .../resources/analyze-report_de.properties | 15 +- .../resources/analyze-report_pt_BR.properties | 14 +- .../resources/analyze-report_sv.properties | 14 +- 11 files changed, 198 insertions(+), 323 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java delete mode 100644 src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java diff --git a/pom.xml b/pom.xml index ebcfbfb6c..35bed3be0 100644 --- a/pom.xml +++ b/pom.xml @@ -166,6 +166,16 @@ under the License. + + org.apache.maven.doxia + doxia-sink-api + 1.11.1 + + + org.apache.maven.reporting + maven-reporting-api + 3.1.1 + org.apache.maven.reporting maven-reporting-impl @@ -193,6 +203,17 @@ under the License. plexus-io 3.4.1 + + org.codehaus.plexus + plexus-i18n + 1.0-beta-10 + + + org.codehaus.plexus + plexus-component-api + + + diff --git a/src/it/projects/analyze-report/invoker.properties b/src/it/projects/analyze-report/invoker.properties index a3d335ef8..050bfcf1b 100644 --- a/src/it/projects/analyze-report/invoker.properties +++ b/src/it/projects/analyze-report/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = site +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze-report diff --git a/src/it/projects/analyze-report/pom.xml b/src/it/projects/analyze-report/pom.xml index 1cc764e48..a55389717 100644 --- a/src/it/projects/analyze-report/pom.xml +++ b/src/it/projects/analyze-report/pom.xml @@ -53,46 +53,4 @@ 2.0.6 - - - - - - maven-dependency-plugin - @project.version@ - - - maven-site-plugin - 3.10.0 - - - - - - - - - maven-project-info-reports-plugin - 3.2.1 - - - - index - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - analyze-report - - - - - - diff --git a/src/it/projects/analyze-testDependencyWithNonTestScope/invoker.properties b/src/it/projects/analyze-testDependencyWithNonTestScope/invoker.properties index 38edf1c32..050bfcf1b 100644 --- a/src/it/projects/analyze-testDependencyWithNonTestScope/invoker.properties +++ b/src/it/projects/analyze-testDependencyWithNonTestScope/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,5 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = clean ${project.groupId}:${project.artifactId}:${project.version}:analyze-report -invoker.maven.version = 3.0+ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze-report diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java index 677ab104d..5ef0ea7c9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java @@ -19,9 +19,7 @@ package org.apache.maven.plugins.dependency.analyze; import java.util.Locale; -import java.util.ResourceBundle; -import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -33,6 +31,7 @@ import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; +import org.codehaus.plexus.i18n.I18N; /** * Analyzes the dependencies of this project and produces a report that summarizes which are: used and declared; used @@ -76,6 +75,12 @@ public class AnalyzeReportMojo extends AbstractMavenReport { @Parameter(property = "mdep.analyze.skip", defaultValue = "false") private boolean skip; + /** + * Internationalization component + */ + @Component + private I18N i18n; + // Mojo methods ----------------------------------------------------------- /* @@ -100,13 +105,9 @@ public void executeReport(Locale locale) throws MavenReportException { analysis = analysis.ignoreNonCompile(); } - // Step 2: Create sink and bundle - Sink sink = getSink(); - ResourceBundle bundle = getBundle(locale); - // Step 3: Generate the report - AnalyzeReportView analyzethis = new AnalyzeReportView(); - analyzethis.generateReport(analysis, sink, bundle); + AnalyzeReportRenderer r = new AnalyzeReportRenderer(getSink(), i18n, locale, analysis); + r.render(); } // MavenReport methods ---------------------------------------------------- @@ -127,38 +128,30 @@ public boolean canGenerateReport() { return true; } - /* - * @see org.apache.maven.reporting.AbstractMavenReport#getOutputName() - */ + /** {@inheritDoc} */ @Override public String getOutputName() { return "dependency-analysis"; } - /* - * @see org.apache.maven.reporting.AbstractMavenReport#getName(java.util.Locale) - */ - @Override + /** {@inheritDoc} */ public String getName(Locale locale) { - return getBundle(locale).getString("analyze.report.name"); + return getI18nString(locale, "name"); } - /* - * @see org.apache.maven.reporting.AbstractMavenReport#getDescription(java.util.Locale) - */ - @Override + /** {@inheritDoc} */ public String getDescription(Locale locale) { - return getBundle(locale).getString("analyze.report.description"); + return getI18nString(locale, "description"); } // protected methods ------------------------------------------------------ /** - * @param locale the current locale - * @return The resource bundle {@link ResourceBundle} + * @param locale The locale + * @param key The key to search for + * @return The text appropriate for the locale. */ - protected ResourceBundle getBundle(Locale locale) { - return ResourceBundle.getBundle( - "analyze-report", locale, this.getClass().getClassLoader()); + protected String getI18nString(Locale locale, String key) { + return i18n.getString("analyze-report", locale, "report.analyze." + key); } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java new file mode 100644 index 000000000..80fb1b2d6 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java @@ -0,0 +1,125 @@ +/* + * 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.dependency.analyze; + +import java.util.Collection; +import java.util.Locale; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; +import org.codehaus.plexus.i18n.I18N; + +/** + * This is the view part of the analyze-report mojo. It generates the HTML report for the project website. The HTML + * output is same as the CLI output. + */ +public class AnalyzeReportRenderer extends AbstractMavenReportRenderer { + private final I18N i18n; + + private final Locale locale; + + private final ProjectDependencyAnalysis analysis; + + public AnalyzeReportRenderer(Sink sink, I18N i18n, Locale locale, ProjectDependencyAnalysis analysis) { + super(sink); + this.i18n = i18n; + this.locale = locale; + this.analysis = analysis; + } + + @Override + public String getTitle() { + return getI18nString("title"); + } + + /** + * @param key The key. + * @return The translated string. + */ + private String getI18nString(String key) { + return i18n.getString("analyze-report", locale, "report.analyze." + key); + } + + protected void renderBody() { + startSection(getTitle()); + + boolean reported = false; + + // Generate Used Declared dependencies: + if (!analysis.getUsedDeclaredArtifacts().isEmpty()) { + startSection(getI18nString("UsedDeclaredDependencies")); + renderDependenciesTable(sink, analysis.getUsedDeclaredArtifacts()); + endSection(); + reported = true; + } + + // Generate Used Undeclared dependencies: + + if (!analysis.getUsedUndeclaredArtifacts().isEmpty()) { + startSection(getI18nString("UsedUndeclaredDependencies")); + renderDependenciesTable(sink, analysis.getUsedUndeclaredArtifacts()); + endSection(); + reported = true; + } + + // Generate Unused declared dependencies: + if (!analysis.getUnusedDeclaredArtifacts().isEmpty()) { + startSection(getI18nString("UnusedDeclaredDependencies")); + renderDependenciesTable(sink, analysis.getUnusedDeclaredArtifacts()); + endSection(); + reported = true; + } + + // Generate Non-Test Scoped Test Dependencies: + if (!analysis.getTestArtifactsWithNonTestScope().isEmpty()) { + startSection(getI18nString("CompileScopeTestOnlyDependencies")); + renderDependenciesTable(sink, analysis.getTestArtifactsWithNonTestScope()); + endSection(); + reported = true; + } + + if (!reported) { + text(getI18nString("noDependencyProblems")); + } + + endSection(); + } + + private void renderDependenciesTable(Sink sink, Collection artifacts) { + startTable(); + + tableHeader(new String[] {"GroupId", "ArtifactId", "Version", "Scope", "Classifier", "Type", "Optional"}); + + for (Artifact artifact : artifacts) { + tableRow(new String[] { + artifact.getGroupId(), + artifact.getArtifactId(), + artifact.getVersion(), + artifact.getScope(), + artifact.getClassifier(), + artifact.getType(), + artifact.isOptional() ? "" : "false" + }); + } + + endTable(); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java deleted file mode 100644 index 17f346f64..000000000 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportView.java +++ /dev/null @@ -1,216 +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.dependency.analyze; - -import java.util.Iterator; -import java.util.ResourceBundle; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; - -/** - * This is the view part of the analyze-report mojo. It generates the HTML report for the project website. The HTML - * output is same as the CLI output. - */ -public class AnalyzeReportView { - /** - * Generates the HTML report. - * - * @param analysis {@link ProjectDependencyAnalysis} - * @param sink {@link Sink} - * @param bundle {@link ResourceBundle} - */ - public void generateReport(ProjectDependencyAnalysis analysis, Sink sink, ResourceBundle bundle) { - sink.head(); - sink.title(); - sink.text(bundle.getString("analyze.report.header")); - sink.title_(); - sink.head_(); - sink.body(); - - // Generate title - sink.section1(); - sink.sectionTitle1(); - sink.text(bundle.getString("analyze.report.mainTitle")); - sink.sectionTitle1_(); - - // Generate Used Declared dependencies: - sink.section2(); - sink.sectionTitle2(); - sink.text(bundle.getString("analyze.report.UsedDeclaredDependencies")); - sink.sectionTitle2_(); - if (analysis.getUsedDeclaredArtifacts().isEmpty()) { - sink.paragraph(); - sink.text(bundle.getString("analyze.report.noDependency")); - sink.paragraph_(); - sink.horizontalRule(); - } else { - generateDependenciesTable(sink, analysis.getUsedDeclaredArtifacts().iterator()); - } - sink.section2_(); - - // Generate Used Undeclared dependencies: - sink.section2(); - sink.sectionTitle2(); - sink.text(bundle.getString("analyze.report.UsedUndeclaredDependencies")); - sink.sectionTitle2_(); - if (analysis.getUsedUndeclaredArtifacts().isEmpty()) { - sink.paragraph(); - sink.text(bundle.getString("analyze.report.noDependency")); - sink.paragraph_(); - sink.horizontalRule(); - } else { - generateDependenciesTable( - sink, analysis.getUsedUndeclaredArtifacts().iterator()); - } - sink.section2_(); - - // Generate Unused declared dependencies: - sink.section2(); - sink.sectionTitle2(); - sink.text(bundle.getString("analyze.report.UnusedDeclaredDependencies")); - sink.sectionTitle2_(); - if (analysis.getUnusedDeclaredArtifacts().isEmpty()) { - sink.paragraph(); - sink.text(bundle.getString("analyze.report.noDependency")); - sink.paragraph_(); - sink.horizontalRule(); - } else { - generateDependenciesTable( - sink, analysis.getUnusedDeclaredArtifacts().iterator()); - } - sink.section2_(); - - // Generate Non-Test Scoped Test Dependencies: - sink.section2(); - sink.sectionTitle2(); - sink.text("Compile Scoped Test Dependencies"); - sink.sectionTitle2_(); - if (analysis.getTestArtifactsWithNonTestScope().isEmpty()) { - sink.paragraph(); - sink.text("None"); - sink.paragraph_(); - sink.horizontalRule(); - } else { - generateDependenciesTable( - sink, analysis.getTestArtifactsWithNonTestScope().iterator()); - } - sink.section2_(); - - sink.section1_(); - - // Closing the report - sink.body_(); - sink.flush(); - sink.close(); - } - - /** - * Generate a table for the given dependencies iterator. - * - * @param sink {@link Sink} - * @param iter {@link Artifact} - */ - public void generateDependenciesTable(Sink sink, Iterator iter) { - sink.table(); - sink.tableRows(null, false); - - sink.tableRow(); - sink.tableCell(); - sink.bold(); - sink.text("GroupId"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("ArtifactId"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("Version"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("Scope"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("Classifier"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("Type"); - sink.bold_(); - sink.tableCell_(); - - sink.tableCell(); - sink.bold(); - sink.text("Optional"); - sink.bold_(); - sink.tableCell_(); - - sink.tableRow_(); - while (iter.hasNext()) { - Artifact artifact = iter.next(); - - sink.tableRow(); - sink.tableCell(); - sink.text(artifact.getGroupId()); - sink.tableCell_(); - sink.tableCell(); - sink.text(artifact.getArtifactId()); - sink.tableCell_(); - sink.tableCell(); - sink.text(artifact.getVersion()); - sink.tableCell_(); - sink.tableCell(); - sink.text(artifact.getScope()); - sink.tableCell_(); - sink.tableCell(); - sink.text(artifact.getClassifier()); - sink.tableCell_(); - sink.tableCell(); - sink.text(artifact.getType()); - sink.tableCell_(); - sink.tableCell(); - if (artifact.isOptional()) { - sink.text(""); - } else { - sink.text("false"); - } - - sink.tableCell_(); - sink.tableRow_(); - } - - sink.tableRows_(); - sink.table_(); - sink.horizontalRule(); - } -} diff --git a/src/main/resources/analyze-report.properties b/src/main/resources/analyze-report.properties index 588f287c8..a2848b5d8 100644 --- a/src/main/resources/analyze-report.properties +++ b/src/main/resources/analyze-report.properties @@ -15,11 +15,11 @@ # specific language governing permissions and limitations # under the License. -analyze.report.name=Dependency Analysis -analyze.report.description=Dependency analysis of the project (used declared, used undeclared, unused declared) -analyze.report.header=Dependencies Report -analyze.report.mainTitle=Dependency Analysis -analyze.report.noDependency=None -analyze.report.UsedDeclaredDependencies=Used and declared dependencies -analyze.report.UsedUndeclaredDependencies=Used but undeclared dependencies -analyze.report.UnusedDeclaredDependencies=Unused but declared dependencies +report.analyze.name=Dependency Analysis +report.analyze.description=Dependency analysis of the project (used declared, used undeclared, unused declared) +report.analyze.title=Dependency Analysis +report.analyze.noDependencyProblems=No dependency problems found +report.analyze.UsedDeclaredDependencies=Used and Declared Dependencies +report.analyze.UsedUndeclaredDependencies=Used but Undeclared Dependencies +report.analyze.UnusedDeclaredDependencies=Unused but Declared Dependencies +report.analyze.CompileScopeTestOnlyDependencies=Compile Scoped Test Dependencies diff --git a/src/main/resources/analyze-report_de.properties b/src/main/resources/analyze-report_de.properties index 9f18ae7af..e284ece71 100644 --- a/src/main/resources/analyze-report_de.properties +++ b/src/main/resources/analyze-report_de.properties @@ -15,11 +15,10 @@ # specific language governing permissions and limitations # under the License. -analyze.report.name=Abhängigkeitsanalyse -analyze.report.description=Eine Analysebericht der Projektabhängigkeiten (verwendet und deklariert, verwendet aber nicht deklariert, unverwendet aber deklariert) -analyze.report.header=Abhängigkeitsanalyse -analyze.report.mainTitle=Abhängigkeitsanalyse -analyze.report.noDependency=Keine -analyze.report.UsedDeclaredDependencies=Verwendete und deklarierte Abhängigkeiten -analyze.report.UsedUndeclaredDependencies=Verwendete aber undeklarierte Abhängigkeiten -analyze.report.UnusedDeclaredDependencies=Unverwendete aber deklarierte Abhängigkeiten +report.analyze.name=Abhängigkeitsanalyse +report.analyze.description=Eine Analysebericht der Projektabhängigkeiten (verwendet und deklariert, verwendet aber nicht deklariert, unverwendet aber deklariert) +report.analyze.title=Abhängigkeitsanalyse +report.analyze.noDependencyProblems=Keine Abhängigkeitsprobleme gefunden +report.analyze.UsedDeclaredDependencies=Verwendete und deklarierte Abhängigkeiten +report.analyze.UsedUndeclaredDependencies=Verwendete aber undeklarierte Abhängigkeiten +report.analyze.UnusedDeclaredDependencies=Unverwendete aber deklarierte Abhängigkeiten diff --git a/src/main/resources/analyze-report_pt_BR.properties b/src/main/resources/analyze-report_pt_BR.properties index c84642347..324fd0e43 100644 --- a/src/main/resources/analyze-report_pt_BR.properties +++ b/src/main/resources/analyze-report_pt_BR.properties @@ -15,11 +15,9 @@ # specific language governing permissions and limitations # under the License. -analyze.report.name=An\u00e1lise de Depend\u00eancias -analyze.report.description=An\u00e1lise de Depend\u00eancias do projeto (usadas e declaradas, usadas e n\u00e3o declaradas, n\u00e3o usadas e declaradas) -analyze.report.header=Relat\u00f3rio de Depend\u00eancias -analyze.report.mainTitle=An\u00e1lise de Depend\u00eancias -analyze.report.noDependency=Nenhuma -analyze.report.UsedDeclaredDependencies=Depend\u00eancias usadas e declaradas -analyze.report.UsedUndeclaredDependencies=Depend\u00eancias usadas mas n\u00e3o declaradas -analyze.report.UnusedDeclaredDependencies=Depend\u00eancias n\u00e3o usadas mas declaradas +report.analyze.name=An\u00e1lise de Depend\u00eancias +report.analyze.description=An\u00e1lise de Depend\u00eancias do projeto (usadas e declaradas, usadas e n\u00e3o declaradas, n\u00e3o usadas e declaradas) +report.analyze.title=An\u00e1lise de Depend\u00eancias +report.analyze.UsedDeclaredDependencies=Depend\u00eancias usadas e declaradas +report.analyze.UsedUndeclaredDependencies=Depend\u00eancias usadas mas n\u00e3o declaradas +report.analyze.UnusedDeclaredDependencies=Depend\u00eancias n\u00e3o usadas mas declaradas diff --git a/src/main/resources/analyze-report_sv.properties b/src/main/resources/analyze-report_sv.properties index 81760118b..9f80758a0 100644 --- a/src/main/resources/analyze-report_sv.properties +++ b/src/main/resources/analyze-report_sv.properties @@ -15,11 +15,9 @@ # specific language governing permissions and limitations # under the License. -analyze.report.name=Beroendeanalys -analyze.report.description=Beroendeanalys av projektet (anv\u00e4nda deklarerade, anv\u00e4nda odeklarerade, oanv\u00e4nda deklarerade) -analyze.report.header=Beroenderapport -analyze.report.mainTitle=Beroendeanalys -analyze.report.noDependency=Inga -analyze.report.UsedDeclaredDependencies=Anv\u00e4nda och deklarerade beroenden -analyze.report.UsedUndeclaredDependencies=Anv\u00e4nda men odeklarerade beroenden -analyze.report.UnusedDeclaredDependencies=Oanv\u00e4nda men deklarerade beroenden +report.analyze.name=Beroendeanalys +report.analyze.description=Beroendeanalys av projektet (anv\u00e4nda deklarerade, anv\u00e4nda odeklarerade, oanv\u00e4nda deklarerade) +report.analyze.title=Beroendeanalys +report.analyze.UsedDeclaredDependencies=Anv\u00e4nda och deklarerade beroenden +report.analyze.UsedUndeclaredDependencies=Anv\u00e4nda men odeklarerade beroenden +report.analyze.UnusedDeclaredDependencies=Oanv\u00e4nda men deklarerade beroenden From b4474bb9d8c003348fddb18b0c95a52ae21d8536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 May 2023 23:25:14 +0200 Subject: [PATCH 035/283] [MDEP-851] Bump plexus-archiver from 4.6.3 to 4.7.1 (#315) Bumps [plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.6.3 to 4.7.1. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.6.3...plexus-archiver-4.7.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 35bed3be0..c78be445e 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-01-06T22:59:57Z 1.7.36 - 4.6.3 + 4.7.1 From 2992497b4fdce17c55a51ee8a47419e2925d962f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 18 May 2023 22:59:44 +0200 Subject: [PATCH 036/283] [MDEP-862] Get rid of plexus-container-default from dependencies --- pom.xml | 12 ++++++++++ .../analyze/AbstractAnalyzeMojo.java | 23 ++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index c78be445e..01a70570a 100644 --- a/pom.xml +++ b/pom.xml @@ -170,6 +170,12 @@ under the License. org.apache.maven.doxia doxia-sink-api 1.11.1 + + + org.codehaus.plexus + plexus-container-default + + org.apache.maven.reporting @@ -180,6 +186,12 @@ under the License. org.apache.maven.reporting maven-reporting-impl 3.2.0 + + + org.codehaus.plexus + plexus-container-default + + commons-io diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 9360e6074..92ef8ee8a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -35,16 +35,15 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; -import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; /** @@ -54,14 +53,15 @@ * @author Mark Hobson * @since 2.0-alpha-5 */ -public abstract class AbstractAnalyzeMojo extends AbstractMojo implements Contextualizable { +public abstract class AbstractAnalyzeMojo extends AbstractMojo { // fields ----------------------------------------------------------------- /** - * The plexus context to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo + * The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo * configuration. */ - private Context context; + @Component + private PlexusContainer plexusContainer; /** * The Maven project to analyze. @@ -300,20 +300,15 @@ public void execute() throws MojoExecutionException, MojoFailureException { * @throws MojoExecutionException in case of an error. */ protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException { + try { - final PlexusContainer container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); - return container.lookup(ProjectDependencyAnalyzer.class, analyzer); - } catch (Exception exception) { + return plexusContainer.lookup(ProjectDependencyAnalyzer.class, analyzer); + } catch (ComponentLookupException exception) { throw new MojoExecutionException( "Failed to instantiate ProjectDependencyAnalyser" + " / role-hint " + analyzer, exception); } } - @Override - public void contextualize(Context theContext) { - this.context = theContext; - } - /** * @return {@link #skip} */ From 159090be4f3897ae0dbe058ba36da110ddf501af Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 18 May 2023 23:06:49 +0200 Subject: [PATCH 037/283] [MDEP-866] Refresh download page --- src/site/site.xml | 6 +- src/site/xdoc/download.xml.vm | 117 ++++++++++------------------------ 2 files changed, 36 insertions(+), 87 deletions(-) diff --git a/src/site/site.xml b/src/site/site.xml index 8d192c97a..790d3d42b 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -19,8 +19,8 @@ specific language governing permissions and limitations under the License. --> - + @@ -28,7 +28,7 @@ under the License. - + diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 3f710359a..8f28f053a 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -23,102 +23,51 @@ under the License. Download ${project.name} Source +
-

${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build - ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.

- -

You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24 - hours to reach all mirrors.

- -

In order to guard against corrupted downloads/installations, it is highly recommended to - verify the signature - of the release bundles against the public KEYS used by the Apache Maven - developers.

+

${project.name} ${project.version} is distributed in source format.

-

${project.name} is distributed under the Apache License, version 2.0.

+

Use a source archive if you intend to build ${project.name} yourself.

-

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

- - - - -

- [if-any logo] - - logo - - [end] - The currently selected mirror is - [preferred]. - If you encounter a problem with this mirror, - please select another mirror. - If all mirrors are failing, there are - backup - mirrors - (at the end of the mirrors list) that should be available. -

+

Otherwise, simply use the ready-made binary artifacts from central repository.

-
- Other mirrors: - - -
+

${project.name} is distributed under the Apache License, version 2.0.

-

- You may also consult the - complete list of - mirrors. + + +

This is the current stable version of ${project.name}.

+ + + + + + + + + + + + + + + + + + +
LinkChecksumSignature
${project.name} ${project.version} (Source zip)${project.artifactId}-${project.version}-source-release.zip${project.artifactId}-${project.version}-source-release.zip.sha512${project.artifactId}-${project.version}-source-release.zip.asc
+ +

It is essential that you verify the integrity of the downloaded file + using the checksum (.sha512 file) + or using the signature (.asc file) against the public KEYS used by the Apache Maven developers.

- - - -

This is the current stable version of ${project.name}.

- - - - - - - - - - - - - - - - - - -
LinkChecksumSignature
${project.name} ${project.version} (Source zip)maven/plugins/${project.artifactId}-${project.version}-source-release.zipmaven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc
-
- -

Older non-recommended releases can be found on our archive site.

- +

It is strongly recommended to use the latest release version of ${project.name} to take advantage of the newest features and bug fixes.

+

Older non-recommended releases can be found on our archive site.

From 6ccca01bfbf634796d243227da3b0f09ef257240 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 19 May 2023 15:52:37 +0200 Subject: [PATCH 038/283] [MDEP-867] Upgrade plugins in ITs --- pom.xml | 1 + .../projects/build-classpath-output-file-and-property/pom.xml | 4 ++-- src/it/projects/mdep-439-analyze-java8/pom.xml | 4 ++-- src/it/projects/mdep-599-analyze-java9/pom.xml | 2 +- src/it/projects/mdep-663_analyze_unsupported_version/pom.xml | 1 - .../mdep-779-analyze-only-verbose-shows-class-names/pom.xml | 1 + src/it/projects/setup-custom-ear-lifecycle/pom.xml | 4 ++-- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 01a70570a..ddd6ff8cd 100644 --- a/pom.xml +++ b/pom.xml @@ -455,6 +455,7 @@ under the License. src/it/mrm/settings.xml ${repository.proxy.url} + 3.11.0 diff --git a/src/it/projects/build-classpath-output-file-and-property/pom.xml b/src/it/projects/build-classpath-output-file-and-property/pom.xml index 82dee75e7..0b44be25e 100644 --- a/src/it/projects/build-classpath-output-file-and-property/pom.xml +++ b/src/it/projects/build-classpath-output-file-and-property/pom.xml @@ -42,7 +42,7 @@ 1.0 - + @@ -62,7 +62,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.4.1 + 3.3.0 enforce-property diff --git a/src/it/projects/mdep-439-analyze-java8/pom.xml b/src/it/projects/mdep-439-analyze-java8/pom.xml index 27ce72494..f7e34ebf7 100644 --- a/src/it/projects/mdep-439-analyze-java8/pom.xml +++ b/src/it/projects/mdep-439-analyze-java8/pom.xml @@ -23,7 +23,7 @@ under the License. 4.0.0 - + org.sugis.maven dep-analyze-java8 dep-analyze-java8 @@ -56,7 +56,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 3.1 + @compilerPluginVersion@ 1.8 1.8 diff --git a/src/it/projects/mdep-599-analyze-java9/pom.xml b/src/it/projects/mdep-599-analyze-java9/pom.xml index be1f345d2..9a8b66574 100644 --- a/src/it/projects/mdep-599-analyze-java9/pom.xml +++ b/src/it/projects/mdep-599-analyze-java9/pom.xml @@ -37,7 +37,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + @compilerPluginVersion@ diff --git a/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml b/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml index bc6002aa9..11d31c278 100644 --- a/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml +++ b/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml @@ -28,7 +28,6 @@ UTF-8 - diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml index 749dd7064..c32e272d4 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml @@ -42,6 +42,7 @@ maven-compiler-plugin + @compilerPluginVersion@ 8 8 diff --git a/src/it/projects/setup-custom-ear-lifecycle/pom.xml b/src/it/projects/setup-custom-ear-lifecycle/pom.xml index 32b004d6d..b5a3448b4 100644 --- a/src/it/projects/setup-custom-ear-lifecycle/pom.xml +++ b/src/it/projects/setup-custom-ear-lifecycle/pom.xml @@ -25,14 +25,14 @@ under the License. maven-custom-ear 1.0 pom - + org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + @compilerPluginVersion@ From 8e257106e7c11c280d6fd05443419c999f05370c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 19 May 2023 15:54:15 +0200 Subject: [PATCH 039/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.6.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index ddd6ff8cd..58ce5ccbe 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.5.1-SNAPSHOT + 3.6.0 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + maven-dependency-plugin-3.6.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -92,7 +92,7 @@ under the License. 3.3.0 1.0.0.v20140518 8 - 2023-01-06T22:59:57Z + 2023-05-19T13:52:51Z 1.7.36 4.7.1 From 0b57492a09962ca8e46188456c6e6ddd28e96ba1 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 19 May 2023 15:54:25 +0200 Subject: [PATCH 040/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 58ce5ccbe..f49fed748 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.6.0 + 3.6.1-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.6.0 + maven-dependency-plugin-3.5.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -92,7 +92,7 @@ under the License. 3.3.0 1.0.0.v20140518 8 - 2023-05-19T13:52:51Z + 2023-05-19T13:54:25Z 1.7.36 4.7.1 From 73d222012f27b028ee0c2ecfbe23063b770168c0 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 20 May 2023 16:48:07 +0000 Subject: [PATCH 041/283] move commons-io to test scope (#323) --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index f49fed748..845cc7876 100644 --- a/pom.xml +++ b/pom.xml @@ -197,6 +197,7 @@ under the License. commons-io commons-io 2.11.0 + test From f18636315e4359cc9041918597adf4197f26f84a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 21 May 2023 11:48:50 +0000 Subject: [PATCH 042/283] [MDEP-869] update commons-collections to 4.4 (#324) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 845cc7876..4e735eb9f 100644 --- a/pom.xml +++ b/pom.xml @@ -258,7 +258,7 @@ under the License. org.apache.commons commons-collections4 - 4.2 + 4.4 org.apache.commons From 694655dd1a634144cf50c9e9963ba2c68b582acf Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 21 May 2023 11:49:05 +0000 Subject: [PATCH 043/283] MDEP-868 update maven-shared-utils to 3.4.2 (#322) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e735eb9f..4cfad0d79 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,7 @@ under the License. org.apache.maven.shared maven-shared-utils - 3.3.4 + 3.4.2 From 03bc34e843e61eb0def19397043461ca480293bd Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 22 Jun 2023 12:38:39 +0000 Subject: [PATCH 044/283] Tighten language (#327) --- src/site/apt/usage.apt.vm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index a67381c74..6a8db0cf7 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -333,7 +333,7 @@ mvn dependency:unpack Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. - <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. + <> You can mix includes and excludes of the same category (i.e. scope). Includes are processed before excludes. See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled. @@ -643,7 +643,7 @@ java -cp `cat resultFile` MyClass mvn dependency:build-classpath +---+ - or to write the classpath to cp.txt.: + or to write the classpath to cp.txt: +---+ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt @@ -682,13 +682,13 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt * <<>> - This goal is used to list all the repositories that this build depends upon. It will show repositories defined in your settings, - poms and declared in transitive dependency poms. + This goal lists all the repositories that this build depends upon. It shows repositories defined in your settings, + poms, and declared in transitive dependency poms. * <<>> - This goal is used to fetch an artifact and (optionally) its dependencies from remote repositories using its Maven coordinates. + This goal fetches an artifact and (optionally) its dependencies from remote repositories using its Maven coordinates. +-----+ mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=central::default::https://repo.maven.apache.org/maven2,myrepo::::http://myrepo.com/maven2 From 9e479d4bb277b1899bd024af5288b1a65cf243c0 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 22 Jun 2023 12:39:22 +0000 Subject: [PATCH 045/283] [MDEP-872] update commons-io to 2.13.0 (#326) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4cfad0d79..3c4d65e98 100644 --- a/pom.xml +++ b/pom.xml @@ -196,7 +196,7 @@ under the License. commons-io commons-io - 2.11.0 + 2.13.0 test From 3c877fb861f82b777f12ddf436ab50859f90d766 Mon Sep 17 00:00:00 2001 From: Rostislav Krasny <45571812+rosti-il@users.noreply.github.com> Date: Wed, 21 Jun 2023 03:23:43 +0300 Subject: [PATCH 046/283] MDEP-875 prevent possible NPE --- .../plugins/dependency/ListRepositoriesMojo.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index dd4f4a0b6..f038e88a2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -98,14 +98,21 @@ public boolean visitLeave(DependencyNode node) { } })); + if (repositories.isEmpty()) { + getLog().info("No remote repository is used by this build." + System.lineSeparator()); + return; + } + StringBuilder message = new StringBuilder(); Map> repoGroupByMirrors = repositories.stream() .collect(Collectors.groupingBy( repo -> repo.getMirroredRepositories().isEmpty())); - prepareRemoteRepositoriesList(message, repoGroupByMirrors.get(Boolean.TRUE)); - prepareRemoteMirrorRepositoriesList(message, repoGroupByMirrors.get(Boolean.FALSE)); + prepareRemoteRepositoriesList( + message, repoGroupByMirrors.getOrDefault(Boolean.TRUE, Collections.emptyList())); + prepareRemoteMirrorRepositoriesList( + message, repoGroupByMirrors.getOrDefault(Boolean.FALSE, Collections.emptyList())); getLog().info(message); From 4ed696e06d03486a17d9604d46697fc6b357b8ef Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 24 Jun 2023 14:35:14 +0200 Subject: [PATCH 047/283] Add Javadoc 'author' tag to prevent dangling contributor name --- .../maven/plugins/dependency/resolvers/GoOfflineMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index 2fc6d8f8f..1bc3e4d7a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -41,7 +41,7 @@ /** * Goal that resolves all project dependencies, including plugins and reports and their dependencies. * - * Brian Fox + * @author Brian Fox * @author Maarten Mulders * @since 2.0 */ From 0243c410d504303e25465f7c5d39790d1c272684 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 17:26:47 +0000 Subject: [PATCH 048/283] Bump org.codehaus.plexus:plexus-archiver from 4.7.1 to 4.8.0 Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.7.1 to 4.8.0. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.7.1...plexus-archiver-4.8.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c4d65e98..e60fa9c48 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-05-19T13:54:25Z 1.7.36 - 4.7.1 + 4.8.0 From c6973dae1d79192d5cfaae6e32b14663164342a2 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 20 Oct 2022 13:52:08 +0200 Subject: [PATCH 049/283] [MDEP-832] - Remove commons-collections-4 --- pom.xml | 5 ----- .../analyze/AnalyzeDuplicateMojo.java | 19 ++++++++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index e60fa9c48..16e0a1e64 100644 --- a/pom.xml +++ b/pom.xml @@ -260,11 +260,6 @@ under the License. commons-collections4 4.4 - - org.apache.commons - commons-lang3 - 3.12.0 - diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index 11a0d6a11..ab5bed3a3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -20,14 +20,14 @@ import java.io.IOException; import java.io.Reader; -import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; -import org.apache.commons.collections4.CollectionUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -131,14 +131,11 @@ private void createMessage( } private Set findDuplicateDependencies(List modelDependencies) { - List modelDependencies2 = new ArrayList<>(); - for (Dependency dep : modelDependencies) { - modelDependencies2.add(dep.getManagementKey()); - } - - // @formatter:off - return new LinkedHashSet<>( - CollectionUtils.disjunction(modelDependencies2, new LinkedHashSet<>(modelDependencies2))); - // @formatter:on + List modelDependencies2 = + modelDependencies.stream().map(Dependency::getManagementKey).collect(Collectors.toList()); + // remove one instance of each element from the list + modelDependencies2.removeIf(new HashSet<>(modelDependencies2)::remove); + // keep a single instance of each duplicate + return new LinkedHashSet<>(modelDependencies2); } } From 00620832a3c6ba3d17c7ec0382c7eecdaa510ebf Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Fri, 11 Aug 2023 21:39:32 +0200 Subject: [PATCH 050/283] [MDEP-883] - Upgrade maven-plugin parent to 40 --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 16e0a1e64..b91bd4774 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 39 + 40 @@ -433,7 +433,6 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - 3.5.1 clean From 34348ecee0a3588037287df2cad9269e10975c40 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 20 Aug 2023 12:23:09 +0000 Subject: [PATCH 051/283] [MNG-6847] Use diamond operator As discussed on - https://github.com/apache/maven-scm/pull/184 - https://issues.apache.org/jira/browse/MNG-6847 Review requested of @elharo Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.UseDiamondOperator?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../tree/BuildingDependencyNodeVisitor.java | 4 +- .../TestCopyDependenciesMojo.java | 30 +++++++-------- .../TestCopyDependenciesMojo2.java | 18 ++++----- .../TestUnpackDependenciesMojo.java | 38 +++++++++---------- .../ResolveDependenciesMojoTest.java | 2 +- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java index b2e3ef0e1..411a1fb5c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/BuildingDependencyNodeVisitor.java @@ -70,7 +70,7 @@ public BuildingDependencyNodeVisitor() { public BuildingDependencyNodeVisitor(DependencyNodeVisitor visitor) { this.visitor = visitor; - parentNodes = new Stack(); + parentNodes = new Stack<>(); } // DependencyNodeVisitor methods ------------------------------------------ @@ -90,7 +90,7 @@ public boolean visit(DependencyNode node) { node.getOptional(), node.getExclusions(), node.toNodeString()); - newNode.setChildren(new ArrayList()); + newNode.setChildren(new ArrayList<>()); if (parentNodes.empty()) { rootNode = newNode; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index e8b5da787..b79a876b6 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -156,7 +156,7 @@ public void testNoTransitive() throws Exception { public void testExcludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeTypes = "jar"; mojo.execute(); @@ -170,7 +170,7 @@ public void testExcludeType() throws Exception { public void testIncludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -198,7 +198,7 @@ public void testIncludeType() throws Exception { public void testExcludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeArtifactIds = "one"; mojo.execute(); @@ -212,7 +212,7 @@ public void testExcludeArtifactId() throws Exception { public void testIncludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; @@ -240,7 +240,7 @@ public void testIncludeArtifactId() throws Exception { public void testIncludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; // shouldn't get anything @@ -267,7 +267,7 @@ public void testIncludeGroupId() throws Exception { public void testExcludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeGroupIds = "one"; mojo.execute(); @@ -282,7 +282,7 @@ public void testExcludeGroupId() throws Exception { public void testExcludeMultipleGroupIds() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeGroupIds = "one,two"; mojo.execute(); @@ -298,7 +298,7 @@ public void testExcludeMultipleGroupIds() throws Exception { public void testExcludeClassifier() throws Exception { mojo.getProject().setArtifacts(stubFactory.getClassifiedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeClassifiers = "one"; mojo.execute(); @@ -312,7 +312,7 @@ public void testExcludeClassifier() throws Exception { public void testIncludeClassifier() throws Exception { mojo.getProject().setArtifacts(stubFactory.getClassifiedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeClassifiers = "one"; mojo.excludeClassifiers = "one"; @@ -340,7 +340,7 @@ public void testIncludeClassifier() throws Exception { public void testSubPerType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -555,7 +555,7 @@ public void testGetDependencies() throws MojoExecutionException { public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "provided"; // mojo.silent = false; @@ -573,7 +573,7 @@ public void testExcludeProvidedScope() throws Exception { public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "system"; // mojo.silent = false; @@ -591,7 +591,7 @@ public void testExcludeSystemScope() throws Exception { public void testExcludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -607,7 +607,7 @@ public void testExcludeCompileScope() throws Exception { public void testExcludeTestScope() throws IOException, MojoFailureException { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "test"; try { @@ -620,7 +620,7 @@ public void testExcludeTestScope() throws IOException, MojoFailureException { public void testExcludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 629cd811a..59b2b60fd 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -82,7 +82,7 @@ protected void setUp() throws Exception { public void testCopyDependenciesMojoIncludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "compile"; mojo.execute(); @@ -100,7 +100,7 @@ public void testCopyDependenciesMojoIncludeCompileScope() throws Exception { public void testCopyDependenciesMojoIncludeTestScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "test"; mojo.execute(); @@ -118,7 +118,7 @@ public void testCopyDependenciesMojoIncludeTestScope() throws Exception { public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "runtime"; mojo.execute(); @@ -136,7 +136,7 @@ public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception { public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "provided"; mojo.execute(); @@ -152,7 +152,7 @@ public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception { public void testCopyDependenciesMojoIncludesystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "system"; mojo.execute(); @@ -183,7 +183,7 @@ public void testSubPerArtifact() throws Exception { public void testSubPerArtifactAndType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; @@ -201,7 +201,7 @@ public void testSubPerArtifactAndType() throws Exception { public void testSubPerArtifactAndScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerScope = true; @@ -322,7 +322,7 @@ public void testSubPerArtifactRemoveVersion() throws Exception { public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; @@ -357,7 +357,7 @@ public void testSubPerArtifactRemoveType() throws Exception { public void testSubPerArtifactAndTypeRemoveType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripType = true; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 9f54efdda..c8e9f0dfe 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -139,7 +139,7 @@ public void testNoTransitive() throws Exception { public void testExcludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeTypes = "jar"; mojo.execute(); @@ -150,7 +150,7 @@ public void testExcludeType() throws Exception { public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "provided"; // mojo.silent = false; @@ -163,7 +163,7 @@ public void testExcludeProvidedScope() throws Exception { public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "system"; // mojo.silent = false; @@ -176,7 +176,7 @@ public void testExcludeSystemScope() throws Exception { public void testExcludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -188,7 +188,7 @@ public void testExcludeCompileScope() throws Exception { public void testExcludeTestScope() throws IOException, MojoFailureException { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "test"; try { @@ -201,7 +201,7 @@ public void testExcludeTestScope() throws IOException, MojoFailureException { public void testExcludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -213,7 +213,7 @@ public void testExcludeRuntimeScope() throws Exception { public void testIncludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -241,7 +241,7 @@ public void testIncludeType() throws Exception { public void testSubPerType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -261,7 +261,7 @@ public void testSubPerArtifact() throws Exception { public void testSubPerArtifactAndType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -283,7 +283,7 @@ public void testSubPerArtifactRemoveVersion() throws Exception { public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; @@ -296,7 +296,7 @@ public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { public void testIncludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); @@ -308,7 +308,7 @@ public void testIncludeCompileScope() throws Exception { public void testIncludeTestScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "test"; mojo.execute(); @@ -321,7 +321,7 @@ public void testIncludeTestScope() throws Exception { public void testIncludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); @@ -333,7 +333,7 @@ public void testIncludeRuntimeScope() throws Exception { public void testIncludeprovidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "provided"; mojo.execute(); @@ -344,7 +344,7 @@ public void testIncludeprovidedScope() throws Exception { public void testIncludesystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "system"; mojo.execute(); @@ -356,7 +356,7 @@ public void testIncludesystemScope() throws Exception { public void testIncludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; @@ -380,7 +380,7 @@ public void testIncludeArtifactId() throws Exception { public void testExcludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeArtifactIds = "one"; mojo.execute(); @@ -394,7 +394,7 @@ public void testExcludeArtifactId() throws Exception { public void testExcludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeGroupIds = "one"; mojo.execute(); @@ -405,7 +405,7 @@ public void testExcludeGroupId() throws Exception { public void testIncludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet()); + mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; // shouldn't get anything diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index b4de4fcb2..a9d3c6077 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -45,7 +45,7 @@ public void testDependencyStatusLogNullFiles() throws IOException { } public void testDependencyStatusEmptySet() { - doTestDependencyStatusLog(new HashSet()); + doTestDependencyStatusLog(new HashSet<>()); } public void testOptionalDependencyFormatting() throws IOException { From 4d18cfbae02624cb8572b47442e1492ba6e9894c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 20 Oct 2023 23:21:41 +0200 Subject: [PATCH 052/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.6.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b91bd4774..249a73ca9 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.6.1-SNAPSHOT + 3.6.1 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + maven-dependency-plugin-3.6.1 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -92,7 +92,7 @@ under the License. 3.3.0 1.0.0.v20140518 8 - 2023-05-19T13:54:25Z + 2023-10-20T21:20:17Z 1.7.36 4.8.0 From 4c898d78f31025c2faef7ab2dc16d126cf566afe Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 20 Oct 2023 23:21:50 +0200 Subject: [PATCH 053/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 249a73ca9..cdd07a765 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.6.1 + 3.6.2-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.6.1 + maven-dependency-plugin-3.5.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -92,7 +92,7 @@ under the License. 3.3.0 1.0.0.v20140518 8 - 2023-10-20T21:20:17Z + 2023-10-20T21:21:50Z 1.7.36 4.8.0 From fcdaf61c208e52a424c0ae3116e9f8729a760517 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:20:38 -0400 Subject: [PATCH 054/283] Bump org.jsoup:jsoup from 1.16.1 to 1.16.2 (#339) Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.16.1 to 1.16.2. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.16.1...jsoup-1.16.2) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cdd07a765..f0bc1a0e5 100644 --- a/pom.xml +++ b/pom.xml @@ -458,7 +458,7 @@ under the License. org.jsoup jsoup - 1.16.1 + 1.16.2 From 8a3ff132248e1e86e8923f82362f008d2db49558 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:21:06 -0400 Subject: [PATCH 055/283] Bump jettyVersion from 9.4.51.v20230217 to 9.4.53.v20231009 (#338) Bumps `jettyVersion` from 9.4.51.v20230217 to 9.4.53.v20231009. Updates `org.eclipse.jetty:jetty-server` from 9.4.51.v20230217 to 9.4.53.v20231009 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.51.v20230217...jetty-9.4.53.v20231009) Updates `org.eclipse.jetty:jetty-util` from 9.4.51.v20230217 to 9.4.53.v20231009 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.51.v20230217...jetty-9.4.53.v20231009) Updates `org.eclipse.jetty:jetty-security` from 9.4.51.v20230217 to 9.4.53.v20231009 - [Release notes](https://github.com/eclipse/jetty.project/releases) - [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.51.v20230217...jetty-9.4.53.v20231009) --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0bc1a0e5..0a87630f7 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ under the License. 3.2.5 - 9.4.51.v20230217 + 9.4.53.v20231009 3.3.0 1.0.0.v20140518 8 From 7ec0bda3cf529a65ba809d4b0604bab68ea5c293 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:23:16 -0400 Subject: [PATCH 056/283] Bump resolverVersion from 1.0.0.v20140518 to 1.0.2.v20150114 (#329) Bumps `resolverVersion` from 1.0.0.v20140518 to 1.0.2.v20150114. Updates `aether-api` from 1.0.0.v20140518 to 1.0.2.v20150114 Updates `aether-util` from 1.0.0.v20140518 to 1.0.2.v20150114 Updates `aether-connector-basic` from 1.0.0.v20140518 to 1.0.2.v20150114 Updates `aether-transport-file` from 1.0.0.v20140518 to 1.0.2.v20150114 Updates `aether-transport-http` from 1.0.0.v20140518 to 1.0.2.v20150114 --- updated-dependencies: - dependency-name: org.eclipse.aether:aether-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.eclipse.aether:aether-util dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.eclipse.aether:aether-connector-basic dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.aether:aether-transport-file dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.aether:aether-transport-http dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a87630f7..ac09ebc3e 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ under the License. 3.2.5 9.4.53.v20231009 3.3.0 - 1.0.0.v20140518 + 1.0.2.v20150114 8 2023-10-20T21:21:50Z 1.7.36 From f45b26fbf0a55c611a180ff90b5010cfeb8efd24 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 21 Oct 2023 18:19:46 +0000 Subject: [PATCH 057/283] commons-io to 2.14.0 (#340) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ac09ebc3e..5b09f8aba 100644 --- a/pom.xml +++ b/pom.xml @@ -196,7 +196,7 @@ under the License. commons-io commons-io - 2.13.0 + 2.14.0 test From 724887544955bfd491dc65ad56b524105f2a9f0b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 21 Oct 2023 18:20:12 +0000 Subject: [PATCH 058/283] Assorted grammar nits on the home page (#345) @michael-o --- src/site/apt/index.apt.vm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 4cae408d4..930258943 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -37,7 +37,7 @@ ${project.name} *{{{./analyze-mojo.html}dependency:analyze}} analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared. - *{{{./analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes your projects dependencies and lists mismatches + *{{{./analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes the project's dependencies and lists mismatches between resolved dependencies and those listed in your dependencyManagement section. *{{{./analyze-only-mojo.html}dependency:analyze-only}} is the same as analyze, but is meant to be bound in a pom. It @@ -74,11 +74,11 @@ ${project.name} *{{{./list-classes-mojo.html}dependency:list-classes}} displays the fully package-qualified names of all classes found in a specified artifact. - *{{{./list-repositories-mojo.html}dependency:list-repositories}} collect all project dependencies and then lists the repositories + *{{{./list-repositories-mojo.html}dependency:list-repositories}} collects all project dependencies and then lists the repositories used by the build and by the transitive dependencies. - *{{{./properties-mojo.html}dependency:properties}} set a property for each project dependency containing the - to the artifact on the file system. + *{{{./properties-mojo.html}dependency:properties}} sets a property for each project dependency containing the + the artifact on the file system. *{{{./purge-local-repository-mojo.html}dependency:purge-local-repository}} tells Maven to clear dependency artifact files out of the local repository, and optionally re-resolve them. @@ -103,14 +103,14 @@ ${project.name} * Usage General instructions on how to use the Dependency Plugin can be found on the {{{./usage.html}usage page}}. Some more - specific use cases are described in the examples given below. + specific use cases are described in the following examples. - In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel + If you have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel free to contact the {{{./mailing-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{./mailing-lists.html}mail archive}}. - If you feel like the plugin is missing a feature or has a defect, you can file a feature request or bug report in our + If you think the plugin is missing a feature or has a defect, you can file a feature request or bug report in the {{{./issue-management.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. From 9e92085803f5c08cd98d6dda09fe3065b912fef7 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 21 Oct 2023 18:20:42 +0000 Subject: [PATCH 059/283] [MDEP-889] declare javax.inject explicitly (#343) --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 5b09f8aba..e0bd17278 100644 --- a/pom.xml +++ b/pom.xml @@ -267,6 +267,11 @@ under the License. maven-plugin-annotations provided + + javax.inject + javax.inject + 1 + org.eclipse.aether From a56c4df2cc76324c39659cdf5d0ad4cbedfb7690 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 21 Oct 2023 18:21:43 +0000 Subject: [PATCH 060/283] [MDEP-888] Update used but undeclared commons-lang3 to 3.13.0 (#341) * declare used but undeclared dependency on commons-lang3 * 3.13.0 --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index e0bd17278..ce438d3fe 100644 --- a/pom.xml +++ b/pom.xml @@ -260,6 +260,11 @@ under the License. commons-collections4 4.4 + + org.apache.commons + commons-lang3 + 3.13.0 + From 710a30f3424da36735323a627f77b7a94d103e87 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 22 Oct 2023 13:15:45 +0000 Subject: [PATCH 061/283] [MDEP-771] Remove broken 404 link (#344) @khmarbaise --- src/site/apt/index.apt.vm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 930258943..1dae65445 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -140,8 +140,6 @@ ${project.name} * {{{./examples/filtering-the-dependency-tree.html}Filtering the Dependency Tree}} - * {{{./examples/resolving-conflicts-using-the-dependency-tree.html}Resolving Conflicts Using the Dependency Tree}} - * {{{./examples/purging-local-repository.html}Purging the local repository}} [] From 3576dcb727f6cbc157219ddad59987f0d826aff6 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 22 Oct 2023 13:33:53 +0000 Subject: [PATCH 062/283] [MDEP-869] remove unused collections dependency (#342) --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index ce438d3fe..bd8b839e3 100644 --- a/pom.xml +++ b/pom.xml @@ -255,11 +255,6 @@ under the License. 3.4.2 - - org.apache.commons - commons-collections4 - 4.4 - org.apache.commons commons-lang3 From 69fdf92903fc209d6f3c6e2b3186d8887c6a0964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 24 Oct 2023 00:39:48 +0200 Subject: [PATCH 063/283] remove executable flag --- src/test/resources/unit/properties-test/plugin-config.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/test/resources/unit/properties-test/plugin-config.xml diff --git a/src/test/resources/unit/properties-test/plugin-config.xml b/src/test/resources/unit/properties-test/plugin-config.xml old mode 100755 new mode 100644 From 416f7325f6713db2a2b439f1f44b35a507c5266d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:36:14 -0400 Subject: [PATCH 064/283] Bump org.codehaus.mojo:mrm-maven-plugin from 1.5.0 to 1.6.0 (#347) Bumps [org.codehaus.mojo:mrm-maven-plugin](https://github.com/mojohaus/mrm) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/mojohaus/mrm/releases) - [Commits](https://github.com/mojohaus/mrm/compare/1.5.0...1.6.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mrm-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bd8b839e3..3b555ecb5 100644 --- a/pom.xml +++ b/pom.xml @@ -470,7 +470,7 @@ under the License. org.codehaus.mojo mrm-maven-plugin - 1.5.0 + 1.6.0 repository.proxy.url From f64df8fd3f2f295312c9f10169585705c75bf03d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 5 Nov 2023 18:13:02 +0100 Subject: [PATCH 065/283] [MDEP-893] - Get rid of commons-lang3 --- pom.xml | 6 ---- .../maven/plugins/dependency/GetMojo.java | 7 ++-- .../analyze/AbstractAnalyzeMojo.java | 6 ++-- .../dependency/analyze/AnalyzeDepMgt.java | 7 ++-- .../AbstractFromConfigurationMojo.java | 17 +++++----- .../fromConfiguration/UnpackMojo.java | 2 +- .../fromDependencies/BuildClasspathMojo.java | 3 +- .../dependency/utils/DependencyUtil.java | 7 ++-- .../plugins/dependency/utils/StringUtils.java | 33 +++++++++++++++++++ .../utils/filters/DestFileFilter.java | 6 ++-- .../markers/UnpackFileMarkerHandler.java | 2 +- .../TestCopyDependenciesMojo2.java | 3 +- .../stubs/StubUnpackFileMarkerHandler.java | 2 +- .../dependency/utils/TestDependencyUtil.java | 3 +- 14 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java diff --git a/pom.xml b/pom.xml index 3b555ecb5..1dab651b0 100644 --- a/pom.xml +++ b/pom.xml @@ -255,12 +255,6 @@ under the License. 3.4.2 - - org.apache.commons - commons-lang3 - 3.13.0 - - org.apache.maven.plugin-tools diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 159b775b5..45c43125d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -24,7 +24,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -38,6 +37,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.plugins.dependency.utils.StringUtils; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; @@ -130,7 +130,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0"); } if (artifact != null) { - String[] tokens = StringUtils.split(artifact, ":"); + String[] tokens = artifact.split("\\s*:+\\s*"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, you must specify " + "groupId:artifactId:version[:packaging[:classifier]] " + artifact); @@ -157,7 +157,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (remoteRepositories != null) { // Use the same format as in the deploy plugin id::layout::url - String[] repos = StringUtils.split(remoteRepositories, ","); + String[] repos = remoteRepositories.split("\\s*,+\\s*"); for (String repo : repos) { repoList.add(parseRepository(repo, always)); } @@ -214,6 +214,7 @@ ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) } id = matcher.group(1).trim(); + if (!StringUtils.isEmpty(matcher.group(2))) { layout = getLayout(matcher.group(2).trim()); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 92ef8ee8a..12f0423b2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.plugin.AbstractMojo; @@ -37,6 +36,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; @@ -509,9 +509,9 @@ private void writeDependencyXML(Set artifacts) { writer.startElement("version"); writer.writeText(artifact.getBaseVersion()); String classifier = artifact.getClassifier(); - if (StringUtils.isNotBlank(classifier)) { + if (!StringUtils.isEmpty(classifier)) { writer.startElement("classifier"); - writer.writeText(artifact.getClassifier()); + writer.writeText(classifier); writer.endElement(); } writer.endElement(); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index ee77f6dde..113f5f00a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -26,7 +26,6 @@ import java.util.Set; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -143,7 +142,8 @@ private boolean checkDependencyManagement() throws MojoExecutionException { // log exclusion errors List exclusionErrors = getExclusionErrors(exclusions, allDependencyArtifacts); for (Artifact exclusion : exclusionErrors) { - getLog().info(StringUtils.stripEnd(getArtifactManagementKey(exclusion), ":") + String artifactManagementKey = getArtifactManagementKey(exclusion); + getLog().info(artifactManagementKey.substring(artifactManagementKey.lastIndexOf(":")) + " was excluded in DepMgt, but version " + exclusion.getVersion() + " has been found in the dependency tree."); foundError = true; @@ -249,7 +249,8 @@ public void logMismatch(Artifact dependencyArtifact, Dependency dependencyFromDe "Invalid params: Artifact: " + dependencyArtifact + " Dependency: " + dependencyFromDepMgt); } - getLog().info("\tDependency: " + StringUtils.stripEnd(dependencyFromDepMgt.getManagementKey(), ":")); + String managementKey = dependencyFromDepMgt.getManagementKey(); + getLog().info("\tDependency: " + managementKey.substring(managementKey.lastIndexOf(":"))); getLog().info("\t\tDepMgt : " + dependencyFromDepMgt.getVersion()); getLog().info("\t\tResolved: " + dependencyArtifact.getBaseVersion()); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 28d17611f..5cf6c91f4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Objects; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -34,6 +33,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; @@ -135,13 +135,12 @@ protected void verifyRequirements() throws MojoFailureException { protected List getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) throws MojoExecutionException { - boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(), - prependGroupId = processArtifactItemsRequest.isPrependGroupId(), - useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); - + boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(); + boolean prependGroupId = processArtifactItemsRequest.isPrependGroupId(); + boolean useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); boolean removeClassifier = processArtifactItemsRequest.isRemoveClassifier(); - if (artifactItems == null || artifactItems.size() < 1) { + if (artifactItems == null || artifactItems.isEmpty()) { throw new MojoExecutionException("There are no artifactItems configured."); } @@ -174,8 +173,8 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque return artifactItems; } - private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException, ArtifactFilterException { - return StringUtils.equalsIgnoreCase(item.getOverWrite(), "true") + private boolean checkIfProcessingNeeded(ArtifactItem item) throws ArtifactFilterException { + return Boolean.parseBoolean(item.getOverWrite()) || getMarkedArtifactFilter(item).isArtifactIncluded(item); } @@ -367,7 +366,7 @@ public void setArtifact(String artifact) throws MojoFailureException { if (artifact != null) { String packaging = "jar"; String classifier; - String[] tokens = StringUtils.split(artifact, ":"); + String[] tokens = artifact.split(":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, " + "you must specify groupId:artifactId:version[:packaging[:classifier]] " + artifact); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index f60199406..034d60aa5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -21,13 +21,13 @@ import java.io.File; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 388c47c4e..c8bfa4f67 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -36,7 +36,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; @@ -268,7 +267,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); File localBasedir = repositoryManager.getLocalRepositoryBasedir(projectBuildingRequest); - file = StringUtils.replace(file, localBasedir.getAbsolutePath(), localRepoProperty); + file = file.replace(localBasedir.getAbsolutePath(), localRepoProperty); } sb.append(file); } else { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index 0f58d1b2d..a9d99584d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -27,7 +27,6 @@ import java.io.Writer; import java.util.Objects; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.logging.Log; @@ -260,7 +259,11 @@ public static synchronized void log(String string, Log log) throws IOException { * @return the result items */ public static String[] tokenizer(String str) { - return StringUtils.split(cleanToBeTokenizedString(str), ","); + String s = cleanToBeTokenizedString(str); + if (s.isEmpty()) { + return new String[0]; + } + return cleanToBeTokenizedString(str).split(","); } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java b/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java new file mode 100644 index 000000000..e238a6692 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java @@ -0,0 +1,33 @@ +/* + * 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.dependency.utils; + +import static java.util.Objects.isNull; + +public final class StringUtils { + private StringUtils() {} + + public static boolean isEmpty(String s) { + return isNull(s) || s.isEmpty(); + } + + public static boolean isNotEmpty(String s) { + return !isEmpty(s); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 7852412ff..8c4dec7c3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -24,13 +24,14 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import static org.apache.maven.plugins.dependency.utils.StringUtils.isEmpty; + /** * @author Brian Fox */ @@ -284,7 +285,8 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept } File destFile; - if (StringUtils.isEmpty(item.getDestFileName())) { + + if (isEmpty(item.getDestFileName())) { String formattedFileName = DependencyUtil.getFormattedFileName( artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier); destFile = new File(destFolder, formattedFileName); diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 063404d21..42cbe1c74 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -20,8 +20,8 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; +import org.apache.maven.plugins.dependency.utils.StringUtils; /** * @author Damian Bradicich diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 59b2b60fd..c755a62a7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -27,7 +27,6 @@ import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -276,7 +275,7 @@ private Artifact createExpandedVersionArtifact( snapshot.setBuildNumber(1); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata(expandedSnapshot, snapshot); String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - expandedSnapshot.setResolvedVersion(StringUtils.replace(baseVersion, Artifact.SNAPSHOT_VERSION, newVersion)); + expandedSnapshot.setResolvedVersion(baseVersion.replace(Artifact.SNAPSHOT_VERSION, newVersion)); expandedSnapshot.addMetadata(metadata); return expandedSnapshot; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java index 411aa048e..9262470da 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java @@ -20,8 +20,8 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; +import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; public class StubUnpackFileMarkerHandler extends UnpackFileMarkerHandler { diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java index 3974101f9..b22ee84ed 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java @@ -24,7 +24,6 @@ import java.util.Random; import junit.framework.TestCase; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; @@ -324,7 +323,7 @@ public void testTokenizer() { String[] tokens = DependencyUtil.tokenizer(" alpha,bravo, charlie , delta kappa, theta"); String[] expected = new String[] {"alpha", "bravo", "charlie", "delta kappa", "theta"}; // easier to see in the JUnit reports - assertEquals(StringUtils.join(expected, ", "), StringUtils.join(tokens, ", ")); + assertEquals(String.join(", ", expected), String.join(", ", tokens)); assertEquals(expected.length, tokens.length); tokens = DependencyUtil.tokenizer(" \r\n a, \t \n \r b \t \n \r"); From f1b2915a45a34c7257c8ce232ca6da989bad6e70 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Fri, 11 Aug 2023 20:34:53 +0200 Subject: [PATCH 066/283] Code Improvements * using Files.newBufferedWriter(), Files.lines() * using reader.lines().forEach() * Removed inverse logic. * Using StandardCharsets.UTF_8 instead of literal texts. --- .../fromDependencies/BuildClasspathMojo.java | 26 +++++++------------ .../dependency/utils/DependencyUtil.java | 24 ++++++----------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index c8bfa4f67..57c0d9c4d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -18,15 +18,12 @@ */ package org.apache.maven.plugins.dependency.fromDependencies; -import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; @@ -35,6 +32,8 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; @@ -306,9 +305,8 @@ private void storeClasspathFile(String cpString, File out) throws MojoExecutionE // make sure the parent path exists. out.getParentFile().mkdirs(); - String encoding = Objects.toString(outputEncoding, "UTF-8"); - - try (Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), encoding))) { + String encoding = Objects.toString(outputEncoding, StandardCharsets.UTF_8.name()); + try (Writer w = Files.newBufferedWriter(out.toPath(), Charset.forName(encoding))) { w.write(cpString); getLog().info("Wrote classpath file '" + out + "'."); } catch (IOException ex) { @@ -332,15 +330,11 @@ protected String readClasspathFile() throws IOException { if (!outputFile.isFile()) { return null; } - StringBuilder sb = new StringBuilder(); - String encoding = Objects.toString(outputEncoding, "UTF-8"); - try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile), encoding))) { - for (String line = r.readLine(); line != null; line = r.readLine()) { - sb.append(line); - } + String encoding = Objects.toString(outputEncoding, StandardCharsets.UTF_8.name()); - return sb.toString(); + try (Stream lines = Files.lines(outputFile.toPath(), Charset.forName(encoding))) { + return lines.collect(Collectors.joining()); } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index a9d99584d..eaff55ca0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -20,11 +20,11 @@ import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.StringReader; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.Objects; import org.apache.maven.artifact.Artifact; @@ -105,15 +105,13 @@ public static String getFormattedFileName( destFileName.append(artifact.getGroupId()).append("."); } - String versionString; + String versionString = ""; if (!removeVersion) { if (useBaseVersion) { versionString = "-" + ArtifactUtils.toSnapshotVersion(artifact.getVersion()); } else { versionString = "-" + artifact.getVersion(); } - } else { - versionString = ""; } String classifierString = ""; @@ -226,9 +224,9 @@ public static synchronized void write(String string, File file, boolean append, */ public static synchronized void write(String string, File file, boolean append, String encoding) throws IOException { - file.getParentFile().mkdirs(); + Files.createDirectories(file.getParentFile().toPath()); - try (Writer writer = new OutputStreamWriter(new FileOutputStream(file, append), encoding)) { + try (Writer writer = Files.newBufferedWriter(file.toPath(), Charset.forName(encoding))) { writer.write(string); } } @@ -241,15 +239,9 @@ public static synchronized void write(String string, File file, boolean append, * @throws IOException if an I/O error occurs */ public static synchronized void log(String string, Log log) throws IOException { - BufferedReader reader = new BufferedReader(new StringReader(string)); - - String line; - - while ((line = reader.readLine()) != null) { - log.info(line); + try (BufferedReader reader = new BufferedReader(new StringReader(string))) { + reader.lines().forEach(log::info); } - - reader.close(); } /** @@ -276,7 +268,7 @@ public static String cleanToBeTokenizedString(String str) { String ret = ""; if (!(str == null || str.isEmpty())) { // remove initial and ending spaces, plus all spaces next to commas - ret = str.trim().replaceAll("[\\s]*,[\\s]*", ","); + ret = str.trim().replaceAll("\\s*,\\s*", ","); } return ret; From ad2af9594a3381b99d11a07e726ee607c01a16dc Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 5 Nov 2023 23:45:02 +0100 Subject: [PATCH 067/283] [MDEP-894] - Use @Component instead of @Parameter for session/project --- .../maven/plugins/dependency/AbstractDependencyMojo.java | 4 ++-- .../apache/maven/plugins/dependency/DisplayAncestorsMojo.java | 4 ++-- .../java/org/apache/maven/plugins/dependency/GetMojo.java | 2 +- .../org/apache/maven/plugins/dependency/ListClassesMojo.java | 2 +- .../apache/maven/plugins/dependency/ListRepositoriesMojo.java | 2 +- .../org/apache/maven/plugins/dependency/PropertiesMojo.java | 3 ++- .../maven/plugins/dependency/PurgeLocalRepositoryMojo.java | 4 ++-- .../maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java | 2 +- .../maven/plugins/dependency/analyze/AnalyzeDepMgt.java | 3 ++- .../plugins/dependency/analyze/AnalyzeDuplicateMojo.java | 3 ++- .../plugins/dependency/fromConfiguration/UnpackMojo.java | 2 +- .../dependency/fromDependencies/UnpackDependenciesMojo.java | 2 +- .../org/apache/maven/plugins/dependency/tree/TreeMojo.java | 4 ++-- 13 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 68cc286c4..c57bc99d3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -59,7 +59,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * POM */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; /** @@ -83,7 +83,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * The Maven session */ - @Parameter(defaultValue = "${session}", readonly = true, required = true) + @Component protected MavenSession session; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java index 4e1be1b30..06efbe74c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java @@ -25,9 +25,9 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; /** @@ -43,7 +43,7 @@ public class DisplayAncestorsMojo extends AbstractMojo { /** * POM */ - @Parameter(defaultValue = "${project}", readonly = true) + @Component private MavenProject project; @Override diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 45c43125d..d0b86033c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -59,7 +59,7 @@ public class GetMojo extends AbstractMojo { private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.*)::(.+)"); - @Parameter(defaultValue = "${session}", required = true, readonly = true) + @Component private MavenSession session; @Component diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index c34ad206d..31ba07a9d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -62,7 +62,7 @@ public class ListClassesMojo extends AbstractMojo { private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.*)::(.+)"); - @Parameter(defaultValue = "${session}", required = true, readonly = true) + @Component private MavenSession session; @Component diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index f038e88a2..1a5a28f34 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -54,7 +54,7 @@ public class ListRepositoriesMojo extends AbstractDependencyMojo { @Component - RepositorySystem repositorySystem; + private RepositorySystem repositorySystem; /** * Displays a list of the repositories used by this build. diff --git a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java index 06b692eff..4eed301de 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java @@ -23,6 +23,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -49,7 +50,7 @@ public class PropertiesMojo extends AbstractMojo { /** * The current Maven project */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index 69f69694a..460e3c760 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -88,10 +88,10 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo { /** * The current Maven project. */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; - @Parameter(defaultValue = "${session}", readonly = true, required = true) + @Component private MavenSession session; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 12f0423b2..54d8acd24 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -66,7 +66,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { /** * The Maven project to analyze. */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index 113f5f00a..079c95d9c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -33,6 +33,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +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.plugins.annotations.ResolutionScope; @@ -53,7 +54,7 @@ public class AnalyzeDepMgt extends AbstractMojo { /** * */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index ab5bed3a3..a4c965df2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +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.project.MavenProject; @@ -65,7 +66,7 @@ public class AnalyzeDuplicateMojo extends AbstractMojo { /** * The Maven project to analyze. */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 034d60aa5..60c4f2972 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -45,7 +45,7 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { @Component - UnpackUtil unpackUtil; + private UnpackUtil unpackUtil; /** * Directory to store flag files after unpack diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index ba36a233c..e1042b47c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -51,7 +51,7 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { @Component - UnpackUtil unpackUtil; + private UnpackUtil unpackUtil; /** * A comma separated list of file patterns to include when unpacking the artifact. i.e. diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 9e8b10f78..960f101b1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -80,10 +80,10 @@ public class TreeMojo extends AbstractMojo { /** * The Maven project. */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) + @Component private MavenProject project; - @Parameter(defaultValue = "${session}", readonly = true, required = true) + @Component private MavenSession session; @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") From 8b150c49a6221751c3bc992dbff67e06ce37bfa9 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Fri, 10 Nov 2023 02:58:09 +0100 Subject: [PATCH 068/283] [MDEP-896] - Removing unused code --- .../plugins/dependency/tree/TreeMojo.java | 30 ------------ .../tree/TestTreeMojo_ContainsVersion.java | 49 ------------------- 2 files changed, 79 deletions(-) delete mode 100644 src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 960f101b1..843011071 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -29,9 +29,6 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -442,31 +439,4 @@ private DependencyNodeFilter createDependencyNodeFilter() { // following is required because the version handling in maven code // doesn't work properly. I ripped it out of the enforcer rules. - - /** - * Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default - * containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" == - * "[2.0.4,)" - * - * @param allowedRange range of allowed versions. - * @param theVersion the version to be checked. - * @return true if the version is contained by the range. - * @deprecated This method is unused in this project and will be removed in the future. - */ - @Deprecated - public static boolean containsVersion(VersionRange allowedRange, ArtifactVersion theVersion) { - ArtifactVersion recommendedVersion = allowedRange.getRecommendedVersion(); - if (recommendedVersion == null) { - List restrictions = allowedRange.getRestrictions(); - for (Restriction restriction : restrictions) { - if (restriction.containsVersion(theVersion)) { - return true; - } - } - return false; - } else { - // only singular versions ever have a recommendedVersion - return recommendedVersion.compareTo(theVersion) <= 0; - } - } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java deleted file mode 100644 index 95badb0b3..000000000 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo_ContainsVersion.java +++ /dev/null @@ -1,49 +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.dependency.tree; - -import java.util.Collections; - -import junit.framework.TestCase; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; -import org.apache.maven.artifact.versioning.VersionRange; - -import static org.apache.maven.plugins.dependency.tree.TreeMojo.containsVersion; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Tests TreeMojo.containsVersion. - */ -public class TestTreeMojo_ContainsVersion extends TestCase { - private VersionRange range = mock(VersionRange.class); - - private ArtifactVersion version = mock(ArtifactVersion.class); - - public void testWhenRecommendedVersionIsNullAndNoRestrictions() { - when(range.getRecommendedVersion()).thenReturn(null); - when(range.getRestrictions()).thenReturn(Collections.emptyList()); - - @SuppressWarnings("deprecation") - boolean doesItContain = containsVersion(range, version); - - assertFalse(doesItContain); - } -} From da5070ff63ac5f731f6c79f51ce340ca2934a1ae Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Fri, 10 Nov 2023 03:11:27 +0100 Subject: [PATCH 069/283] Removed left over comment. --- .../java/org/apache/maven/plugins/dependency/tree/TreeMojo.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 843011071..080c0402c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -437,6 +437,4 @@ private DependencyNodeFilter createDependencyNodeFilter() { return filters.isEmpty() ? null : new AndDependencyNodeFilter(filters); } - // following is required because the version handling in maven code - // doesn't work properly. I ripped it out of the enforcer rules. } From 0bb4c5917222c4f4a6df53bbc70dd770507a3d4d Mon Sep 17 00:00:00 2001 From: Juan Manuel Leflet Estrada Date: Tue, 7 Nov 2023 18:26:48 +0100 Subject: [PATCH 070/283] Fix sources goal for multimodule projects Signed-off-by: Juan Manuel Leflet Estrada --- src/it/projects/sources/module-a/pom.xml | 48 +++++++++++++++++++ src/it/projects/sources/module-b/pom.xml | 48 +++++++++++++++++++ src/it/projects/sources/pom.xml | 18 ++++--- .../ResolveDependencySourcesMojo.java | 2 +- 4 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 src/it/projects/sources/module-a/pom.xml create mode 100644 src/it/projects/sources/module-b/pom.xml diff --git a/src/it/projects/sources/module-a/pom.xml b/src/it/projects/sources/module-a/pom.xml new file mode 100644 index 000000000..7c6fe3c1d --- /dev/null +++ b/src/it/projects/sources/module-a/pom.xml @@ -0,0 +1,48 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + tree-multimodule + 1.0-SNAPSHOT + + + MultimoduleTest Module A + + tree-multimodule-module-a + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff --git a/src/it/projects/sources/module-b/pom.xml b/src/it/projects/sources/module-b/pom.xml new file mode 100644 index 000000000..bffea42af --- /dev/null +++ b/src/it/projects/sources/module-b/pom.xml @@ -0,0 +1,48 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + tree-multimodule + 1.0-SNAPSHOT + + + MultimoduleTest Module B + + tree-multimodule-module-b + + + UTF-8 + + + + + org.apache.maven.its.dependency + tree-multimodule-module-a + ${project.version} + + + + diff --git a/src/it/projects/sources/pom.xml b/src/it/projects/sources/pom.xml index f04fc4d88..062e10d43 100644 --- a/src/it/projects/sources/pom.xml +++ b/src/it/projects/sources/pom.xml @@ -24,24 +24,22 @@ 4.0.0 org.apache.maven.its.dependency - test + tree-multimodule 1.0-SNAPSHOT + pom - Test + MultimoduleTest - Test dependency:sources + Test dependency:tree on multimodule project UTF-8 - - - org.apache.maven - maven-project - 2.0.8 - - + + module-a + module-b + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index 21e8cce3b..f4871de0b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -32,7 +32,7 @@ @Mojo( name = "sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, - requiresDependencyResolution = ResolutionScope.TEST, + requiresDependencyCollection = ResolutionScope.TEST, threadSafe = true) public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { From 381def888b66591dcfbfb1ab279c15b2e2761e20 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 10 Nov 2023 21:08:57 +0100 Subject: [PATCH 071/283] Fix formatting --- .../java/org/apache/maven/plugins/dependency/tree/TreeMojo.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 080c0402c..0b587a0d6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -436,5 +436,4 @@ private DependencyNodeFilter createDependencyNodeFilter() { return filters.isEmpty() ? null : new AndDependencyNodeFilter(filters); } - } From 3ee528d1f812b1179b2c52faa7651afa149e6ee0 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Mon, 13 Nov 2023 18:46:50 +0100 Subject: [PATCH 072/283] [MDEP-897] - Remove old style JavaDoc Plexus docs --- .../fromConfiguration/ArtifactItem.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java index f56ecf896..ff9e5b39f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java @@ -23,6 +23,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.codehaus.plexus.components.io.filemappers.FileMapper; @@ -37,53 +38,45 @@ public class ArtifactItem implements DependableCoordinate { /** * Group Id of Artifact * - * @parameter - * @required */ + @Parameter(required = true) private String groupId; /** * Name of Artifact - * - * @parameter - * @required */ + @Parameter(required = true) private String artifactId; /** * Version of Artifact - * - * @parameter */ + @Parameter private String version = null; /** * Type of Artifact (War,Jar,etc) * - * @parameter - * @required */ + @Parameter(required = true) private String type = "jar"; /** * Classifier for Artifact (tests,sources,etc) - * - * @parameter */ + @Parameter private String classifier; /** * Location to use for this Artifact. Overrides default location. - * - * @parameter */ + @Parameter private File outputDirectory; /** * Provides ability to change destination file name - * - * @parameter */ + @Parameter private String destFileName; /** @@ -93,9 +86,8 @@ public class ArtifactItem implements DependableCoordinate { /** * Encoding of artifact. Overrides default encoding. - * - * @parameter */ + @Parameter private String encoding; /** @@ -122,9 +114,8 @@ public class ArtifactItem implements DependableCoordinate { * {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting shall happen. * * @since 3.1.2 - * - * @parameter */ + @Parameter private FileMapper[] fileMappers; /** From b773e4cf1c6f39e0afc316c77f5871b8f3eed245 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Mon, 13 Nov 2023 19:53:25 +0100 Subject: [PATCH 073/283] [MDEP-899] - Upgrade maven-plugin parent to 41 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1dab651b0..dea87485e 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 40 + 41 From de7751b57c22864541218baba1d55152cb7ed5ec Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 14 Nov 2023 20:10:26 +0100 Subject: [PATCH 074/283] Simplify expression --- .../plugins/dependency/DisplayAncestorsMojo.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java index 06efbe74c..4a52c0150 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Locale; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -62,14 +61,8 @@ private ArrayList collectAncestors() { MavenProject currentAncestor = project.getParent(); while (currentAncestor != null) { - final String gav = String.format( - Locale.US, - "%s:%s:%s", - currentAncestor.getGroupId(), - currentAncestor.getArtifactId(), - currentAncestor.getVersion()); - - ancestors.add(gav); + ancestors.add(currentAncestor.getGroupId() + ":" + currentAncestor.getArtifactId() + ":" + + currentAncestor.getVersion()); currentAncestor = currentAncestor.getParent(); } From c340e9e08a49c7f95f5097727e9030dc19107fea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 14:30:18 +0000 Subject: [PATCH 075/283] Bump org.apache.maven.doxia:doxia-sink-api from 1.11.1 to 1.12.0 (#353) Bumps [org.apache.maven.doxia:doxia-sink-api](https://github.com/apache/maven-doxia) from 1.11.1 to 1.12.0. - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-1.11.1...doxia-1.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-sink-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dea87485e..2db2ac5f3 100644 --- a/pom.xml +++ b/pom.xml @@ -169,7 +169,7 @@ under the License. org.apache.maven.doxia doxia-sink-api - 1.11.1 + 1.12.0 org.codehaus.plexus From aeba7e2da3ad6b5b63d01f5231f665de95b30b64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 14:30:30 +0000 Subject: [PATCH 076/283] Bump commons-io:commons-io from 2.14.0 to 2.15.1 (#352) Bumps commons-io:commons-io from 2.14.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2db2ac5f3..40a48d41b 100644 --- a/pom.xml +++ b/pom.xml @@ -196,7 +196,7 @@ under the License. commons-io commons-io - 2.14.0 + 2.15.1 test From a5b64ea22396f9c2722d7405f084a5b94cefb464 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 14:30:44 +0000 Subject: [PATCH 077/283] Bump org.jsoup:jsoup from 1.16.2 to 1.17.1 (#350) Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.16.2 to 1.17.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.16.2...jsoup-1.17.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40a48d41b..8d6b769f4 100644 --- a/pom.xml +++ b/pom.xml @@ -457,7 +457,7 @@ under the License. org.jsoup jsoup - 1.16.2 + 1.17.1 From 462c1fc4c08df98bea79c5792329cb6dc8d5558a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 14:31:29 +0000 Subject: [PATCH 078/283] Bump org.codehaus.plexus:plexus-archiver from 4.8.0 to 4.9.0 (#348) Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.8.0 to 4.9.0. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.8.0...plexus-archiver-4.9.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d6b769f4..31cdd9403 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-10-20T21:21:50Z 1.7.36 - 4.8.0 + 4.9.0 From 704970bd133ed1c49fd72aa6c44e9b80fc18845c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:23:31 +0000 Subject: [PATCH 079/283] Bump org.apache.commons:commons-text from 1.10.0 to 1.11.0 (#357) Bumps org.apache.commons:commons-text from 1.10.0 to 1.11.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 31cdd9403..c73b619db 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ under the License. org.apache.commons commons-text - 1.10.0 + 1.11.0 From bc33485a2085af639b84f8da2d0494db67b39672 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 14:30:47 +0000 Subject: [PATCH 080/283] Bump ch.qos.logback:logback-classic Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.2.3 to 1.2.13. - [Commits](https://github.com/qos-ch/logback/compare/v_1.2.3...v_1.2.13) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .../mdep-204-go-offline-resolve-intermodule/module-2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-2/pom.xml b/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-2/pom.xml index 50f7922d7..db9e97b12 100644 --- a/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-2/pom.xml +++ b/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-2/pom.xml @@ -42,7 +42,7 @@ ch.qos.logback logback-classic - 1.2.3 + 1.2.13 From 2cf89f44e543f3633a9b7190d468f3a9fd24a439 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 07:52:24 -0500 Subject: [PATCH 081/283] Bump org.jsoup:jsoup from 1.17.1 to 1.17.2 (#361) Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.17.1 to 1.17.2. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.17.1...jsoup-1.17.2) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c73b619db..fe8c0f3da 100644 --- a/pom.xml +++ b/pom.xml @@ -457,7 +457,7 @@ under the License. org.jsoup jsoup - 1.17.1 + 1.17.2 From f0929217583508751f1705c51420d509dd4a4ee5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 07:52:41 -0500 Subject: [PATCH 082/283] Bump org.codehaus.plexus:plexus-io from 3.4.1 to 3.4.2 (#359) Bumps [org.codehaus.plexus:plexus-io](https://github.com/codehaus-plexus/plexus-io) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/codehaus-plexus/plexus-io/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-io/compare/plexus-io-3.4.1...plexus-io-3.4.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fe8c0f3da..f2b1ffc23 100644 --- a/pom.xml +++ b/pom.xml @@ -214,7 +214,7 @@ under the License. org.codehaus.plexus plexus-io - 3.4.1 + 3.4.2 org.codehaus.plexus From 0c1baf7cbe981176a6940ffc335ccaef9ba3b291 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 08:28:22 -0500 Subject: [PATCH 083/283] Bump org.codehaus.plexus:plexus-archiver from 4.9.0 to 4.9.1 (#358) Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.9.0 to 4.9.1. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.9.0...plexus-archiver-4.9.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2b1ffc23..dfb8eb913 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-10-20T21:21:50Z 1.7.36 - 4.9.0 + 4.9.1 From 5389514fe237746eef09cdcf9d47ac10e3ae0694 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:24:03 +0000 Subject: [PATCH 084/283] Bump apache/maven-gh-actions-shared from 3 to 4 Bumps [apache/maven-gh-actions-shared](https://github.com/apache/maven-gh-actions-shared) from 3 to 4. - [Commits](https://github.com/apache/maven-gh-actions-shared/compare/v3...v4) --- updated-dependencies: - dependency-name: apache/maven-gh-actions-shared dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven-verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 970433585..07af46ecb 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -24,6 +24,6 @@ on: jobs: build: name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 with: jdk-matrix: '[ "8", "11", "17", "20" ]' From 1948d2764428e79c7be64619135295d3a86b323c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:50:39 +0000 Subject: [PATCH 085/283] Bump org.codehaus.plexus:plexus-archiver from 4.9.1 to 4.9.2 Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.9.1 to 4.9.2. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.9.1...plexus-archiver-4.9.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dfb8eb913..c91cc0a5a 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 8 2023-10-20T21:21:50Z 1.7.36 - 4.9.1 + 4.9.2 From 4a4999ff02489acdfc5383a0b62df210ef08486e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 21 Mar 2024 23:28:02 +0100 Subject: [PATCH 086/283] [MDEP-912] Use version for plexus-utils/plexus-xml from parent --- pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c91cc0a5a..9b37307ab 100644 --- a/pom.xml +++ b/pom.xml @@ -209,7 +209,10 @@ under the License. org.codehaus.plexus plexus-utils - 3.5.1 + + + org.codehaus.plexus + plexus-xml org.codehaus.plexus From 572cebbcb29a22a43858cce5edfa57787a1bb320 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 21 Mar 2024 23:35:12 +0100 Subject: [PATCH 087/283] Use default configuration for GitHub Actions --- .github/workflows/maven-verify.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 07af46ecb..932827cf9 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,5 +25,3 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 - with: - jdk-matrix: '[ "8", "11", "17", "20" ]' From c9e488ba11516aa5b4be22fedd5b109ab11fa32c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 22 Mar 2024 20:00:55 +0100 Subject: [PATCH 088/283] [MDEP-894] Use `@Component` only - fix tests (#360) * Use @Component only * Fix one test * Fix all Unit Tests * Add todo to remove with next parent --------- Co-authored-by: Slawomir Jaranowski --- pom.xml | 22 +++++++---------- .../plugins/dependency/TestCollectMojo.java | 7 ++++++ .../maven/plugins/dependency/TestGetMojo.java | 13 ++++++---- .../dependency/TestListClassesMojo.java | 13 ++++++---- .../dependency/TestPropertiesMojo.java | 8 +++++++ .../maven/plugins/dependency/TestSkip.java | 14 +++++++++++ .../analyze/TestAnalyzeDuplicateMojo.java | 16 +++++++++++++ .../fromConfiguration/TestCopyMojo.java | 9 ++++--- .../TestIncludeExcludeUnpackMojo.java | 11 ++++++--- .../fromConfiguration/TestUnpackMojo.java | 10 +++++--- .../TestBuildClasspathMojo.java | 11 ++++++--- .../TestCopyDependenciesMojo.java | 11 +++++---- .../TestCopyDependenciesMojo2.java | 10 ++++---- ...tIncludeExcludeUnpackDependenciesMojo.java | 9 ++++++- .../TestUnpackDependenciesMojo.java | 11 +++++---- .../TestUnpackDependenciesMojo2.java | 9 ++++++- .../dependency/resolvers/TestResolveMojo.java | 8 +++++++ .../plugins/dependency/tree/TestTreeMojo.java | 24 +++++++++++++------ .../build-classpath-test/plugin-config.xml | 1 - .../unit/collect-test/plugin-config.xml | 1 - .../copy-dependencies-test/plugin-config.xml | 1 - .../unit/copy-test/plugin-config.xml | 1 - .../duplicate-dependencies/plugin-config.xml | 1 - .../duplicate-dependencies/plugin-config2.xml | 1 - .../unit/properties-test/plugin-config.xml | 1 - .../unit/resolve-test/plugin-config.xml | 1 - .../plugin-analyze-report-config.xml | 1 - .../unit/skip-test/plugin-config.xml | 1 - .../plugin-purge-local-repository-config.xml | 4 ---- .../unit/tree-test/plugin-config.xml | 1 - .../plugin-config.xml | 1 - .../unit/unpack-dependencies-test/test.txt | 1 - .../unit/unpack-test/plugin-config.xml | 1 - 33 files changed, 162 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 9b37307ab..24c93bfc0 100644 --- a/pom.xml +++ b/pom.xml @@ -95,22 +95,12 @@ under the License. 2023-10-20T21:21:50Z 1.7.36 4.9.2 + + 3.11.0 - - - - org.eclipse.sisu - org.eclipse.sisu.inject - 0.3.0.M1 - - - org.eclipse.sisu - org.eclipse.sisu.plexus - 0.3.0.M1 - org.apache.commons @@ -321,6 +311,12 @@ under the License. maven-plugin-testing-harness ${pluginTestingVersion} test + + + org.codehaus.plexus + plexus-container-default + + org.mockito @@ -414,7 +410,7 @@ under the License. maven-surefire-plugin - -Xmx384m + -Xmx512m ${maven.home} diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 30f84893b..070cbb69c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -22,8 +22,10 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; @@ -32,6 +34,11 @@ public class TestCollectMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java index 4dfcc284c..fd820791d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java @@ -30,7 +30,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.eclipse.jetty.security.ConstraintMapping; @@ -49,6 +50,11 @@ public class TestGetMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml"); mojo = (GetMojo) lookupMojo("get", testPom); @@ -56,14 +62,13 @@ protected void setUp() throws Exception { assertNotNull(mojo); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession mavenSession = newMavenSession(new MavenProjectStub()); - Settings settings = mavenSession.getSettings(); + Settings settings = session.getSettings(); Server server = new Server(); server.setId("myserver"); server.setUsername("foo"); server.setPassword("bar"); settings.addServer(server); - legacySupport.setSession(mavenSession); + legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index cd73bf741..92cf2d68a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -27,7 +27,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.junit.Assert; @@ -39,6 +40,13 @@ public class TestListClassesMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("markers", false); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml"); assertTrue(testPom.exists()); @@ -47,7 +55,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession session = newMavenSession(new MavenProjectStub()); Settings settings = session.getSettings(); Server server = new Server(); server.setId("myserver"); @@ -57,8 +64,6 @@ protected void setUp() throws Exception { legacySupport.setSession(session); installLocalRepository(legacySupport); - - setVariableValueToObject(mojo, "session", legacySupport.getSession()); } public void testListClassesNotTransitive() throws Exception { diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java index 3b0a6f2c3..ede675d2d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java @@ -22,12 +22,20 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; public class TestPropertiesMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", true); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java index 1b1923089..b52a9e812 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java @@ -20,8 +20,11 @@ import java.io.File; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.mockito.ArgumentCaptor; import static org.mockito.Mockito.atLeastOnce; @@ -29,6 +32,17 @@ import static org.mockito.Mockito.verify; public class TestSkip extends AbstractDependencyMojoTestCase { + + @Override + protected void setUp() throws Exception { + super.setUp(); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + } + public void testSkipAnalyze() throws Exception { doTest("analyze"); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java index 23796923b..c74d24ecf 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java @@ -22,8 +22,12 @@ import java.io.PrintWriter; import java.io.StringWriter; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependencies2ProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependenciesProjectStub; +import org.apache.maven.project.MavenProject; /** * @author Vincent Siveton @@ -31,6 +35,12 @@ */ public class TestAnalyzeDuplicateMojo extends AbstractDependencyMojoTestCase { public void testDuplicate() throws Exception { + MavenProject project = new DuplicateDependenciesProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config.xml"); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo("analyze-duplicate", testPom); assertNotNull(mojo); @@ -44,6 +54,12 @@ public void testDuplicate() throws Exception { } public void testDuplicate2() throws Exception { + MavenProject project = new DuplicateDependencies2ProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config2.xml"); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo("analyze-duplicate", testPom); assertNotNull(mojo); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index cdd132f4d..4390f9bf7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -39,6 +40,11 @@ public class TestCopyMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("copy", false, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/copy-test/plugin-config.xml"); mojo = (CopyMojo) lookupMojo("copy", testPom); @@ -48,9 +54,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 31de69673..5778f0e29 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -28,7 +28,9 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; +import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase { private final String PACKED_FILE = "test.zip"; @@ -45,6 +47,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); @@ -63,9 +71,6 @@ protected void setUp() throws Exception { mojo.setMarkersDirectory(new File(this.testDir, "markers")); mojo.setArtifactItems(list); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 2adc2860f..6671c515a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; @@ -45,6 +46,12 @@ public class TestUnpackMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("unpack", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); @@ -62,9 +69,6 @@ protected void setUp() throws Exception { stubFactory.setSrcFile(new File( getBasedir() + File.separatorChar + "target/test-classes/unit/unpack-dependencies-test/test.txt")); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index 52beca51d..3c6f3eb08 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -25,6 +25,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -36,6 +37,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("build-classpath", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/build-classpath-test/plugin-config.xml"); mojo = (BuildClasspathMojo) lookupMojo("build-classpath", testPom); @@ -101,11 +108,9 @@ public void testEnvironment() throws Exception { } public void testPath() throws Exception { - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); - legacySupport.setSession(session); + legacySupport.setSession(lookup(MavenSession.class)); installLocalRepository(legacySupport); Artifact artifact = stubFactory.getReleaseArtifact(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index b79a876b6..f83743a05 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; @@ -44,6 +45,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("copy-dependencies", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -51,10 +58,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); - - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index c755a62a7..231c620a5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -43,6 +43,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -53,6 +54,11 @@ public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("copy-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); @@ -61,7 +67,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); @@ -72,9 +77,6 @@ protected void setUp() throws Exception { mojo.markersDirectory = new File(this.testDir, "markers"); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); - legacySupport.setSession(session); installLocalRepository(legacySupport); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 60faec3ee..8195ae16c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -22,7 +22,9 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { @@ -40,6 +42,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -53,7 +61,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index c8e9f0dfe..44c7cbeb0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; @@ -51,6 +52,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -64,10 +71,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); - - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 515a87c24..70941f9c8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -24,10 +24,12 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; @@ -44,6 +46,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -57,7 +65,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 8d74d2345..9c1d6a56f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -22,8 +22,10 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; @@ -32,6 +34,12 @@ public class TestResolveMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index aef1c69db..79e734825 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -26,6 +26,9 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.dependency.graph.DependencyNode; @@ -46,16 +49,23 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("tree", false); - } - // tests ------------------------------------------------------------------ + MavenProject project = new MavenProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); - public void testVoid() { - // TODO: tests disabled during MDEP-339 work, to be reactivated + LegacySupport legacySupport = lookup(LegacySupport.class); + legacySupport.setSession(session); + installLocalRepository(legacySupport); } + // tests ------------------------------------------------------------------ + /** * Tests the proper discovery and configuration of the mojo. + * // TODO: tests disabled during MDEP-339 work, to be reactivated * * @throws Exception in case of an error. */ @@ -89,7 +99,7 @@ public void _testTreeTestEnvironment() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeDotSerializing() throws Exception { + public void testTreeDotSerializing() throws Exception { List contents = runTreeMojo("tree1.dot", "dot"); assertTrue(findString(contents, "digraph \"testGroupId:project:jar:1.0:compile\" {")); assertTrue(findString( @@ -104,7 +114,7 @@ public void _testTreeDotSerializing() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeGraphMLSerializing() throws Exception { + public void testTreeGraphMLSerializing() throws Exception { List contents = runTreeMojo("tree1.graphml", "graphml"); assertTrue(findString(contents, "")); @@ -120,7 +130,7 @@ public void _testTreeGraphMLSerializing() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeTGFSerializing() throws Exception { + public void testTreeTGFSerializing() throws Exception { List contents = runTreeMojo("tree1.tgf", "tgf"); assertTrue(findString(contents, "testGroupId:project:jar:1.0:compile")); assertTrue(findString(contents, "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile")); diff --git a/src/test/resources/unit/build-classpath-test/plugin-config.xml b/src/test/resources/unit/build-classpath-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/build-classpath-test/plugin-config.xml +++ b/src/test/resources/unit/build-classpath-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/collect-test/plugin-config.xml b/src/test/resources/unit/collect-test/plugin-config.xml index 664fb38e9..3d1210a58 100644 --- a/src/test/resources/unit/collect-test/plugin-config.xml +++ b/src/test/resources/unit/collect-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/copy-dependencies-test/plugin-config.xml b/src/test/resources/unit/copy-dependencies-test/plugin-config.xml index 726aa2109..d2eb2b561 100644 --- a/src/test/resources/unit/copy-dependencies-test/plugin-config.xml +++ b/src/test/resources/unit/copy-dependencies-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/copy-test/plugin-config.xml b/src/test/resources/unit/copy-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/copy-test/plugin-config.xml +++ b/src/test/resources/unit/copy-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/duplicate-dependencies/plugin-config.xml b/src/test/resources/unit/duplicate-dependencies/plugin-config.xml index acbbe93ca..0cd446369 100644 --- a/src/test/resources/unit/duplicate-dependencies/plugin-config.xml +++ b/src/test/resources/unit/duplicate-dependencies/plugin-config.xml @@ -55,7 +55,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml b/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml index 282080592..908226dbd 100644 --- a/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml +++ b/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml @@ -67,7 +67,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/properties-test/plugin-config.xml b/src/test/resources/unit/properties-test/plugin-config.xml index 60ef26f5d..e7edfc507 100644 --- a/src/test/resources/unit/properties-test/plugin-config.xml +++ b/src/test/resources/unit/properties-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/resolve-test/plugin-config.xml b/src/test/resources/unit/resolve-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/resolve-test/plugin-config.xml +++ b/src/test/resources/unit/resolve-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml b/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml index 33d7c2f8d..ac324dd00 100644 --- a/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml +++ b/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml @@ -36,7 +36,6 @@ maven-dependency-plugin - true target/unit-tests/skip-test diff --git a/src/test/resources/unit/skip-test/plugin-config.xml b/src/test/resources/unit/skip-test/plugin-config.xml index 3c6076504..0006e2729 100644 --- a/src/test/resources/unit/skip-test/plugin-config.xml +++ b/src/test/resources/unit/skip-test/plugin-config.xml @@ -36,7 +36,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml b/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml index 707b9dfa0..0006e2729 100644 --- a/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml +++ b/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml @@ -36,10 +36,6 @@ maven-dependency-plugin - - - - true diff --git a/src/test/resources/unit/tree-test/plugin-config.xml b/src/test/resources/unit/tree-test/plugin-config.xml index 5d61ca75a..511d1147c 100644 --- a/src/test/resources/unit/tree-test/plugin-config.xml +++ b/src/test/resources/unit/tree-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml index d44f38a36..30d2867c3 100644 --- a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml +++ b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/unpack-dependencies-test/test.txt b/src/test/resources/unit/unpack-dependencies-test/test.txt index 4ee425451..d2eb2b561 100644 --- a/src/test/resources/unit/unpack-dependencies-test/test.txt +++ b/src/test/resources/unit/unpack-dependencies-test/test.txt @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/unpack-test/plugin-config.xml b/src/test/resources/unit/unpack-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/unpack-test/plugin-config.xml +++ b/src/test/resources/unit/unpack-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - From 421daceaa1ba0e57a88af52e00638621ad845913 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 20:31:00 +0200 Subject: [PATCH 089/283] [MDEP-915] Bump commons-io:commons-io from 2.15.1 to 2.16.0 (#369) --- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 24c93bfc0..e61ec11d9 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ under the License. commons-io commons-io - 2.15.1 + 2.16.0 test From 08fca804b91abe32b5aa63aee1c4748d5f4de9c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 22:10:49 +0000 Subject: [PATCH 090/283] Bump jettyVersion from 9.4.53.v20231009 to 9.4.54.v20240208 Bumps `jettyVersion` from 9.4.53.v20231009 to 9.4.54.v20240208. Updates `org.eclipse.jetty:jetty-server` from 9.4.53.v20231009 to 9.4.54.v20240208 Updates `org.eclipse.jetty:jetty-util` from 9.4.53.v20231009 to 9.4.54.v20240208 Updates `org.eclipse.jetty:jetty-security` from 9.4.53.v20231009 to 9.4.54.v20240208 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e61ec11d9..caa5e18f5 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ under the License. 3.2.5 - 9.4.53.v20231009 + 9.4.54.v20240208 3.3.0 1.0.2.v20150114 8 From 9926a5df8a290211fc5b0e154f4f14d6057f4c17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:17:58 +0200 Subject: [PATCH 091/283] [MDEP-915] Bump commons-io:commons-io from 2.16.0 to 2.16.1 (#370) Bumps commons-io:commons-io from 2.16.0 to 2.16.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index caa5e18f5..12862cdec 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ under the License. commons-io commons-io - 2.16.0 + 2.16.1 test From 4907f4a52aa6b84c5bbf29538eaf89c197bda008 Mon Sep 17 00:00:00 2001 From: Vidar Breivik Date: Sun, 14 Apr 2024 19:05:16 +0200 Subject: [PATCH 092/283] [MDEP-317] - add mojo to analyze invalid exclusions (#362) --- pom.xml | 9 +- .../invoker.properties | 19 + .../module1/pom.xml | 40 ++ .../module1/src/main/java/foo/Main.java | 32 ++ .../module2/pom.xml | 36 ++ .../module2/src/main/java/foo/Main.java | 32 ++ .../pom.xml | 61 +++ .../verify.groovy | 30 ++ .../invoker.properties | 18 + .../projects/analyze-invalid-exclude/pom.xml | 95 +++++ .../src/main/java/Main.java | 31 ++ .../analyze-invalid-exclude/verify.groovy | 31 ++ .../exclusion/AnalyzeExclusionsMojo.java | 163 +++++++ .../dependency/exclusion/Coordinates.java | 101 +++++ .../exclusion/ExclusionChecker.java | 45 ++ src/site/apt/index.apt.vm | 2 + src/site/apt/usage.apt.vm | 21 + .../exclusion/AnalyzeExclusionsMojoTest.java | 403 ++++++++++++++++++ .../exclusion/ExclusionCheckerTest.java | 101 +++++ .../unit/analyze-exclusions/plugin-config.xml | 43 ++ 20 files changed, 1312 insertions(+), 1 deletion(-) create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/invoker.properties create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/module1/src/main/java/foo/Main.java create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/module2/src/main/java/foo/Main.java create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml create mode 100644 src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy create mode 100644 src/it/projects/analyze-invalid-exclude/invoker.properties create mode 100644 src/it/projects/analyze-invalid-exclude/pom.xml create mode 100644 src/it/projects/analyze-invalid-exclude/src/main/java/Main.java create mode 100644 src/it/projects/analyze-invalid-exclude/verify.groovy create mode 100644 src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java create mode 100644 src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java create mode 100644 src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java create mode 100644 src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java create mode 100644 src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java create mode 100644 src/test/resources/unit/analyze-exclusions/plugin-config.xml diff --git a/pom.xml b/pom.xml index 12862cdec..dc1716791 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.6.2-SNAPSHOT + 3.7.0-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -325,6 +325,13 @@ under the License. test + + org.assertj + assertj-core + 3.24.2 + test + + org.apache.maven diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/invoker.properties b/src/it/projects/analyze-invalid-exclude-multumodule-project/invoker.properties new file mode 100644 index 000000000..8b1dfce16 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/invoker.properties @@ -0,0 +1,19 @@ +# 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. + +# 'install' is for this IT to work with Maven 2.2.1. Not required for Maven 3.0+. +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze-exclusions diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml new file mode 100644 index 000000000..2b329db31 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml @@ -0,0 +1,40 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + test-parent + 1.0-SNAPSHOT + + + test-module1 + + + + org.apache.maven + maven-core + + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/src/main/java/foo/Main.java b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/src/main/java/foo/Main.java new file mode 100644 index 000000000..7ca91f797 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/src/main/java/foo/Main.java @@ -0,0 +1,32 @@ +/* + * 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 foo; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.model.Model; + +public class Main +{ + public static final String SCOPE_COMPILE = Artifact.SCOPE_COMPILE; + + public Model model = null; + + public Metadata metadata = null; +} diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml new file mode 100644 index 000000000..2f1c4bd58 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml @@ -0,0 +1,36 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + test-parent + 1.0-SNAPSHOT + + + test-module2 + + + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/src/main/java/foo/Main.java b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/src/main/java/foo/Main.java new file mode 100644 index 000000000..7ca91f797 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/src/main/java/foo/Main.java @@ -0,0 +1,32 @@ +/* + * 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 foo; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.model.Model; + +public class Main +{ + public static final String SCOPE_COMPILE = Artifact.SCOPE_COMPILE; + + public Model model = null; + + public Metadata metadata = null; +} diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml new file mode 100644 index 000000000..821d3ec34 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml @@ -0,0 +1,61 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test-parent + 1.0-SNAPSHOT + pom + + Test + + Test dependency:analyze on a multi-module project + + + + UTF-8 + + + + module1 + module2 + + + + + + org.apache.maven + maven-core + 3.9.6 + + + javax.servlet + javax.servlet-api + + + + + + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy new file mode 100644 index 000000000..750514292 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy @@ -0,0 +1,30 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String buildLog = file.getText( "UTF-8" ); +assert buildLog.contains( '[WARNING] test-module1 defines following unnecessary excludes'); +assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:'); +assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api'); + +assert !buildLog.contains( '[WARNING] test-module2 defines following unnecessary excludes'); + +return true; diff --git a/src/it/projects/analyze-invalid-exclude/invoker.properties b/src/it/projects/analyze-invalid-exclude/invoker.properties new file mode 100644 index 000000000..541715067 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze-exclusions diff --git a/src/it/projects/analyze-invalid-exclude/pom.xml b/src/it/projects/analyze-invalid-exclude/pom.xml new file mode 100644 index 000000000..29f2165d7 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude/pom.xml @@ -0,0 +1,95 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + test-module + + Test dependency:analyze-exclusion + + + + UTF-8 + + + + + org.apache.maven + maven-core + 3.9.6 + + + org.apache.maven + maven-artifact + 3.9.6 + + + javax.annotation + javax.annotation-api + + + javax.activation + javax.activation-api + + + + + org.apache.maven + maven-model + 3.9.6 + + + + + + + org.apache.maven + maven-core + 3.9.6 + + + javax.servlet + javax.servlet-api + + + + + + + + + + + maven-dependency-plugin + + false + + + + + + diff --git a/src/it/projects/analyze-invalid-exclude/src/main/java/Main.java b/src/it/projects/analyze-invalid-exclude/src/main/java/Main.java new file mode 100644 index 000000000..e4d166fa1 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude/src/main/java/Main.java @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.model.Model; + +public class Main +{ + public static final String SCOPE_COMPILE = Artifact.SCOPE_COMPILE; + + public Model model = null; + + public Metadata metadata = null; +} diff --git a/src/it/projects/analyze-invalid-exclude/verify.groovy b/src/it/projects/analyze-invalid-exclude/verify.groovy new file mode 100644 index 000000000..513517d12 --- /dev/null +++ b/src/it/projects/analyze-invalid-exclude/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String buildLog = file.getText( "UTF-8" ); +assert buildLog.contains( '[WARNING] test-module defines following unnecessary excludes'); +assert buildLog.contains( '[WARNING] org.apache.maven:maven-artifact:'); +assert buildLog.contains( '[WARNING] - javax.annotation:javax.annotation-api'); +assert buildLog.contains( '[WARNING] - javax.activation:javax.activation-api'); +assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:'); +assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api'); + +return true; diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java new file mode 100644 index 000000000..aed40c98b --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -0,0 +1,163 @@ +/* + * 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.dependency.exclusion; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +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.plugins.annotations.ResolutionScope; +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.project.ProjectBuildingResult; + +import static java.lang.String.format; +import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toSet; +import static org.apache.commons.lang3.StringUtils.stripToEmpty; +import static org.apache.maven.plugins.dependency.exclusion.Coordinates.coordinates; + +/** + * Analyzes the exclusions defined on dependencies in this project and reports if any of them are invalid. + *

+ * Relevant use case is when an artifact in a later version has removed usage of a dependency, making the exclusion no + * longer valid. + *

+ * + * @since 3.7.0 + */ +@Mojo(name = "analyze-exclusions", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) +public class AnalyzeExclusionsMojo extends AbstractMojo { + + @Component + private MavenProject project; + + @Component + private ProjectBuilder projectBuilder; + + @Component + private MavenSession session; + + /** + * Whether to fail the build if invalid exclusions is found. + * + * @since 3.7.0 + */ + @Parameter(property = "mdep.exclusion.fail", defaultValue = "false") + private boolean exclusionFail; + + /** + * Skip plugin execution completely. + * + * @since 3.7.0 + */ + @Parameter(property = "mdep.skip", defaultValue = "false") + private boolean skip; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + if (skip) { + getLog().debug("Skipping execution"); + return; + } + List dependenciesWithExclusions = project.getDependencies().stream() + .filter(dep -> !dep.getExclusions().isEmpty()) + .collect(toList()); + + if (dependenciesWithExclusions.isEmpty()) { + getLog().debug("No dependencies defined with exclusions - exiting"); + return; + } + + ExclusionChecker checker = new ExclusionChecker(); + + for (final Dependency dependency : dependenciesWithExclusions) { + Coordinates currentCoordinates = coordinates(dependency.getGroupId(), dependency.getArtifactId()); + Artifact matchingArtifact = project.getArtifacts().stream() + .filter(artifact -> matchesDependency(artifact, dependency)) + .findFirst() + .orElseThrow(() -> new MojoExecutionException( + format("Error finding Artifact for given Dependency [%s]", dependency))); + + ProjectBuildingResult result = buildProject(matchingArtifact); + + Set actualDependencies = result.getProject().getArtifacts().stream() + .map(a -> coordinates(a.getGroupId(), a.getArtifactId())) + .collect(toSet()); + + Set exclusions = dependency.getExclusions().stream() + .map(e -> coordinates(e.getGroupId(), e.getArtifactId())) + .collect(toSet()); + + checker.check(currentCoordinates, exclusions, actualDependencies); + } + + if (!checker.getViolations().isEmpty()) { + if (exclusionFail) { + logViolations(project.getName(), checker.getViolations(), (value) -> getLog().error(value)); + throw new MojoExecutionException("Invalid exclusions found"); + } else { + logViolations(project.getName(), checker.getViolations(), (value) -> getLog().warn(value)); + } + } + } + + private boolean matchesDependency(Artifact artifact, Dependency dependency) { + return Objects.equals(artifact.getGroupId(), dependency.getGroupId()) + && Objects.equals(artifact.getArtifactId(), dependency.getArtifactId()) + && Objects.equals(artifact.getType(), dependency.getType()) + && Objects.equals(stripToEmpty(artifact.getClassifier()), stripToEmpty(dependency.getClassifier())); + } + + private void logViolations(String name, Map> violations, Consumer logger) { + logger.accept(name + " defines following unnecessary excludes"); + violations.forEach((dependency, invalidExclusions) -> { + logger.accept(" " + dependency + ":"); + invalidExclusions.forEach(invalidExclusion -> { + logger.accept(" - " + invalidExclusion); + }); + }); + } + + private ProjectBuildingResult buildProject(Artifact artifact) throws MojoExecutionException { + try { + ProjectBuildingRequest projectBuildingRequest = + new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + projectBuildingRequest.setResolveDependencies(true); + return projectBuilder.build(artifact, true, projectBuildingRequest); + } catch (ProjectBuildingException e) { + throw new MojoExecutionException( + format("Failed to build project for %s:%s", artifact.getGroupId(), artifact.getArtifactId()), e); + } + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java new file mode 100644 index 000000000..cb4a042ec --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java @@ -0,0 +1,101 @@ +/* + * 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.dependency.exclusion; + +import java.lang.reflect.Proxy; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.util.Objects; +import java.util.function.Predicate; + +/** + * Simple "record" to hold the coordinates of the dependency which is excluded. + *

+ * When dealing with exclusions the version is not important. Only groupId and artifactId is used. + *

+ */ +class Coordinates { + private final String groupId; + private final String artifactId; + + private Coordinates(String groupId, String artifactId) { + this.groupId = groupId; + this.artifactId = artifactId; + } + + public static Coordinates coordinates(String groupId, String artifactId) { + return new Coordinates(groupId, artifactId); + } + + public String getGroupId() { + return groupId; + } + + public String getArtifactId() { + return artifactId; + } + + Predicate getExclusionPattern() { + PathMatcher groupId = FileSystems.getDefault().getPathMatcher("glob:" + getGroupId()); + PathMatcher artifactId = FileSystems.getDefault().getPathMatcher("glob:" + getArtifactId()); + Predicate predGroupId = a -> groupId.matches(createPathProxy(a.getGroupId())); + Predicate predArtifactId = a -> artifactId.matches(createPathProxy(a.getArtifactId())); + + return predGroupId.and(predArtifactId); + } + + /** + * In order to reuse the glob matcher from the filesystem, we need + * to create Path instances. Those are only used with the toString method. + * This hack works because the only system-dependent thing is the path + * separator which should not be part of the groupId or artifactId. + */ + private static Path createPathProxy(String value) { + return (Path) Proxy.newProxyInstance( + Coordinates.class.getClassLoader(), new Class[] {Path.class}, (proxy1, method, args) -> { + if ("toString".equals(method.getName())) { + return value; + } + throw new UnsupportedOperationException(); + }); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Coordinates that = (Coordinates) o; + return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId); + } + + @Override + public int hashCode() { + return Objects.hash(groupId, artifactId); + } + + @Override + public String toString() { + return groupId + ":" + artifactId; + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java new file mode 100644 index 000000000..7219cdee3 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java @@ -0,0 +1,45 @@ +/* + * 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.dependency.exclusion; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static java.util.stream.Collectors.toList; + +class ExclusionChecker { + + private final Map> violations = new HashMap<>(); + + Map> getViolations() { + return violations; + } + + void check(Coordinates artifact, Set excludes, Set actualDependencies) { + List invalidExclusions = excludes.stream() + .filter(exclude -> actualDependencies.stream().noneMatch(exclude.getExclusionPattern())) + .collect(toList()); + + if (!invalidExclusions.isEmpty()) { + violations.put(artifact, invalidExclusions); + } + } +} diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 1dae65445..86156343f 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -98,6 +98,8 @@ ${project.name} *{{{./unpack-dependencies-mojo.html}dependency:unpack-dependencies}} like copy-dependencies but unpacks. + *{{{./analyze-exclusions-mojo.html}dependency:analyze-exclusions}} displays invalid exclusions for this project. + [] * Usage diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 6a8db0cf7..58abc43fd 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -695,3 +695,24 @@ mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion= mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2 mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar +-----+ + + +* <<>> + + This goal checks exclusions on dependencies and checks if the artifact actually brings in the given dependency. + For instance given dependency a:b:1.0 transitively includes x:y:1.0 which you do not want for some reason and exclude it. + Later a:b:2.0 has removed the unwanted dependency and you upgrade. This goal will inform you that the exclusion is no + longer required. + ++---+ +mvn dependency:analyze-exclusions ++---+ + + Sample output: + ++---+ +[WARNING] The following dependencies defines unnecessary excludes +[WARNING] org.apache.maven:maven-artifact: +[WARNING] - javax.annotation:javax.annotation-api +[WARNING] - javax.activation:javax.activation-api ++---+ \ No newline at end of file diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java new file mode 100644 index 000000000..951cea0e9 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -0,0 +1,403 @@ +/* + * 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.dependency.exclusion; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; +import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingResult; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyBoolean; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class AnalyzeExclusionsMojoTest extends AbstractDependencyMojoTestCase { + + AnalyzeExclusionsMojo mojo; + MavenProject project; + private TestLog testLog; + + @Override + public void setUp() throws Exception { + super.setUp("analyze-exclusions", true, false); + + project = new DependencyProjectStub(); + project.setName("projectName"); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + + File testPom = new File(getBasedir(), "target/test-classes/unit/analyze-exclusions/plugin-config.xml"); + mojo = (AnalyzeExclusionsMojo) lookupMojo("analyze-exclusions", testPom); + assertNotNull(mojo); + + LegacySupport legacySupport = lookup(LegacySupport.class); + legacySupport.setSession(session); + installLocalRepository(legacySupport); + + testLog = new TestLog(); + mojo.setLog(testLog); + } + + public void testShallThrowExceptionWhenFailOnWarning() throws Exception { + List projectDependencies = new ArrayList<>(); + Dependency withInvalidExclusion = dependency("a", "b"); + withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); + projectDependencies.add(withInvalidExclusion); + project.setDependencies(projectDependencies); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + setVariableValueToObject(mojo, "exclusionFail", true); + + assertThatThrownBy(() -> mojo.execute()) + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Invalid exclusions found"); + } + + public void testShallLogErrorWhenFailOnWarningIsTrue() throws Exception { + List dependencies = new ArrayList<>(); + Dependency withInvalidExclusion = dependency("a", "b"); + withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); + dependencies.add(withInvalidExclusion); + project.setDependencies(dependencies); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + setVariableValueToObject(mojo, "exclusionFail", true); + + try { + mojo.execute(); + } catch (MojoExecutionException ignored) { + // ignored + } + + assertThat(testLog.getContent()).startsWith("[error]"); + } + + public void testShallLogWarningWhenFailOnWarningIsFalse() throws Exception { + List dependencies = new ArrayList<>(); + Dependency withInvalidExclusion = dependency("a", "b"); + withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); + dependencies.add(withInvalidExclusion); + project.setDependencies(dependencies); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + setVariableValueToObject(mojo, "exclusionFail", false); + + mojo.execute(); + + assertThat(testLog.getContent()).startsWith("[warn]"); + } + + public void testShallExitWithoutAnalyzeWhenNoDependencyHasExclusion() throws Exception { + List dependencies = new ArrayList<>(); + dependencies.add(dependency("a", "c")); + project.setDependencies(dependencies); + mojo.execute(); + assertThat(testLog.getContent()).startsWith("[debug] No dependencies defined with exclusions - exiting"); + } + + public void testShallNotReportInvalidExclusionForWildcardGroupIdAndArtifactId() throws Exception { + Dependency dependencyWithWildcardExclusion = dependency("a", "b"); + dependencyWithWildcardExclusion.addExclusion(exclusion("*", "*")); + project.setDependencies(Arrays.asList(dependencyWithWildcardExclusion)); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + + ProjectBuilder projectBuilder = mock(ProjectBuilder.class); + MavenProject mavenProject = new MavenProject(); + mavenProject.setArtifacts(new HashSet<>(Arrays.asList(stubFactory.createArtifact("whatever", "ok", "1.0")))); + + ProjectBuildingResult pbr = mock(ProjectBuildingResult.class); + when(pbr.getProject()).thenReturn(mavenProject); + when(projectBuilder.build(any(Artifact.class), anyBoolean(), any())).thenReturn(pbr); + setVariableValueToObject(mojo, "projectBuilder", projectBuilder); + + mojo.execute(); + + assertThat(testLog.getContent()).doesNotContain("[warn] a:b:", "[warn] - *:*"); + } + + public void testCanResolveMultipleArtifactsWithEqualGroupIdAndArtifactId() throws Exception { + Dependency dependency1 = dependency("a", "b"); + Dependency dependency2 = dependency("a", "b", "compile", "native"); + dependency1.addExclusion(exclusion("c", "d")); + dependency2.addExclusion(exclusion("c", "d")); + project.setDependencies(Arrays.asList(dependency1, dependency2)); + Artifact artifact1 = stubFactory.createArtifact("a", "b", "1.0"); + Artifact artifact2 = stubFactory.createArtifact("a", "b", "1.0", "compile", "jar", "native"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact1, artifact2))); + + assertThatCode(() -> mojo.execute()).doesNotThrowAnyException(); + } + + public void testShallNotLogWhenExclusionIsValid() throws Exception { + List dependencies = new ArrayList<>(); + Dependency dependency = dependency("a", "b"); + dependency.addExclusion(exclusion("ok", "ok")); + dependencies.add(dependency); + project.setDependencies(dependencies); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + setVariableValueToObject(mojo, "exclusionFail", true); + + ProjectBuilder projectBuilder = mock(ProjectBuilder.class); + MavenProject mavenProject = new MavenProject(); + mavenProject.setArtifacts(new HashSet<>(Arrays.asList(stubFactory.createArtifact("ok", "ok", "1.0")))); + + ProjectBuildingResult pbr = mock(ProjectBuildingResult.class); + when(pbr.getProject()).thenReturn(mavenProject); + when(projectBuilder.build(any(Artifact.class), anyBoolean(), any())).thenReturn(pbr); + + setVariableValueToObject(mojo, "projectBuilder", projectBuilder); + assertThatCode(() -> mojo.execute()).doesNotThrowAnyException(); + } + + public void testThatLogContainProjectName() throws Exception { + List dependencies = new ArrayList<>(); + Dependency withInvalidExclusion = dependency("a", "b"); + withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); + dependencies.add(withInvalidExclusion); + project.setDependencies(dependencies); + Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); + project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + + mojo.execute(); + + assertThat(testLog.getContent()).contains("[warn] projectName defines following unnecessary excludes"); + } + + private Dependency dependency(String groupId, String artifactId) { + Dependency dependency = new Dependency(); + dependency.setGroupId(groupId); + dependency.setArtifactId(artifactId); + dependency.setVersion("1.0"); + dependency.setScope("compile"); + dependency.setType("jar"); + dependency.setClassifier(""); + return dependency; + } + + private Dependency dependency(String groupId, String artifactId, String scope, String classifier) { + Dependency dependency = new Dependency(); + dependency.setGroupId(groupId); + dependency.setArtifactId(artifactId); + dependency.setVersion("1.0"); + dependency.setScope(scope); + dependency.setType("jar"); + dependency.setClassifier(classifier); + return dependency; + } + + private Exclusion exclusion(String groupId, String artifactId) { + Exclusion exclusion = new Exclusion(); + exclusion.setGroupId(groupId); + exclusion.setArtifactId(artifactId); + return exclusion; + } + + static class TestLog implements Log { + StringBuilder sb = new StringBuilder(); + + /** + * {@inheritDoc} + */ + public void debug(CharSequence content) { + print("debug", content); + } + + /** + * {@inheritDoc} + */ + public void debug(CharSequence content, Throwable error) { + print("debug", content, error); + } + + /** + * {@inheritDoc} + */ + public void debug(Throwable error) { + print("debug", error); + } + + /** + * {@inheritDoc} + */ + public void info(CharSequence content) { + print("info", content); + } + + /** + * {@inheritDoc} + */ + public void info(CharSequence content, Throwable error) { + print("info", content, error); + } + + /** + * {@inheritDoc} + */ + public void info(Throwable error) { + print("info", error); + } + + /** + * {@inheritDoc} + */ + public void warn(CharSequence content) { + print("warn", content); + } + + /** + * {@inheritDoc} + */ + public void warn(CharSequence content, Throwable error) { + print("warn", content, error); + } + + /** + * {@inheritDoc} + */ + public void warn(Throwable error) { + print("warn", error); + } + + /** + * {@inheritDoc} + */ + public void error(CharSequence content) { + print("error", content); + } + + /** + * {@inheritDoc} + */ + public void error(CharSequence content, Throwable error) { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter(sWriter); + + error.printStackTrace(pWriter); + + System.err.println("[error] " + content.toString() + System.lineSeparator() + System.lineSeparator() + + sWriter.toString()); + } + + /** + * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) + */ + public void error(Throwable error) { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter(sWriter); + + error.printStackTrace(pWriter); + + System.err.println("[error] " + sWriter.toString()); + } + + /** + * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() + */ + public boolean isDebugEnabled() { + // TODO: Not sure how best to set these for this implementation... + return false; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() + */ + public boolean isInfoEnabled() { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() + */ + public boolean isWarnEnabled() { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() + */ + public boolean isErrorEnabled() { + return true; + } + + private void print(String prefix, CharSequence content) { + sb.append("[") + .append(prefix) + .append("] ") + .append(content.toString()) + .append(System.lineSeparator()); + } + + private void print(String prefix, Throwable error) { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter(sWriter); + + error.printStackTrace(pWriter); + + sb.append("[") + .append(prefix) + .append("] ") + .append(sWriter.toString()) + .append(System.lineSeparator()); + } + + private void print(String prefix, CharSequence content, Throwable error) { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter(sWriter); + + error.printStackTrace(pWriter); + + sb.append("[") + .append(prefix) + .append("] ") + .append(content.toString()) + .append(System.lineSeparator()) + .append(System.lineSeparator()); + sb.append(sWriter.toString()).append(System.lineSeparator()); + } + + protected String getContent() { + return sb.toString(); + } + } +} diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java new file mode 100644 index 000000000..857fd6f66 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java @@ -0,0 +1,101 @@ +/* + * 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.dependency.exclusion; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; + +import static org.apache.maven.plugins.dependency.exclusion.Coordinates.coordinates; +import static org.assertj.core.api.Assertions.assertThat; + +public class ExclusionCheckerTest { + + private ExclusionChecker checker; + + @Before + public void setUp() throws Exception { + checker = new ExclusionChecker(); + } + + @Test + public void shallReportInvalidExclusions() { + Coordinates artifact = coordinates("com.current", "artifact"); + Set excludes = new HashSet<>(Arrays.asList( + coordinates("com.example", "one"), + coordinates("com.example", "two"), + coordinates("com.example", "three"), + coordinates("com.example", "four"))); + + Set actualDependencies = + new HashSet<>(Arrays.asList(coordinates("com.example", "one"), coordinates("com.example", "four"))); + + checker.check(artifact, excludes, actualDependencies); + + assertThat(checker.getViolations()) + .containsEntry( + artifact, + Arrays.asList(coordinates("com.example", "two"), coordinates("com.example", "three"))); + } + + @Test + public void noViolationsWhenEmptyExclusions() { + checker.check(coordinates("a", "b"), new HashSet<>(), new HashSet<>()); + assertThat(checker.getViolations()).isEmpty(); + } + + @Test + public void shallReportInvalidExclusionsWhenNoDependencies() { + Coordinates artifact = coordinates("a", "b"); + HashSet actualDependencies = new HashSet<>(); + checker.check(artifact, new HashSet<>(Arrays.asList(coordinates("p", "m"))), actualDependencies); + assertThat(checker.getViolations()).containsEntry(artifact, Arrays.asList(coordinates("p", "m"))); + } + + @Test + public void shallHandleWildcardExclusions() { + Coordinates artifact = coordinates("com.current", "artifact"); + Set excludes = new HashSet<>(Arrays.asList(coordinates("*", "*"))); + + Set actualDependencies = + new HashSet<>(Arrays.asList(coordinates("com.example", "one"), coordinates("com.example", "four"))); + + checker.check(artifact, excludes, actualDependencies); + + assertThat(checker.getViolations()).isEmpty(); + } + + @Test + public void shallHandleWildcardGroupIdExclusion() { + Coordinates artifact = coordinates("com.current", "artifact"); + Set excludes = new HashSet<>(Arrays.asList(coordinates("javax", "*"))); + + Set actualDependencies = new HashSet<>(Arrays.asList( + coordinates("com.example", "one"), + coordinates("com.example", "four"), + coordinates("javax", "whatever"))); + + checker.check(artifact, excludes, actualDependencies); + + assertThat(checker.getViolations()).isEmpty(); + } +} diff --git a/src/test/resources/unit/analyze-exclusions/plugin-config.xml b/src/test/resources/unit/analyze-exclusions/plugin-config.xml new file mode 100644 index 000000000..ccf9ebde4 --- /dev/null +++ b/src/test/resources/unit/analyze-exclusions/plugin-config.xml @@ -0,0 +1,43 @@ + + + + + + maven-dependency-plugin + + + + + + + + org.apache.maven + maven-artifact + 2.0.4 + + + javax.inject + javax.inject + + + + + \ No newline at end of file From 4083455832430ec790b83e16c498b064ad8beb4d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 14 Apr 2024 19:33:03 +0200 Subject: [PATCH 093/283] [MDEP-918] Use standard updatePolicy for repositories in ITs --- src/it/mrm/settings.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/it/mrm/settings.xml b/src/it/mrm/settings.xml index bd5f56925..63bd2bf03 100644 --- a/src/it/mrm/settings.xml +++ b/src/it/mrm/settings.xml @@ -38,12 +38,10 @@ under the License. true ignore - never true ignore - always @@ -54,12 +52,10 @@ under the License. true ignore - never true ignore - always From d641b4425281fda4ab0c85e620e2b9d7eb4556d9 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 15 Apr 2024 00:29:22 +0200 Subject: [PATCH 094/283] [MDEP-919] Fix ITs for Maven4 --- src/it/projects/copy-from-remote-repository/pom.xml | 3 +++ src/it/projects/unpack-from-remote-repository/pom.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/it/projects/copy-from-remote-repository/pom.xml b/src/it/projects/copy-from-remote-repository/pom.xml index f55e60363..1e991a852 100644 --- a/src/it/projects/copy-from-remote-repository/pom.xml +++ b/src/it/projects/copy-from-remote-repository/pom.xml @@ -42,6 +42,9 @@ fake-remote-repository file:///${basedir}/repo/ + + ignore + diff --git a/src/it/projects/unpack-from-remote-repository/pom.xml b/src/it/projects/unpack-from-remote-repository/pom.xml index c16b6f2c8..e29d6dc5b 100644 --- a/src/it/projects/unpack-from-remote-repository/pom.xml +++ b/src/it/projects/unpack-from-remote-repository/pom.xml @@ -42,6 +42,9 @@ fake-remote-repository file:///${basedir}/repo/ + + ignore + From 2a3c0722f27f3a0e5a79abc0a4024a171b0c24d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:21:56 +0200 Subject: [PATCH 095/283] [MDEP-920] Bump org.assertj:assertj-core from 3.24.2 to 3.25.3 (#373) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.24.2 to 3.25.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.24.2...assertj-build-3.25.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc1716791..0145ae883 100644 --- a/pom.xml +++ b/pom.xml @@ -328,7 +328,7 @@ under the License. org.assertj assertj-core - 3.24.2 + 3.25.3 test From 6d808b3feb8bbaac2174f83de43b625b513dcecd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 07:02:40 +0800 Subject: [PATCH 096/283] Bump org.apache.maven.plugins:maven-plugins from 41 to 42 (#377) Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 41 to 42. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0145ae883..d11ad5fdb 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 41 + 42 From 730a7a22fdf062fe0ffa2ddb5202680424d4c056 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 16 Apr 2024 23:52:18 +0200 Subject: [PATCH 097/283] Add Release Drafter --- .github/release-drafter.yml | 21 ++++++++++++++++++++ .github/workflows/release-drafter.yml | 28 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000..f8dfd76b8 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,21 @@ + + +# 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. + +_extends: maven-gh-actions-shared +tag-template: maven-dependency-plugin-$NEXT_MINOR_VERSION diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 000000000..5205f96ef --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,28 @@ + + +# 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. + +name: Release Drafter +on: + push: + branches: + - master + +jobs: + update_release_draft: + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 From 5cebf02e50d97b21ab740319428f196612a8b673 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 18:49:39 +0200 Subject: [PATCH 098/283] [MDEP-921] Bump org.apache.commons:commons-text from 1.11.0 to 1.12.0 (#376) Bumps org.apache.commons:commons-text from 1.11.0 to 1.12.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d11ad5fdb..0bd36a274 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ under the License. org.apache.commons commons-text - 1.11.0 + 1.12.0 From 27458d9dca1473cabaca00e0060cd258813cfc0a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 16 Apr 2024 23:35:52 +0200 Subject: [PATCH 099/283] [MDEP-917] dependency:analyze-exclusions - use Resolver API instead of ProjectBuilder --- .../module2/pom.xml | 12 ++++ .../pom.xml | 11 +++ .../projects/analyze-invalid-exclude/pom.xml | 9 +-- .../exclusion/AnalyzeExclusionsMojo.java | 72 +++++++------------ .../dependency/utils/ResolverUtil.java | 71 ++++++++++++++++++ .../exclusion/AnalyzeExclusionsMojoTest.java | 72 +++++++------------ .../fromConfiguration/TestUnpackMojo.java | 17 +++-- 7 files changed, 161 insertions(+), 103 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml index 2f1c4bd58..17d63f147 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml @@ -32,5 +32,17 @@ test-module2 + + org.apache.maven.its.dependency + test-module1 + ${project.version} + + + org.apache.maven + maven-core + + + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml index 821d3ec34..56e37b4ca 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml @@ -58,4 +58,15 @@ + + + + + maven-dependency-plugin + @project.version@ + + + + + diff --git a/src/it/projects/analyze-invalid-exclude/pom.xml b/src/it/projects/analyze-invalid-exclude/pom.xml index 29f2165d7..17587fea5 100644 --- a/src/it/projects/analyze-invalid-exclude/pom.xml +++ b/src/it/projects/analyze-invalid-exclude/pom.xml @@ -40,7 +40,6 @@ org.apache.maven maven-core - 3.9.6 org.apache.maven @@ -75,6 +74,10 @@ javax.servlet javax.servlet-api + + org.codehaus.plexus + * + @@ -85,9 +88,7 @@ maven-dependency-plugin - - false - + @project.version@ diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java index aed40c98b..871296f6b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -18,33 +18,28 @@ */ package org.apache.maven.plugins.dependency.exclusion; +import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.function.Consumer; -import org.apache.maven.artifact.Artifact; +import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; 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.plugins.annotations.ResolutionScope; -import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.project.ProjectBuildingResult; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.collection.DependencyCollectionException; -import static java.lang.String.format; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; -import static org.apache.commons.lang3.StringUtils.stripToEmpty; import static org.apache.maven.plugins.dependency.exclusion.Coordinates.coordinates; /** @@ -56,14 +51,14 @@ * * @since 3.7.0 */ -@Mojo(name = "analyze-exclusions", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) +@Mojo(name = "analyze-exclusions", requiresDependencyCollection = ResolutionScope.TEST, threadSafe = true) public class AnalyzeExclusionsMojo extends AbstractMojo { @Component private MavenProject project; @Component - private ProjectBuilder projectBuilder; + private ResolverUtil resolverUtil; @Component private MavenSession session; @@ -85,12 +80,12 @@ public class AnalyzeExclusionsMojo extends AbstractMojo { private boolean skip; @Override - public void execute() throws MojoExecutionException, MojoFailureException { + public void execute() throws MojoExecutionException { if (skip) { getLog().debug("Skipping execution"); return; } - List dependenciesWithExclusions = project.getDependencies().stream() + Collection dependenciesWithExclusions = project.getDependencies().stream() .filter(dep -> !dep.getExclusions().isEmpty()) .collect(toList()); @@ -101,17 +96,23 @@ public void execute() throws MojoExecutionException, MojoFailureException { ExclusionChecker checker = new ExclusionChecker(); + ArtifactTypeRegistry artifactTypeRegistry = + session.getRepositorySession().getArtifactTypeRegistry(); for (final Dependency dependency : dependenciesWithExclusions) { + Coordinates currentCoordinates = coordinates(dependency.getGroupId(), dependency.getArtifactId()); - Artifact matchingArtifact = project.getArtifacts().stream() - .filter(artifact -> matchesDependency(artifact, dependency)) - .findFirst() - .orElseThrow(() -> new MojoExecutionException( - format("Error finding Artifact for given Dependency [%s]", dependency))); - ProjectBuildingResult result = buildProject(matchingArtifact); + Collection actualDependencies = null; + try { + actualDependencies = + resolverUtil.collectDependencies(RepositoryUtils.toDependency(dependency, artifactTypeRegistry) + .setExclusions(null)); + } catch (DependencyCollectionException e) { + throw new MojoExecutionException(e.getMessage(), e); + } - Set actualDependencies = result.getProject().getArtifacts().stream() + Set actualCoordinates = actualDependencies.stream() + .map(org.eclipse.aether.graph.Dependency::getArtifact) .map(a -> coordinates(a.getGroupId(), a.getArtifactId())) .collect(toSet()); @@ -119,45 +120,24 @@ public void execute() throws MojoExecutionException, MojoFailureException { .map(e -> coordinates(e.getGroupId(), e.getArtifactId())) .collect(toSet()); - checker.check(currentCoordinates, exclusions, actualDependencies); + checker.check(currentCoordinates, exclusions, actualCoordinates); } if (!checker.getViolations().isEmpty()) { if (exclusionFail) { - logViolations(project.getName(), checker.getViolations(), (value) -> getLog().error(value)); + logViolations(project.getName(), checker.getViolations(), value -> getLog().error(value)); throw new MojoExecutionException("Invalid exclusions found"); } else { - logViolations(project.getName(), checker.getViolations(), (value) -> getLog().warn(value)); + logViolations(project.getName(), checker.getViolations(), value -> getLog().warn(value)); } } } - private boolean matchesDependency(Artifact artifact, Dependency dependency) { - return Objects.equals(artifact.getGroupId(), dependency.getGroupId()) - && Objects.equals(artifact.getArtifactId(), dependency.getArtifactId()) - && Objects.equals(artifact.getType(), dependency.getType()) - && Objects.equals(stripToEmpty(artifact.getClassifier()), stripToEmpty(dependency.getClassifier())); - } - private void logViolations(String name, Map> violations, Consumer logger) { logger.accept(name + " defines following unnecessary excludes"); violations.forEach((dependency, invalidExclusions) -> { logger.accept(" " + dependency + ":"); - invalidExclusions.forEach(invalidExclusion -> { - logger.accept(" - " + invalidExclusion); - }); + invalidExclusions.forEach(invalidExclusion -> logger.accept(" - " + invalidExclusion)); }); } - - private ProjectBuildingResult buildProject(Artifact artifact) throws MojoExecutionException { - try { - ProjectBuildingRequest projectBuildingRequest = - new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - projectBuildingRequest.setResolveDependencies(true); - return projectBuilder.build(artifact, true, projectBuildingRequest); - } catch (ProjectBuildingException e) { - throw new MojoExecutionException( - format("Failed to build project for %s:%s", artifact.getGroupId(), artifact.getArtifactId()), e); - } - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java new file mode 100644 index 000000000..6138ddd16 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -0,0 +1,71 @@ +/* + * 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.dependency.utils; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import java.util.Collection; + +import org.apache.maven.execution.MavenSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.collection.CollectResult; +import org.eclipse.aether.collection.DependencyCollectionException; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; + +/** + * Helper class for using Resolver API. + */ +@Named +@Singleton +public class ResolverUtil { + + private final RepositorySystem repositorySystem; + + private final Provider mavenSessionProvider; + + @Inject + private ResolverUtil(RepositorySystem repositorySystem, Provider mavenSessionProvider) { + this.repositorySystem = repositorySystem; + this.mavenSessionProvider = mavenSessionProvider; + } + + /** + * Collects the transitive dependencies. + * + * @param root a root dependency for collections + * @return a resolved dependencies collections + */ + public Collection collectDependencies(Dependency root) throws DependencyCollectionException { + + MavenSession session = mavenSessionProvider.get(); + + CollectRequest request = + new CollectRequest(root, session.getCurrentProject().getRemoteProjectRepositories()); + CollectResult result = repositorySystem.collectDependencies(session.getRepositorySession(), request); + + PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator(); + result.getRoot().accept(nodeListGenerator); + return nodeListGenerator.getDependencies(true); + } +} diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index 951cea0e9..10ce18441 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -23,9 +23,11 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; @@ -35,24 +37,26 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingResult; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyBoolean; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class AnalyzeExclusionsMojoTest extends AbstractDependencyMojoTestCase { - AnalyzeExclusionsMojo mojo; - MavenProject project; + private AnalyzeExclusionsMojo mojo; + + private MavenProject project; + private TestLog testLog; + private ResolverUtil resolverUtil; + @Override public void setUp() throws Exception { super.setUp("analyze-exclusions", true, false); @@ -64,6 +68,9 @@ public void setUp() throws Exception { MavenSession session = newMavenSession(project); getContainer().addComponent(session, MavenSession.class.getName()); + resolverUtil = mock(ResolverUtil.class); + getContainer().addComponent(resolverUtil, ResolverUtil.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/analyze-exclusions/plugin-config.xml"); mojo = (AnalyzeExclusionsMojo) lookupMojo("analyze-exclusions", testPom); assertNotNull(mojo); @@ -77,35 +84,18 @@ public void setUp() throws Exception { } public void testShallThrowExceptionWhenFailOnWarning() throws Exception { - List projectDependencies = new ArrayList<>(); - Dependency withInvalidExclusion = dependency("a", "b"); - withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); - projectDependencies.add(withInvalidExclusion); - project.setDependencies(projectDependencies); - Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); - setVariableValueToObject(mojo, "exclusionFail", true); - - assertThatThrownBy(() -> mojo.execute()) - .isInstanceOf(MojoExecutionException.class) - .hasMessageContaining("Invalid exclusions found"); - } - - public void testShallLogErrorWhenFailOnWarningIsTrue() throws Exception { List dependencies = new ArrayList<>(); Dependency withInvalidExclusion = dependency("a", "b"); withInvalidExclusion.addExclusion(exclusion("invalid", "invalid")); dependencies.add(withInvalidExclusion); project.setDependencies(dependencies); Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + project.setArtifacts(new HashSet<>(Collections.singletonList(artifact))); setVariableValueToObject(mojo, "exclusionFail", true); - try { - mojo.execute(); - } catch (MojoExecutionException ignored) { - // ignored - } + assertThatThrownBy(() -> mojo.execute()) + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Invalid exclusions found"); assertThat(testLog.getContent()).startsWith("[error]"); } @@ -117,7 +107,7 @@ public void testShallLogWarningWhenFailOnWarningIsFalse() throws Exception { dependencies.add(withInvalidExclusion); project.setDependencies(dependencies); Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + project.setArtifacts(new HashSet<>(Collections.singletonList(artifact))); setVariableValueToObject(mojo, "exclusionFail", false); mojo.execute(); @@ -140,14 +130,9 @@ public void testShallNotReportInvalidExclusionForWildcardGroupIdAndArtifactId() Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); - ProjectBuilder projectBuilder = mock(ProjectBuilder.class); - MavenProject mavenProject = new MavenProject(); - mavenProject.setArtifacts(new HashSet<>(Arrays.asList(stubFactory.createArtifact("whatever", "ok", "1.0")))); - - ProjectBuildingResult pbr = mock(ProjectBuildingResult.class); - when(pbr.getProject()).thenReturn(mavenProject); - when(projectBuilder.build(any(Artifact.class), anyBoolean(), any())).thenReturn(pbr); - setVariableValueToObject(mojo, "projectBuilder", projectBuilder); + when(resolverUtil.collectDependencies(any())) + .thenReturn(Collections.singletonList(new org.eclipse.aether.graph.Dependency( + RepositoryUtils.toArtifact(stubFactory.createArtifact("whatever", "ok", "1.0")), ""))); mojo.execute(); @@ -175,18 +160,13 @@ public void testShallNotLogWhenExclusionIsValid() throws Exception { project.setDependencies(dependencies); Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + project.setArtifacts(new HashSet<>(Collections.singletonList(artifact))); setVariableValueToObject(mojo, "exclusionFail", true); - ProjectBuilder projectBuilder = mock(ProjectBuilder.class); - MavenProject mavenProject = new MavenProject(); - mavenProject.setArtifacts(new HashSet<>(Arrays.asList(stubFactory.createArtifact("ok", "ok", "1.0")))); - - ProjectBuildingResult pbr = mock(ProjectBuildingResult.class); - when(pbr.getProject()).thenReturn(mavenProject); - when(projectBuilder.build(any(Artifact.class), anyBoolean(), any())).thenReturn(pbr); + when(resolverUtil.collectDependencies(any())) + .thenReturn(Collections.singletonList(new org.eclipse.aether.graph.Dependency( + RepositoryUtils.toArtifact(stubFactory.createArtifact("ok", "ok", "1.0")), ""))); - setVariableValueToObject(mojo, "projectBuilder", projectBuilder); assertThatCode(() -> mojo.execute()).doesNotThrowAnyException(); } @@ -197,7 +177,7 @@ public void testThatLogContainProjectName() throws Exception { dependencies.add(withInvalidExclusion); project.setDependencies(dependencies); Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + project.setArtifacts(new HashSet<>(Collections.singletonList(artifact))); mojo.execute(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 6671c515a..66614da7c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -39,6 +39,8 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; +import static org.junit.Assert.assertNotEquals; + public class TestUnpackMojo extends AbstractDependencyMojoTestCase { UnpackMojo mojo; @@ -491,13 +493,13 @@ public void testUnpackOverWriteIfNewer() throws Exception { // round down to the last second long time = now; time = time - (time % 1000); - // go back 10 more seconds for linux - time -= 10000; + // go back 30 more seconds for linux + time -= 30000; // set to known value assertTrue(unpackedFile.setLastModified(time)); // set source to be newer about some seconds, - // especially on macOS it shouldn't be smaller than 8s in order to mitigate flapping test - assertTrue(artifact.getFile().setLastModified(time + 8000)); + // especially on macOS it shouldn't be smaller than 16s in order to mitigate flapping test + assertTrue(artifact.getFile().setLastModified(time + 16000)); // manually set markerfile (must match getMarkerFile in DefaultMarkerFileHandler) File marker = new File(mojo.getMarkersDirectory(), artifact.getId().replace(':', '-') + ".marker"); @@ -510,10 +512,11 @@ public void testUnpackOverWriteIfNewer() throws Exception { long unpackedFileLastModifiedMillis = Files.getLastModifiedTime(unpackedFile.toPath()).toMillis(); - assertTrue( + assertNotEquals( "unpackedFile '" + unpackedFile + "' lastModified() == " + markerLastModifiedMillis + ": should be different", - markerLastModifiedMillis != unpackedFileLastModifiedMillis); + markerLastModifiedMillis, + unpackedFileLastModifiedMillis); } public void assertUnpacked(ArtifactItem item, boolean overWrite) throws Exception { @@ -530,7 +533,7 @@ public void assertUnpacked(ArtifactItem item, boolean overWrite) throws Exceptio mojo.execute(); if (overWrite) { - assertTrue(time != unpackedFile.lastModified()); + assertNotEquals(time, unpackedFile.lastModified()); } else { assertEquals(time, unpackedFile.lastModified()); } From 61d1162a64577549a8af5e43591fe5782c8fbd31 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 18 Apr 2024 23:32:33 +0200 Subject: [PATCH 100/283] [MDEP-922] dependency:analyze-exclusions - should report issue only in current project - filter exclusion by dependency location --- src/it/mrm/repository/a-with-dep.pom | 37 ++++++++++ src/it/mrm/repository/b-with-dep.pom | 38 ++++++++++ src/it/mrm/repository/c-without-dep.pom | 30 ++++++++ .../module1/pom.xml | 19 ++++- .../module2/pom.xml | 4 +- .../pom.xml | 10 +-- .../verify.groovy | 36 ++++++++-- .../projects/analyze-invalid-exclude/pom.xml | 70 ++++++++++--------- .../analyze-invalid-exclude/verify.groovy | 26 ++++--- .../exclusion/AnalyzeExclusionsMojo.java | 61 +++++++++++++--- .../dependency/exclusion/Coordinates.java | 56 +++++++++++++-- .../exclusion/ExclusionChecker.java | 5 +- .../exclusion/AnalyzeExclusionsMojoTest.java | 11 +++ .../exclusion/ExclusionCheckerTest.java | 2 +- 14 files changed, 328 insertions(+), 77 deletions(-) create mode 100644 src/it/mrm/repository/a-with-dep.pom create mode 100644 src/it/mrm/repository/b-with-dep.pom create mode 100644 src/it/mrm/repository/c-without-dep.pom diff --git a/src/it/mrm/repository/a-with-dep.pom b/src/it/mrm/repository/a-with-dep.pom new file mode 100644 index 000000000..d3d163a87 --- /dev/null +++ b/src/it/mrm/repository/a-with-dep.pom @@ -0,0 +1,37 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + a-with-dep + 1.0.0 + + + + org.apache.maven.its.dependency + b-with-dep + 1.0.0 + + + diff --git a/src/it/mrm/repository/b-with-dep.pom b/src/it/mrm/repository/b-with-dep.pom new file mode 100644 index 000000000..60c213fea --- /dev/null +++ b/src/it/mrm/repository/b-with-dep.pom @@ -0,0 +1,38 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + b-with-dep + 1.0.0 + + + + org.apache.maven.its.dependency + c-without-dep + 1.0.0 + + + + diff --git a/src/it/mrm/repository/c-without-dep.pom b/src/it/mrm/repository/c-without-dep.pom new file mode 100644 index 000000000..36721d29d --- /dev/null +++ b/src/it/mrm/repository/c-without-dep.pom @@ -0,0 +1,30 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + c-without-dep + 1.0.0 + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml index 2b329db31..fb2662662 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module1/pom.xml @@ -33,8 +33,23 @@ - org.apache.maven - maven-core + org.apache.maven.its.dependency + a-with-dep + 1.0.0 + + + org.apache.maven.its.dependency + invalid-exclusion2 + + + org.apache.maven.its.dependency + c-without-dep + + + org.apache.maven.its.dependency + invalid-exclusion3 + + diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml index 17d63f147..59f3a92b8 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/module2/pom.xml @@ -38,8 +38,8 @@ ${project.version} - org.apache.maven - maven-core + org.apache.maven.its.dependency + a-with-dep diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml index 56e37b4ca..8e9c27a90 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/pom.xml @@ -45,13 +45,13 @@ - org.apache.maven - maven-core - 3.9.6 + org.apache.maven.its.dependency + a-with-dep + 1.0.0 - javax.servlet - javax.servlet-api + org.apache.maven.its.dependency + invalid-exclusion1 diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy index 750514292..8b798d26c 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy @@ -1,3 +1,5 @@ +import java.lang.reflect.Array + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,14 +19,34 @@ * under the License. */ -File file = new File( basedir, "build.log" ); + +static void checkMessagedInLogs(logLines, messages) { + def index = logLines.indexOf(messages[0]) + assert index > 0: "no messages: '" + messages[0] + "' in log" + + def logMessages = logLines[index..index + messages.size() - 1] + + assert logMessages == messages + +} + +def file = new File(basedir, "build.log"); assert file.exists(); -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( '[WARNING] test-module1 defines following unnecessary excludes'); -assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:'); -assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api'); +def logLines = buildLog = file.readLines() + +checkMessagedInLogs(logLines, [ + '[WARNING] Test defines following unnecessary excludes', + '[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion1 @ line: 52' +]) + +checkMessagedInLogs(logLines, [ + '[WARNING] test-module1 defines following unnecessary excludes', + '[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion2 @ line: 40', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion3 @ line: 48' -assert !buildLog.contains( '[WARNING] test-module2 defines following unnecessary excludes'); +]) -return true; +assert logLines.count('[INFO] No problems with dependencies exclusions') == 1 diff --git a/src/it/projects/analyze-invalid-exclude/pom.xml b/src/it/projects/analyze-invalid-exclude/pom.xml index 17587fea5..5c65025ca 100644 --- a/src/it/projects/analyze-invalid-exclude/pom.xml +++ b/src/it/projects/analyze-invalid-exclude/pom.xml @@ -36,53 +36,59 @@ UTF-8
+ + + + org.apache.maven.its.dependency + a-with-dep + 1.0.0 + + + org.apache.maven.its.dependency + invalid-exclusion1 + + + + + + - org.apache.maven - maven-core + org.apache.maven.its.dependency + b-with-dep + 1.0.0 + + + org.apache.maven.its.dependency + c-without-dep + + + org.apache.maven.its.dependency + invalid-exclusion3 + + - org.apache.maven - maven-artifact - 3.9.6 + org.apache.maven.its.dependency + a-with-dep - javax.annotation - javax.annotation-api + org.apache.maven.its.dependency + invalid-exclusion2 - javax.activation - javax.activation-api + org.apache.maven.its.dependency + c-without-dep - org.apache.maven - maven-model - 3.9.6 + org.apache.maven.its.dependency + c-without-dep + 1.0.0 - - - - org.apache.maven - maven-core - 3.9.6 - - - javax.servlet - javax.servlet-api - - - org.codehaus.plexus - * - - - - - - diff --git a/src/it/projects/analyze-invalid-exclude/verify.groovy b/src/it/projects/analyze-invalid-exclude/verify.groovy index 513517d12..fb3c8c7a6 100644 --- a/src/it/projects/analyze-invalid-exclude/verify.groovy +++ b/src/it/projects/analyze-invalid-exclude/verify.groovy @@ -17,15 +17,23 @@ * under the License. */ -File file = new File( basedir, "build.log" ); +def file = new File(basedir, "build.log"); assert file.exists(); -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( '[WARNING] test-module defines following unnecessary excludes'); -assert buildLog.contains( '[WARNING] org.apache.maven:maven-artifact:'); -assert buildLog.contains( '[WARNING] - javax.annotation:javax.annotation-api'); -assert buildLog.contains( '[WARNING] - javax.activation:javax.activation-api'); -assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:'); -assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api'); +def logLines = buildLog = file.readLines() + +def index = logLines.indexOf('[WARNING] test-module defines following unnecessary excludes') +assert index > 0: "no messages in log" + +def messages = logLines[index..index + 5]; + +assert messages == [ + '[WARNING] test-module defines following unnecessary excludes', + '[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion1 @ line: 46', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion2 @ line: 75', + '[WARNING] org.apache.maven.its.dependency:b-with-dep:1.0.0', + '[WARNING] - org.apache.maven.its.dependency:invalid-exclusion3 @ line: 65' +] + -return true; diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java index 871296f6b..3ad8d3b9b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -18,7 +18,9 @@ */ package org.apache.maven.plugins.dependency.exclusion; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -27,6 +29,7 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; @@ -79,15 +82,39 @@ public class AnalyzeExclusionsMojo extends AbstractMojo { @Parameter(property = "mdep.skip", defaultValue = "false") private boolean skip; + /** + * Current project modelId. + */ + private String projectModelId; + @Override public void execute() throws MojoExecutionException { if (skip) { getLog().debug("Skipping execution"); return; } - Collection dependenciesWithExclusions = project.getDependencies().stream() - .filter(dep -> !dep.getExclusions().isEmpty()) - .collect(toList()); + + projectModelId = project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(); + + Map> dependenciesWithExclusions = new HashMap<>(); + + project.getDependencyManagement().getDependencies().forEach(dependency -> { + Collection exclusions = getExclusionsForDependency(dependency); + if (!exclusions.isEmpty()) { + dependenciesWithExclusions + .computeIfAbsent(coordinates(dependency), d -> new ArrayList<>()) + .addAll(exclusions); + } + }); + + project.getDependencies().forEach(dependency -> { + Collection exclusions = getExclusionsForDependency(dependency); + if (!exclusions.isEmpty()) { + dependenciesWithExclusions + .computeIfAbsent(coordinates(dependency), d -> new ArrayList<>()) + .addAll(exclusions); + } + }); if (dependenciesWithExclusions.isEmpty()) { getLog().debug("No dependencies defined with exclusions - exiting"); @@ -98,14 +125,14 @@ public void execute() throws MojoExecutionException { ArtifactTypeRegistry artifactTypeRegistry = session.getRepositorySession().getArtifactTypeRegistry(); - for (final Dependency dependency : dependenciesWithExclusions) { + for (Map.Entry> entry : dependenciesWithExclusions.entrySet()) { - Coordinates currentCoordinates = coordinates(dependency.getGroupId(), dependency.getArtifactId()); + Coordinates currentCoordinates = entry.getKey(); Collection actualDependencies = null; try { - actualDependencies = - resolverUtil.collectDependencies(RepositoryUtils.toDependency(dependency, artifactTypeRegistry) + actualDependencies = resolverUtil.collectDependencies( + RepositoryUtils.toDependency(currentCoordinates.getDependency(), artifactTypeRegistry) .setExclusions(null)); } catch (DependencyCollectionException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -116,9 +143,8 @@ public void execute() throws MojoExecutionException { .map(a -> coordinates(a.getGroupId(), a.getArtifactId())) .collect(toSet()); - Set exclusions = dependency.getExclusions().stream() - .map(e -> coordinates(e.getGroupId(), e.getArtifactId())) - .collect(toSet()); + Set exclusions = + entry.getValue().stream().map(Coordinates::coordinates).collect(toSet()); checker.check(currentCoordinates, exclusions, actualCoordinates); } @@ -130,13 +156,26 @@ public void execute() throws MojoExecutionException { } else { logViolations(project.getName(), checker.getViolations(), value -> getLog().warn(value)); } + } else { + getLog().info("No problems with dependencies exclusions"); } } + private Collection getExclusionsForDependency(Dependency dependency) { + return dependency.getExclusions().stream() + .filter(this::isExclusionInProject) + .collect(toList()); + } + + private boolean isExclusionInProject(Exclusion exclusion) { + String modelId = exclusion.getLocation("").getSource().getModelId(); + return projectModelId.equals(modelId); + } + private void logViolations(String name, Map> violations, Consumer logger) { logger.accept(name + " defines following unnecessary excludes"); violations.forEach((dependency, invalidExclusions) -> { - logger.accept(" " + dependency + ":"); + logger.accept(" " + dependency); invalidExclusions.forEach(invalidExclusion -> logger.accept(" - " + invalidExclusion)); }); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java index cb4a042ec..d81f7b37b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/Coordinates.java @@ -25,23 +25,43 @@ import java.util.Objects; import java.util.function.Predicate; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; +import org.apache.maven.model.InputLocation; + /** * Simple "record" to hold the coordinates of the dependency which is excluded. *

* When dealing with exclusions the version is not important. Only groupId and artifactId is used. *

*/ -class Coordinates { +class Coordinates implements Comparable { + private final String groupId; + private final String artifactId; - private Coordinates(String groupId, String artifactId) { + private final Dependency dependency; + + private final InputLocation location; + + private Coordinates(String groupId, String artifactId, Dependency dependency, InputLocation location) { this.groupId = groupId; this.artifactId = artifactId; + this.dependency = dependency; + this.location = location; } public static Coordinates coordinates(String groupId, String artifactId) { - return new Coordinates(groupId, artifactId); + return new Coordinates(groupId, artifactId, null, null); + } + + public static Coordinates coordinates(Dependency dependency) { + return new Coordinates(dependency.getGroupId(), dependency.getArtifactId(), dependency, null); + } + + public static Coordinates coordinates(Exclusion exclusion) { + return new Coordinates(exclusion.getGroupId(), exclusion.getArtifactId(), null, exclusion.getLocation("")); } public String getGroupId() { @@ -52,6 +72,10 @@ public String getArtifactId() { return artifactId; } + public Dependency getDependency() { + return dependency; + } + Predicate getExclusionPattern() { PathMatcher groupId = FileSystems.getDefault().getPathMatcher("glob:" + getGroupId()); PathMatcher artifactId = FileSystems.getDefault().getPathMatcher("glob:" + getArtifactId()); @@ -86,16 +110,36 @@ public boolean equals(Object o) { return false; } Coordinates that = (Coordinates) o; - return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId); + return Objects.equals(groupId, that.groupId) + && Objects.equals(artifactId, that.artifactId) + && Objects.equals(location, that.location); } @Override public int hashCode() { - return Objects.hash(groupId, artifactId); + return Objects.hash(groupId, artifactId, location); + } + + @Override + public int compareTo(Coordinates that) { + + if (location != null && that.location != null) { + return location.getLineNumber() - that.location.getLineNumber(); + } + + return toString().compareTo(that.toString()); } @Override public String toString() { - return groupId + ":" + artifactId; + String version = ""; + if (dependency != null) { + version = ":" + dependency.getVersion(); + } + String line = ""; + if (location != null) { + line = " @ line: " + location.getLineNumber(); + } + return groupId + ":" + artifactId + version + line; } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java index 7219cdee3..1340461b7 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/ExclusionChecker.java @@ -18,16 +18,16 @@ */ package org.apache.maven.plugins.dependency.exclusion; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import static java.util.stream.Collectors.toList; class ExclusionChecker { - private final Map> violations = new HashMap<>(); + private final Map> violations = new TreeMap<>(); Map> getViolations() { return violations; @@ -36,6 +36,7 @@ Map> getViolations() { void check(Coordinates artifact, Set excludes, Set actualDependencies) { List invalidExclusions = excludes.stream() .filter(exclude -> actualDependencies.stream().noneMatch(exclude.getExclusionPattern())) + .sorted() .collect(toList()); if (!invalidExclusions.isEmpty()) { diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index 10ce18441..231871cf3 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -32,6 +32,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; +import org.apache.maven.model.InputLocation; +import org.apache.maven.model.InputSource; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; @@ -63,6 +65,10 @@ public void setUp() throws Exception { project = new DependencyProjectStub(); project.setName("projectName"); + project.setGroupId("testGroupId"); + project.setArtifactId("testArtifactId"); + project.setVersion("1.0.0"); + getContainer().addComponent(project, MavenProject.class.getName()); MavenSession session = newMavenSession(project); @@ -192,6 +198,7 @@ private Dependency dependency(String groupId, String artifactId) { dependency.setScope("compile"); dependency.setType("jar"); dependency.setClassifier(""); + dependency.setLocation("", new InputLocation(1, 1)); return dependency; } @@ -203,6 +210,7 @@ private Dependency dependency(String groupId, String artifactId, String scope, S dependency.setScope(scope); dependency.setType("jar"); dependency.setClassifier(classifier); + dependency.setLocation("", new InputLocation(1, 1)); return dependency; } @@ -210,6 +218,9 @@ private Exclusion exclusion(String groupId, String artifactId) { Exclusion exclusion = new Exclusion(); exclusion.setGroupId(groupId); exclusion.setArtifactId(artifactId); + InputSource inputSource = new InputSource(); + inputSource.setModelId("testGroupId:testArtifactId:1.0.0"); + exclusion.setLocation("", new InputLocation(1, 1, inputSource)); return exclusion; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java index 857fd6f66..70a424111 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java @@ -54,7 +54,7 @@ public void shallReportInvalidExclusions() { assertThat(checker.getViolations()) .containsEntry( artifact, - Arrays.asList(coordinates("com.example", "two"), coordinates("com.example", "three"))); + Arrays.asList(coordinates("com.example", "three"), coordinates("com.example", "two"))); } @Test From 16fa0a4dc636cafc6ba5947a34df7cdb2ebf4782 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 21 Apr 2024 13:13:29 +0200 Subject: [PATCH 101/283] [MDEP-923] Code cleanups - remove usage of deprecated API where possible - cleanup pom after update to 42 - exclude transitive dependencies on org.apache.maven - add project.version in ITs --- .gitignore | 3 - pom.xml | 37 ++- .../pom.xml | 1 + .../analyze-ignore-dependency/pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../verify.groovy | 6 +- .../pom.xml | 1 + src/it/projects/analyze/pom.xml | 1 + src/it/projects/analyze/verify.groovy | 30 +-- .../copy-from-reactor/child-b/pom.xml | 1 + src/it/projects/filterunpack/verify.groovy | 6 +- .../projects/list-repositories/verify.groovy | 14 +- .../projects/mdep-439-analyze-java8/pom.xml | 2 +- .../verify.groovy | 10 +- .../verify.groovy | 10 +- .../mdep-571-resolve-java9/verify.groovy | 10 +- .../child1/pom.xml | 2 +- .../verify.groovy | 14 +- .../verify.groovy | 10 +- .../verify.groovy | 4 +- .../projects/mdep-599-analyze-java9/pom.xml | 2 +- .../pom.xml | 1 + .../verify.groovy | 12 +- .../pom.xml | 2 +- .../pom.xml | 1 + .../verify.groovy | 10 +- .../pom.xml | 1 + .../verify.groovy | 16 +- .../verify.groovy | 12 +- .../pom.xml | 2 +- .../verify.groovy | 18 +- .../verify.groovy | 24 +- .../verify.groovy | 16 +- .../verify.groovy | 10 +- .../purge-local-repository/verify.groovy | 14 +- .../child-b/pom.xml | 1 + .../verify.groovy | 2 +- .../verify.groovy | 2 +- .../setup-custom-ear-lifecycle/plugin/pom.xml | 4 +- .../setup-custom-ear-lifecycle/pom.xml | 2 +- .../verify.groovy | 6 +- .../unpack-dependencies/verify.groovy | 6 +- .../projects/used-dependencies/module/pom.xml | 1 + src/it/projects/used-dependencies/pom.xml | 2 +- .../dependency/ListRepositoriesMojo.java | 5 +- .../dependency/PurgeLocalRepositoryMojo.java | 8 +- .../analyze/AbstractAnalyzeMojo.java | 2 +- .../analyze/AnalyzeDuplicateMojo.java | 4 +- .../exclusion/AnalyzeExclusionsMojo.java | 2 +- .../resolvers/ResolveDependenciesMojo.java | 4 +- .../utils/filters/DestFileFilter.java | 2 +- .../markers/UnpackFileMarkerHandler.java | 2 +- src/site/apt/index.apt.vm | 2 +- .../AbstractDependencyMojoTestCase.java | 2 +- .../analyze/TestAnalyzeDuplicateMojo.java | 16 +- .../exclusion/AnalyzeExclusionsMojoTest.java | 18 +- .../exclusion/ExclusionCheckerTest.java | 9 +- .../TestBuildClasspathMojo.java | 4 +- .../TestUnpackDependenciesMojo.java | 38 +-- ...deReactorProjectsDependencyFilterTest.java | 65 ++--- .../DependencyArtifactStubFactory.java | 7 +- .../stubs/DependencyProjectStub.java | 233 +++++++++++++----- .../utils/filters/TestDestFileFilter.java | 4 +- .../filters/TestResolveMarkerFileFilter.java | 3 - 66 files changed, 429 insertions(+), 334 deletions(-) diff --git a/.gitignore b/.gitignore index bc313a1fe..c1b42ca0f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,5 @@ out/ /dependencies.xml .java-version .checkstyle -# This file is being created by Mock Repository Manager -# during integration tests -src/it/mrm/repository/_ResourceArtifact-1.0.jar /dependency-reduced-pom.xml .factorypath diff --git a/pom.xml b/pom.xml index 0bd36a274..1ea2e19c6 100644 --- a/pom.xml +++ b/pom.xml @@ -95,8 +95,6 @@ under the License. 2023-10-20T21:21:50Z 1.7.36 4.9.2 - - 3.11.0 @@ -181,6 +179,10 @@ under the License. org.codehaus.plexus plexus-container-default
+ + org.apache.maven + * +
@@ -226,11 +228,23 @@ under the License. org.apache.maven.shared maven-dependency-analyzer 1.13.2 + + + org.apache.maven + * + + org.apache.maven.shared maven-dependency-tree 3.2.1 + + + org.apache.maven + * + + org.apache.maven.shared @@ -241,6 +255,12 @@ under the License. org.apache.maven.shared maven-artifact-transfer 0.13.1 + + + org.apache.maven + * + + org.apache.maven.shared @@ -258,6 +278,7 @@ under the License. javax.inject javax.inject 1 + provided @@ -402,13 +423,6 @@ under the License.
- - org.apache.maven.plugins - maven-checkstyle-plugin - - config/maven_checks_nocodestyle.xml - - @@ -418,9 +432,6 @@ under the License. -Xmx512m - - ${maven.home} - @@ -454,7 +465,6 @@ under the License. src/it/mrm/settings.xml - ${repository.proxy.url} 3.11.0 @@ -476,6 +486,7 @@ under the License. src/it/mrm/repository + ${project.build.directory}/mock-repo ${project.build.directory}/local-repo diff --git a/src/it/projects/analyze-ignore-all-non-test-scope-dependency/pom.xml b/src/it/projects/analyze-ignore-all-non-test-scope-dependency/pom.xml index a762b0b69..3bf859f54 100644 --- a/src/it/projects/analyze-ignore-all-non-test-scope-dependency/pom.xml +++ b/src/it/projects/analyze-ignore-all-non-test-scope-dependency/pom.xml @@ -49,6 +49,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze-ignore-dependency/pom.xml b/src/it/projects/analyze-ignore-dependency/pom.xml index c802f08e5..20aba9f99 100644 --- a/src/it/projects/analyze-ignore-dependency/pom.xml +++ b/src/it/projects/analyze-ignore-dependency/pom.xml @@ -49,6 +49,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze-ignore-non-test-scope-dependency/pom.xml b/src/it/projects/analyze-ignore-non-test-scope-dependency/pom.xml index 34cb9fed0..a97bfbce7 100644 --- a/src/it/projects/analyze-ignore-non-test-scope-dependency/pom.xml +++ b/src/it/projects/analyze-ignore-non-test-scope-dependency/pom.xml @@ -49,6 +49,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze-ignore-unused-declared-dependency/pom.xml b/src/it/projects/analyze-ignore-unused-declared-dependency/pom.xml index 650fb6304..c8fd5bcd5 100644 --- a/src/it/projects/analyze-ignore-unused-declared-dependency/pom.xml +++ b/src/it/projects/analyze-ignore-unused-declared-dependency/pom.xml @@ -49,6 +49,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze-ignore-used-undeclared-dependency/pom.xml b/src/it/projects/analyze-ignore-used-undeclared-dependency/pom.xml index 0fa6d51c6..281cb3b59 100644 --- a/src/it/projects/analyze-ignore-used-undeclared-dependency/pom.xml +++ b/src/it/projects/analyze-ignore-used-undeclared-dependency/pom.xml @@ -49,6 +49,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy index 8b798d26c..b052186e5 100644 --- a/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy +++ b/src/it/projects/analyze-invalid-exclude-multumodule-project/verify.groovy @@ -1,5 +1,3 @@ -import java.lang.reflect.Array - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -30,8 +28,8 @@ static void checkMessagedInLogs(logLines, messages) { } -def file = new File(basedir, "build.log"); -assert file.exists(); +def file = new File(basedir, "build.log") +assert file.exists() def logLines = buildLog = file.readLines() diff --git a/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml b/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml index 22c2be078..89dbdefe3 100644 --- a/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml +++ b/src/it/projects/analyze-testDependencyWithNonTestScope/pom.xml @@ -36,6 +36,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze/pom.xml b/src/it/projects/analyze/pom.xml index fc13441d4..013a97988 100644 --- a/src/it/projects/analyze/pom.xml +++ b/src/it/projects/analyze/pom.xml @@ -59,6 +59,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/analyze/verify.groovy b/src/it/projects/analyze/verify.groovy index 0ff117d26..085cf324b 100644 --- a/src/it/projects/analyze/verify.groovy +++ b/src/it/projects/analyze/verify.groovy @@ -17,25 +17,25 @@ * under the License. */ -File classFile = new File( basedir, "target/classes/Main.class" ); -assert classFile.exists(); +File classFile = new File( basedir, "target/classes/Main.class" ) +assert classFile.exists() if ( !classFile.isFile() ) { - throw new Exception( "Build was not forked, class missing " + classFile ); + throw new Exception( "Build was not forked, class missing " + classFile ) } -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( '[INFO] Used declared dependencies found:'); -assert buildLog.contains( '[INFO] org.apache.maven:maven-artifact:jar:2.0.6:compile'); -assert buildLog.contains( '[INFO] org.apache.maven:maven-model:jar:2.0.6:compile'); -assert buildLog.contains( '[WARNING] Used undeclared dependencies found:'); -assert buildLog.contains( '[WARNING] org.apache.maven:maven-repository-metadata:jar:2.0.6:compile'); -assert buildLog.contains( '[WARNING] class org.apache.maven.artifact.repository.metadata.Metadata'); -assert buildLog.contains( '[WARNING] Unused declared dependencies found:'); -assert buildLog.contains( '[WARNING] org.apache.maven:maven-project:jar:2.0.6:compile'); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( '[INFO] Used declared dependencies found:') +assert buildLog.contains( '[INFO] org.apache.maven:maven-artifact:jar:2.0.6:compile') +assert buildLog.contains( '[INFO] org.apache.maven:maven-model:jar:2.0.6:compile') +assert buildLog.contains( '[WARNING] Used undeclared dependencies found:') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-repository-metadata:jar:2.0.6:compile') +assert buildLog.contains( '[WARNING] class org.apache.maven.artifact.repository.metadata.Metadata') +assert buildLog.contains( '[WARNING] Unused declared dependencies found:') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-project:jar:2.0.6:compile') -return true; +return true diff --git a/src/it/projects/copy-from-reactor/child-b/pom.xml b/src/it/projects/copy-from-reactor/child-b/pom.xml index 891439ab5..6ef74e860 100644 --- a/src/it/projects/copy-from-reactor/child-b/pom.xml +++ b/src/it/projects/copy-from-reactor/child-b/pom.xml @@ -52,6 +52,7 @@ maven-dependency-plugin + @project.version@ test diff --git a/src/it/projects/filterunpack/verify.groovy b/src/it/projects/filterunpack/verify.groovy index 330e6aa30..8ed2f2517 100644 --- a/src/it/projects/filterunpack/verify.groovy +++ b/src/it/projects/filterunpack/verify.groovy @@ -24,7 +24,7 @@ for (item in expected) def file = new File(basedir, 'target/dependency' + item) if (!file.exists()) { - throw new RuntimeException("Missing "+file.name); + throw new RuntimeException("Missing "+file.name) } } @@ -35,8 +35,8 @@ for (item in notExpected) def file = new File(basedir, 'target/dependency' + item) if (file.exists()) { - throw new RuntimeException("This file shouldn't be here: "+file.name); + throw new RuntimeException("This file shouldn't be here: "+file.name) } } -return true; +return true diff --git a/src/it/projects/list-repositories/verify.groovy b/src/it/projects/list-repositories/verify.groovy index be64953d9..b14fc5b43 100644 --- a/src/it/projects/list-repositories/verify.groovy +++ b/src/it/projects/list-repositories/verify.groovy @@ -17,12 +17,12 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( 'Project remote repositories used by this build:'); -assert buildLog.contains( '* fake-remote-repository (http://localhost:2345, default, releases+snapshots)'); -assert buildLog.contains( '* sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots) mirrored by mrm-maven-plugin'); -assert buildLog.contains( '* central (https://repo.maven.apache.org/maven2, default, releases) mirrored by mrm-maven-plugin'); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'Project remote repositories used by this build:') +assert buildLog.contains( '* fake-remote-repository (http://localhost:2345, default, releases+snapshots)') +assert buildLog.contains( '* sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots) mirrored by mrm-maven-plugin') +assert buildLog.contains( '* central (https://repo.maven.apache.org/maven2, default, releases) mirrored by mrm-maven-plugin') diff --git a/src/it/projects/mdep-439-analyze-java8/pom.xml b/src/it/projects/mdep-439-analyze-java8/pom.xml index f7e34ebf7..7d00e9c1a 100644 --- a/src/it/projects/mdep-439-analyze-java8/pom.xml +++ b/src/it/projects/mdep-439-analyze-java8/pom.xml @@ -56,7 +56,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ 1.8 1.8 diff --git a/src/it/projects/mdep-450-project-with-ancestor/verify.groovy b/src/it/projects/mdep-450-project-with-ancestor/verify.groovy index 19a18cedc..0d48aaba5 100644 --- a/src/it/projects/mdep-450-project-with-ancestor/verify.groovy +++ b/src/it/projects/mdep-450-project-with-ancestor/verify.groovy @@ -17,10 +17,10 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( 'Ancestor POMs: org.apache:apache:5' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'Ancestor POMs: org.apache:apache:5' ) -return true; +return true diff --git a/src/it/projects/mdep-450-project-without-ancestor/verify.groovy b/src/it/projects/mdep-450-project-without-ancestor/verify.groovy index fd0afd7f5..15bbe6625 100644 --- a/src/it/projects/mdep-450-project-without-ancestor/verify.groovy +++ b/src/it/projects/mdep-450-project-without-ancestor/verify.groovy @@ -17,10 +17,10 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( 'No Ancestor POMs!' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'No Ancestor POMs!' ) -return true; +return true diff --git a/src/it/projects/mdep-571-resolve-java9/verify.groovy b/src/it/projects/mdep-571-resolve-java9/verify.groovy index e93e874c9..2fe1f641b 100644 --- a/src/it/projects/mdep-571-resolve-java9/verify.groovy +++ b/src/it/projects/mdep-571-resolve-java9/verify.groovy @@ -17,10 +17,10 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( 'org.slf4j:slf4j-api:jar:1.7.6:compile -- module' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'org.slf4j:slf4j-api:jar:1.7.6:compile -- module' ) -return true; +return true diff --git a/src/it/projects/mdep-572-unpack-tar-long-file/child1/pom.xml b/src/it/projects/mdep-572-unpack-tar-long-file/child1/pom.xml index 93a49d7dd..ba478bab9 100644 --- a/src/it/projects/mdep-572-unpack-tar-long-file/child1/pom.xml +++ b/src/it/projects/mdep-572-unpack-tar-long-file/child1/pom.xml @@ -32,7 +32,7 @@ under the License. maven-assembly-plugin - 3.0.0 + @version.maven-assembly-plugin@ diff --git a/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy b/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy index 7bfaa91db..c1e00cac0 100644 --- a/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy +++ b/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy @@ -17,20 +17,20 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); +String buildLog = file.getText( "UTF-8" ) // Cause message is JDK specific and can change over time // JDOMAbout$Author.class found in top-level directory (unnamed package not allowed in module) -assert buildLog.contains( "Can't extract module name from jdom-1.0.jar: " ); +assert buildLog.contains( "Can't extract module name from jdom-1.0.jar: " ) // geronimo.servlet.2.4.spec: Invalid module name: '2' is not a Java identifier -assert buildLog.contains( "Can't extract module name from geronimo-servlet_2.4_spec-1.1.1.jar: " ); +assert buildLog.contains( "Can't extract module name from geronimo-servlet_2.4_spec-1.1.1.jar: " ) // geronimo.jta.1.1.spec: Invalid module name: '1' is not a Java identifier -assert buildLog.contains( "Can't extract module name from geronimo-jta_1.1_spec-1.1.jar: " ); +assert buildLog.contains( "Can't extract module name from geronimo-jta_1.1_spec-1.1.jar: " ) -return true; +return true diff --git a/src/it/projects/mdep-580_display-manifest-automodules/verify.groovy b/src/it/projects/mdep-580_display-manifest-automodules/verify.groovy index 20b88d711..539131bfa 100644 --- a/src/it/projects/mdep-580_display-manifest-automodules/verify.groovy +++ b/src/it/projects/mdep-580_display-manifest-automodules/verify.groovy @@ -17,11 +17,11 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); +String buildLog = file.getText( "UTF-8" ) -assert buildLog.contains( "org.apache.maven.resolver:maven-resolver-api:jar:1.1.0:compile -- module org.apache.maven.resolver [auto]" ); +assert buildLog.contains( "org.apache.maven.resolver:maven-resolver-api:jar:1.1.0:compile -- module org.apache.maven.resolver [auto]" ) -return true; +return true diff --git a/src/it/projects/mdep-586-unpacking-resources/verify.groovy b/src/it/projects/mdep-586-unpacking-resources/verify.groovy index a35849839..991b88b00 100644 --- a/src/it/projects/mdep-586-unpacking-resources/verify.groovy +++ b/src/it/projects/mdep-586-unpacking-resources/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.isFile(); +File file = new File( basedir, "build.log" ) +assert file.isFile() File file1 = new File( basedir, "resources1/resource1.txt" ) assert file1.isFile() diff --git a/src/it/projects/mdep-599-analyze-java9/pom.xml b/src/it/projects/mdep-599-analyze-java9/pom.xml index 9a8b66574..cc5103af1 100644 --- a/src/it/projects/mdep-599-analyze-java9/pom.xml +++ b/src/it/projects/mdep-599-analyze-java9/pom.xml @@ -37,7 +37,7 @@ org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ diff --git a/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/pom.xml b/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/pom.xml index 16eae6740..36f8bc84f 100644 --- a/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/pom.xml +++ b/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/pom.xml @@ -45,6 +45,7 @@ under the License. maven-dependency-plugin + @project.version@ true diff --git a/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/verify.groovy b/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/verify.groovy index e3ff35309..3959742e1 100644 --- a/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/verify.groovy +++ b/src/it/projects/mdep-602-log-on-error-level-when-failOnWarning/verify.groovy @@ -17,11 +17,11 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( '[ERROR] Unused declared dependencies found:'); -assert buildLog.contains( '[ERROR] org.apache.maven:maven-project:jar:2.0.6:compile' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( '[ERROR] Unused declared dependencies found:') +assert buildLog.contains( '[ERROR] org.apache.maven:maven-project:jar:2.0.6:compile' ) -return true; +return true diff --git a/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml b/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml index 11d31c278..58ed74d9e 100644 --- a/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml +++ b/src/it/projects/mdep-663_analyze_unsupported_version/pom.xml @@ -36,7 +36,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + @version.maven-compiler-plugin@ ${java.specification.version} diff --git a/src/it/projects/mdep-714-analyze-ignore-unused-runtime/pom.xml b/src/it/projects/mdep-714-analyze-ignore-unused-runtime/pom.xml index 15afd8dc2..a1f76cccf 100644 --- a/src/it/projects/mdep-714-analyze-ignore-unused-runtime/pom.xml +++ b/src/it/projects/mdep-714-analyze-ignore-unused-runtime/pom.xml @@ -50,6 +50,7 @@ maven-dependency-plugin + @project.version@ true true diff --git a/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy b/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy index fcc7dc004..dded7be02 100644 --- a/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy +++ b/src/it/projects/mdep-739-go-offline-respect-classifiers/verify.groovy @@ -17,10 +17,10 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( 'Resolved dependency: spring-cloud-stream-3.1.2-test-binder.jar' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'Resolved dependency: spring-cloud-stream-3.1.2-test-binder.jar' ) -return true; +return true diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml index 8fa4df173..a07d01e71 100644 --- a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml +++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/pom.xml @@ -46,6 +46,7 @@ maven-dependency-plugin + @project.version@ true diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy index 392d161a7..cacac0aa5 100644 --- a/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy +++ b/src/it/projects/mdep-752-analyze-ignored-packaging-custom/verify.groovy @@ -17,14 +17,14 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); +String buildLog = file.getText( "UTF-8" ) // custom configuration for ignoredPackagings should be applied to Mojo -assert buildLog.contains( 'ignoredPackagings = [pom, ear, ejb]' ); -assert buildLog.contains( '[INFO] Skipping pom project' ); -assert buildLog.contains( '[INFO] Skipping ear project' ); -assert buildLog.contains( '[INFO] Skipping ejb project' ); +assert buildLog.contains( 'ignoredPackagings = [pom, ear, ejb]' ) +assert buildLog.contains( '[INFO] Skipping pom project' ) +assert buildLog.contains( '[INFO] Skipping ear project' ) +assert buildLog.contains( '[INFO] Skipping ejb project' ) -return true; +return true diff --git a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy index 2de46b262..b585e5d67 100644 --- a/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy +++ b/src/it/projects/mdep-752-analyze-ignored-packaging-defaults/verify.groovy @@ -17,11 +17,11 @@ * under the License. */ -File file = new File( basedir, "build.log" ); -assert file.exists(); +File file = new File( basedir, "build.log" ) +assert file.exists() -String buildLog = file.getText( "UTF-8" ); -assert buildLog.contains( '[INFO] Skipping pom project' ); -assert buildLog.contains( '[INFO] Skipping ear project' ); +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( '[INFO] Skipping pom project' ) +assert buildLog.contains( '[INFO] Skipping ear project' ) -return true; +return true diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml index c32e272d4..74504df21 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml @@ -42,7 +42,7 @@ maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ 8 8 diff --git a/src/it/projects/purge-local-repository-bad-dep/verify.groovy b/src/it/projects/purge-local-repository-bad-dep/verify.groovy index 0e7767633..65b44f164 100644 --- a/src/it/projects/purge-local-repository-bad-dep/verify.groovy +++ b/src/it/projects/purge-local-repository-bad-dep/verify.groovy @@ -19,19 +19,19 @@ void checkFilePresence( String path ) { - File depJar = new File( localRepositoryPath, path ); + File depJar = new File( localRepositoryPath, path ) if ( !depJar.exists() ) { - throw new Exception( "Direct dependency jar was not re-resolved: " + depJar ); + throw new Exception( "Direct dependency jar was not re-resolved: " + depJar ) } } -checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); -checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ); +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ) +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ) -String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); -assert buildLog.contains( 'Unable to resolve artifact: org.apache.maven.its.dependency:i-do-not-exist:jar:1.0' ); -assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); -assert buildLog.contains( 'Resolving artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ) +assert buildLog.contains( 'Unable to resolve artifact: org.apache.maven.its.dependency:i-do-not-exist:jar:1.0' ) +assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ) +assert buildLog.contains( 'Resolving artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ) -return true; +return true diff --git a/src/it/projects/purge-local-repository-include/verify.groovy b/src/it/projects/purge-local-repository-include/verify.groovy index 41104d735..baabe8f71 100644 --- a/src/it/projects/purge-local-repository-include/verify.groovy +++ b/src/it/projects/purge-local-repository-include/verify.groovy @@ -19,30 +19,30 @@ void checkFilePresence( String path ) { - File depJar = new File( localRepositoryPath, path ); + File depJar = new File( localRepositoryPath, path ) if ( !depJar.exists() ) { - throw new Exception( "Dependency jar was not re-resolved: " + depJar ); + throw new Exception( "Dependency jar was not re-resolved: " + depJar ) } } void checkFileAbsence( String path ) { - File depJar = new File( localRepositoryPath, path ); + File depJar = new File( localRepositoryPath, path ) if ( depJar.exists() ) { - throw new Exception( "Dependency jar was not purged: " + depJar ); + throw new Exception( "Dependency jar was not purged: " + depJar ) } } -checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); -checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ); +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ) +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ) -checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.jar" ); -checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.pom" ); +checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.jar" ) +checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.pom" ) -String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); -assert !buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); -assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository-2:jar:1.0' ); +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ) +assert !buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ) +assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository-2:jar:1.0' ) -return true; +return true diff --git a/src/it/projects/purge-local-repository-multi-module/verify.groovy b/src/it/projects/purge-local-repository-multi-module/verify.groovy index 81fd494cd..03177852f 100644 --- a/src/it/projects/purge-local-repository-multi-module/verify.groovy +++ b/src/it/projects/purge-local-repository-multi-module/verify.groovy @@ -19,17 +19,17 @@ void checkFileAbsence( String path ) { - File depJar = new File( localRepositoryPath, path ); + File depJar = new File( localRepositoryPath, path ) if ( depJar.exists() ) { - throw new Exception( "Dependency jar was not purged: " + depJar ); + throw new Exception( "Dependency jar was not purged: " + depJar ) } } -checkFileAbsence("purged-a" ); -checkFileAbsence("purged-b" ); +checkFileAbsence("purged-a" ) +checkFileAbsence("purged-b" ) -String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); -assert buildLog.contains( 'Deleting 1 transitive dependency for project child1 from ' ); -assert buildLog.contains( 'Deleting 1 transitive dependency for project child2 from ' ); -assert buildLog.contains( 'with artifact version resolution fuzziness' ); +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ) +assert buildLog.contains( 'Deleting 1 transitive dependency for project child1 from ' ) +assert buildLog.contains( 'Deleting 1 transitive dependency for project child2 from ' ) +assert buildLog.contains( 'with artifact version resolution fuzziness' ) diff --git a/src/it/projects/purge-local-repository-without-pom/verify.groovy b/src/it/projects/purge-local-repository-without-pom/verify.groovy index 409e6bcaa..4d0df7374 100644 --- a/src/it/projects/purge-local-repository-without-pom/verify.groovy +++ b/src/it/projects/purge-local-repository-without-pom/verify.groovy @@ -19,14 +19,14 @@ void checkFileAbsence( String path ) { - File depJar = new File( localRepositoryPath, path ); + File depJar = new File( localRepositoryPath, path ) if ( depJar.exists() ) { - throw new Exception( "Dependency jar was not purged: " + depJar ); + throw new Exception( "Dependency jar was not purged: " + depJar ) } } -checkFileAbsence( "org/apache/maven/its/dependency/purged-without-pom/1.0/purged-without-pom-1.0.jar" ); +checkFileAbsence( "org/apache/maven/its/dependency/purged-without-pom/1.0/purged-without-pom-1.0.jar" ) -String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); -assert buildLog.contains( 'Deleting 1 manual dependency from ' ); +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ) +assert buildLog.contains( 'Deleting 1 manual dependency from ' ) diff --git a/src/it/projects/purge-local-repository/verify.groovy b/src/it/projects/purge-local-repository/verify.groovy index ffb1734c3..1ee8ed0de 100644 --- a/src/it/projects/purge-local-repository/verify.groovy +++ b/src/it/projects/purge-local-repository/verify.groovy @@ -19,16 +19,16 @@ void checkFileAbsence( String path ) { - File depJar = new File( localRepositoryPath, path ); - System.out.println( "Checking for absence of dummy JAR " + depJar ); + File depJar = new File( localRepositoryPath, path ) + System.out.println( "Checking for absence of dummy JAR " + depJar ) if ( depJar.exists() ) { - throw new Exception( "Dependency jar was not purged: " + depJar ); + throw new Exception( "Dependency jar was not purged: " + depJar ) } } -checkFileAbsence( "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); +checkFileAbsence( "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ) -String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); -assert buildLog.contains( 'Deleting 1 transitive dependency for project test from ' ); -assert buildLog.contains( 'with artifact version resolution fuzziness' ); +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ) +assert buildLog.contains( 'Deleting 1 transitive dependency for project test from ' ) +assert buildLog.contains( 'with artifact version resolution fuzziness' ) diff --git a/src/it/projects/resolve-plugins-exclude-reactor/child-b/pom.xml b/src/it/projects/resolve-plugins-exclude-reactor/child-b/pom.xml index 891439ab5..6ef74e860 100644 --- a/src/it/projects/resolve-plugins-exclude-reactor/child-b/pom.xml +++ b/src/it/projects/resolve-plugins-exclude-reactor/child-b/pom.xml @@ -52,6 +52,7 @@ maven-dependency-plugin + @project.version@ test diff --git a/src/it/projects/resolve-plugins-exclude-reactor/verify.groovy b/src/it/projects/resolve-plugins-exclude-reactor/verify.groovy index 4f7718f6d..540c60d58 100644 --- a/src/it/projects/resolve-plugins-exclude-reactor/verify.groovy +++ b/src/it/projects/resolve-plugins-exclude-reactor/verify.groovy @@ -23,4 +23,4 @@ new File(basedir, "target/resolved.txt").eachLine { line -> } } -return true; +return true diff --git a/src/it/projects/resolve-plugins-with-exclude/verify.groovy b/src/it/projects/resolve-plugins-with-exclude/verify.groovy index 90471f0f8..9b669b097 100644 --- a/src/it/projects/resolve-plugins-with-exclude/verify.groovy +++ b/src/it/projects/resolve-plugins-with-exclude/verify.groovy @@ -26,4 +26,4 @@ new File(basedir, "target/resolved.txt").eachLine { line -> } } -return true; +return true diff --git a/src/it/projects/setup-custom-ear-lifecycle/plugin/pom.xml b/src/it/projects/setup-custom-ear-lifecycle/plugin/pom.xml index ca1f9b3af..011ebf42b 100644 --- a/src/it/projects/setup-custom-ear-lifecycle/plugin/pom.xml +++ b/src/it/projects/setup-custom-ear-lifecycle/plugin/pom.xml @@ -41,7 +41,7 @@ under the License. org.apache.maven.plugins maven-plugin-plugin - 3.7.0 + @version.maven-plugin-tools@
@@ -75,7 +75,7 @@ under the License. org.apache.maven.plugin-tools maven-plugin-annotations - 3.7.0 + @version.maven-plugin-tools@ provided diff --git a/src/it/projects/setup-custom-ear-lifecycle/pom.xml b/src/it/projects/setup-custom-ear-lifecycle/pom.xml index b5a3448b4..ad10f6b31 100644 --- a/src/it/projects/setup-custom-ear-lifecycle/pom.xml +++ b/src/it/projects/setup-custom-ear-lifecycle/pom.xml @@ -32,7 +32,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ diff --git a/src/it/projects/unpack-dependencies-with-filemappers/verify.groovy b/src/it/projects/unpack-dependencies-with-filemappers/verify.groovy index de665cc1e..03edbd03c 100644 --- a/src/it/projects/unpack-dependencies-with-filemappers/verify.groovy +++ b/src/it/projects/unpack-dependencies-with-filemappers/verify.groovy @@ -24,7 +24,7 @@ for (item in expected) def file = new File(basedir, 'target/dependency/mapped/' + item) if (!file.exists()) { - throw new RuntimeException("Missing "+file.name); + throw new RuntimeException("Missing "+file.name) } } @@ -35,8 +35,8 @@ for (item in notExpected) def file = new File(basedir, 'target/dependency/' + item) if (file.exists()) { - throw new RuntimeException("This file shouldn't be here: "+file.name); + throw new RuntimeException("This file shouldn't be here: "+file.name) } } -return true; +return true diff --git a/src/it/projects/unpack-dependencies/verify.groovy b/src/it/projects/unpack-dependencies/verify.groovy index 665562965..dcd8104ba 100644 --- a/src/it/projects/unpack-dependencies/verify.groovy +++ b/src/it/projects/unpack-dependencies/verify.groovy @@ -24,7 +24,7 @@ for (item in expected) def file = new File(basedir, 'target/dependency/' + item) if (!file.exists()) { - throw new RuntimeException("Missing "+file.name); + throw new RuntimeException("Missing "+file.name) } } @@ -35,8 +35,8 @@ for (item in notExpected) def file = new File(basedir, 'target/dependency/' + item) if (file.exists()) { - throw new RuntimeException("This file shouldn't be here: "+file.name); + throw new RuntimeException("This file shouldn't be here: "+file.name) } } -return true; +return true diff --git a/src/it/projects/used-dependencies/module/pom.xml b/src/it/projects/used-dependencies/module/pom.xml index b954917f4..07c6608ec 100644 --- a/src/it/projects/used-dependencies/module/pom.xml +++ b/src/it/projects/used-dependencies/module/pom.xml @@ -39,6 +39,7 @@ maven-dependency-plugin + @project.version@ org.apache.maven.plugins.dependency:annotation diff --git a/src/it/projects/used-dependencies/pom.xml b/src/it/projects/used-dependencies/pom.xml index fe8f90367..17bb47a46 100644 --- a/src/it/projects/used-dependencies/pom.xml +++ b/src/it/projects/used-dependencies/pom.xml @@ -39,7 +39,7 @@ maven-dependency-plugin - @pom.version@ + @project.version@ true diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index 1a5a28f34..fa067ded4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -125,9 +125,8 @@ private void prepareRemoteMirrorRepositoriesList( StringBuilder message, Collection remoteProjectRepositories) { Map mirrorMap = new HashMap<>(); - remoteProjectRepositories.forEach(repo -> { - repo.getMirroredRepositories().forEach(mrepo -> mirrorMap.put(mrepo, repo)); - }); + remoteProjectRepositories.forEach( + repo -> repo.getMirroredRepositories().forEach(mrepo -> mirrorMap.put(mrepo, repo))); mirrorMap.forEach((repo, mirror) -> message.append(" * ") .append(repo) diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index 460e3c760..c678faf40 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -301,7 +301,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { manualIncludes = this.parseIncludes(manualInclude); } // If it's a manual purge, the only step is to delete from the local repo - if (manualIncludes != null && manualIncludes.size() > 0) { + if (manualIncludes != null && !manualIncludes.isEmpty()) { manualPurge(manualIncludes); return; } @@ -378,7 +378,7 @@ private void manualPurge(List theIncludes) throws MojoExecutionException .a(theIncludes.size() != 1 ? "dependencies" : "dependency") .a(" from ") .strong(localRepository.getBasedir()) - .toString()); + .build()); for (String gavPattern : theIncludes) { if (gavPattern == null || gavPattern.isEmpty()) { @@ -569,7 +569,7 @@ private void purgeArtifacts(MavenProject theProject, Set artifacts) { .a(" with artifact ") .strong(resolutionFuzziness) .a(" resolution fuzziness") - .toString()); + .build()); for (Artifact artifact : artifacts) { verbose("Purging artifact: " + artifact.getId()); @@ -622,7 +622,7 @@ private void reResolveArtifacts(MavenProject theProject, Set artifacts } } - if (missingArtifacts.size() > 0) { + if (!missingArtifacts.isEmpty()) { StringBuilder message = new StringBuilder("required artifacts missing:"); message.append(System.lineSeparator()); for (Artifact missingArtifact : missingArtifacts) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 54d8acd24..59b3ba3c8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -94,7 +94,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { /** * Ignore Runtime/Provided/Test/System scopes for unused dependency analysis. - * + *

* Non-test scoped list will be not affected. */ @Parameter(property = "ignoreNonCompile", defaultValue = "false") diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index a4c965df2..f5f6c6ea1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -38,7 +38,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** @@ -81,7 +81,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model; - try (Reader reader = ReaderFactory.newXmlReader(project.getFile())) { + try (Reader reader = new XmlStreamReader(project.getFile())) { model = pomReader.read(reader); } catch (IOException | XmlPullParserException e) { throw new MojoExecutionException("Exception: " + e.getMessage(), e); diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java index 3ad8d3b9b..7c6515674 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -129,7 +129,7 @@ public void execute() throws MojoExecutionException { Coordinates currentCoordinates = entry.getKey(); - Collection actualDependencies = null; + Collection actualDependencies; try { actualDependencies = resolverUtil.collectDependencies( RepositoryUtils.toDependency(currentCoordinates.getDependency(), artifactTypeRegistry) diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 423c467bf..3d023a823 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -278,7 +278,7 @@ private ModuleDescriptor getModuleDescriptor(File artifactFile) { } catch (ClassNotFoundException | SecurityException | IllegalAccessException | IllegalArgumentException e) { // do nothing } catch (NoSuchMethodException e) { - e.printStackTrace(); + getLog().warn(e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); while (cause.getCause() != null) { @@ -289,7 +289,7 @@ private ModuleDescriptor getModuleDescriptor(File artifactFile) { return moduleDescriptor; } - private class ModuleDescriptor { + private static class ModuleDescriptor { String name; boolean automatic = true; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 8c4dec7c3..46909a98f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -301,7 +301,7 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept /** * Using simply {@code File.getLastModified} will return sometimes a wrong value see JDK bug for details. - * + *

* https://bugs.openjdk.java.net/browse/JDK-8177809 * * @param file {@link File} diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 42cbe1c74..95684a3c4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -50,7 +50,7 @@ public UnpackFileMarkerHandler(ArtifactItem artifactItem, File markerFilesDirect @Override protected File getMarkerFile() { - /** + /* * Build a hash of all include/exclude strings, to determine if an artifactItem has been unpacked using the * include/exclude parameters, this will allow an artifact to be included multiple times with different * include/exclude parameters diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 86156343f..c223708ba 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -118,7 +118,7 @@ ${project.name} entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{./scm.html}source repository}} and will find supplementary information in the - {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. + {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 2f5bd7cf1..64ecd542a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -60,7 +60,7 @@ protected void tearDown() { FileUtils.deleteDirectory(testDir); } catch (IOException e) { e.printStackTrace(); - fail("Trying to remove directory:" + testDir + System.lineSeparator() + e.toString()); + fail("Trying to remove directory:" + testDir + System.lineSeparator() + e); } assertFalse(testDir.exists()); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java index c74d24ecf..339d2b646 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java @@ -72,7 +72,7 @@ public void testDuplicate2() throws Exception { assertTrue(log.getContent().contains("junit:junit:jar")); } - class DuplicateLog implements Log { + static class DuplicateLog implements Log { StringBuilder sb = new StringBuilder(); /** {@inheritDoc} */ @@ -132,8 +132,8 @@ public void error(CharSequence content, Throwable error) { error.printStackTrace(pWriter); - System.err.println("[error] " + content.toString() + System.lineSeparator() + System.lineSeparator() - + sWriter.toString()); + System.err.println( + "[error] " + content.toString() + System.lineSeparator() + System.lineSeparator() + sWriter); } /** @@ -145,7 +145,7 @@ public void error(Throwable error) { error.printStackTrace(pWriter); - System.err.println("[error] " + sWriter.toString()); + System.err.println("[error] " + sWriter); } /** @@ -191,11 +191,7 @@ private void print(String prefix, Throwable error) { error.printStackTrace(pWriter); - sb.append("[") - .append(prefix) - .append("] ") - .append(sWriter.toString()) - .append(System.lineSeparator()); + sb.append("[").append(prefix).append("] ").append(sWriter).append(System.lineSeparator()); } private void print(String prefix, CharSequence content, Throwable error) { @@ -210,7 +206,7 @@ private void print(String prefix, CharSequence content, Throwable error) { .append(content.toString()) .append(System.lineSeparator()) .append(System.lineSeparator()); - sb.append(sWriter.toString()).append(System.lineSeparator()); + sb.append(sWriter).append(System.lineSeparator()); } protected String getContent() { diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index 231871cf3..bbcc74857 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -132,9 +132,9 @@ public void testShallExitWithoutAnalyzeWhenNoDependencyHasExclusion() throws Exc public void testShallNotReportInvalidExclusionForWildcardGroupIdAndArtifactId() throws Exception { Dependency dependencyWithWildcardExclusion = dependency("a", "b"); dependencyWithWildcardExclusion.addExclusion(exclusion("*", "*")); - project.setDependencies(Arrays.asList(dependencyWithWildcardExclusion)); + project.setDependencies(Collections.singletonList(dependencyWithWildcardExclusion)); Artifact artifact = stubFactory.createArtifact("a", "b", "1.0"); - project.setArtifacts(new HashSet<>(Arrays.asList(artifact))); + project.setArtifacts(new HashSet<>(Collections.singletonList(artifact))); when(resolverUtil.collectDependencies(any())) .thenReturn(Collections.singletonList(new org.eclipse.aether.graph.Dependency( @@ -306,8 +306,8 @@ public void error(CharSequence content, Throwable error) { error.printStackTrace(pWriter); - System.err.println("[error] " + content.toString() + System.lineSeparator() + System.lineSeparator() - + sWriter.toString()); + System.err.println( + "[error] " + content.toString() + System.lineSeparator() + System.lineSeparator() + sWriter); } /** @@ -319,7 +319,7 @@ public void error(Throwable error) { error.printStackTrace(pWriter); - System.err.println("[error] " + sWriter.toString()); + System.err.println("[error] " + sWriter); } /** @@ -365,11 +365,7 @@ private void print(String prefix, Throwable error) { error.printStackTrace(pWriter); - sb.append("[") - .append(prefix) - .append("] ") - .append(sWriter.toString()) - .append(System.lineSeparator()); + sb.append("[").append(prefix).append("] ").append(sWriter).append(System.lineSeparator()); } private void print(String prefix, CharSequence content, Throwable error) { @@ -384,7 +380,7 @@ private void print(String prefix, CharSequence content, Throwable error) { .append(content.toString()) .append(System.lineSeparator()) .append(System.lineSeparator()); - sb.append(sWriter.toString()).append(System.lineSeparator()); + sb.append(sWriter).append(System.lineSeparator()); } protected String getContent() { diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java index 70a424111..ad97c810c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/ExclusionCheckerTest.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.exclusion; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -67,14 +68,14 @@ public void noViolationsWhenEmptyExclusions() { public void shallReportInvalidExclusionsWhenNoDependencies() { Coordinates artifact = coordinates("a", "b"); HashSet actualDependencies = new HashSet<>(); - checker.check(artifact, new HashSet<>(Arrays.asList(coordinates("p", "m"))), actualDependencies); - assertThat(checker.getViolations()).containsEntry(artifact, Arrays.asList(coordinates("p", "m"))); + checker.check(artifact, new HashSet<>(Collections.singletonList(coordinates("p", "m"))), actualDependencies); + assertThat(checker.getViolations()).containsEntry(artifact, Collections.singletonList(coordinates("p", "m"))); } @Test public void shallHandleWildcardExclusions() { Coordinates artifact = coordinates("com.current", "artifact"); - Set excludes = new HashSet<>(Arrays.asList(coordinates("*", "*"))); + Set excludes = new HashSet<>(Collections.singletonList(coordinates("*", "*"))); Set actualDependencies = new HashSet<>(Arrays.asList(coordinates("com.example", "one"), coordinates("com.example", "four"))); @@ -87,7 +88,7 @@ public void shallHandleWildcardExclusions() { @Test public void shallHandleWildcardGroupIdExclusion() { Coordinates artifact = coordinates("com.current", "artifact"); - Set excludes = new HashSet<>(Arrays.asList(coordinates("javax", "*"))); + Set excludes = new HashSet<>(Collections.singletonList(coordinates("javax", "*"))); Set actualDependencies = new HashSet<>(Arrays.asList( coordinates("com.example", "one"), diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index 3c6f3eb08..74d80b5bf 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -78,7 +78,7 @@ public void testEnvironment() throws Exception { String file = mojo.readClasspathFile(); assertNotNull(file); - assertTrue(file.length() > 0); + assertFalse(file.isEmpty()); assertTrue(file.contains(File.pathSeparator)); assertTrue(file.contains(File.separator)); @@ -92,7 +92,7 @@ public void testEnvironment() throws Exception { file = mojo.readClasspathFile(); assertNotNull(file); - assertTrue(file.length() > 0); + assertFalse(file.isEmpty()); assertFalse(file.contains(File.pathSeparator)); assertFalse(file.contains(File.separator)); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 44c7cbeb0..ab17a5030 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -127,7 +127,7 @@ public void assertMarkerFile(boolean val, Artifact artifact) { public void testMojo() throws Exception { mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -135,7 +135,7 @@ public void testMojo() throws Exception { public void testNoTransitive() throws Exception { mojo.excludeTransitive = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getDependencyArtifacts()) { + for (Artifact artifact : mojo.getProject().getDependencyArtifacts()) { assertUnpacked(artifact); } } @@ -146,7 +146,7 @@ public void testExcludeType() throws Exception { mojo.excludeTypes = "jar"; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!artifact.getType().equalsIgnoreCase("jar"), artifact); } } @@ -159,7 +159,7 @@ public void testExcludeProvidedScope() throws Exception { mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!artifact.getScope().equals("provided"), artifact); } } @@ -172,7 +172,7 @@ public void testExcludeSystemScope() throws Exception { mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!artifact.getScope().equals("system"), artifact); } } @@ -184,7 +184,7 @@ public void testExcludeCompileScope() throws Exception { mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!saf.include(artifact), artifact); } } @@ -209,7 +209,7 @@ public void testExcludeRuntimeScope() throws Exception { mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!saf.include(artifact), artifact); } } @@ -248,7 +248,7 @@ public void testSubPerType() throws Exception { mojo.useSubDirectoryPerType = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -257,7 +257,7 @@ public void testSubPerArtifact() throws Exception { mojo.useSubDirectoryPerArtifact = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -269,7 +269,7 @@ public void testSubPerArtifactAndType() throws Exception { mojo.useSubDirectoryPerType = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -279,7 +279,7 @@ public void testSubPerArtifactRemoveVersion() throws Exception { mojo.stripVersion = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -292,7 +292,7 @@ public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { mojo.stripVersion = true; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } @@ -304,7 +304,7 @@ public void testIncludeCompileScope() throws Exception { mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(saf.include(artifact), artifact); } } @@ -317,7 +317,7 @@ public void testIncludeTestScope() throws Exception { mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(saf.include(artifact), artifact); } } @@ -329,7 +329,7 @@ public void testIncludeRuntimeScope() throws Exception { mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(saf.include(artifact), artifact); } } @@ -340,7 +340,7 @@ public void testIncludeprovidedScope() throws Exception { mojo.includeScope = "provided"; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(Artifact.SCOPE_PROVIDED.equals(artifact.getScope()), artifact); } } @@ -352,7 +352,7 @@ public void testIncludesystemScope() throws Exception { mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(Artifact.SCOPE_SYSTEM.equals(artifact.getScope()), artifact); } } @@ -390,7 +390,7 @@ public void testExcludeArtifactId() throws Exception { // test - get all direct dependencies and verify that they exist if they // do not have a classifier of "one" // then delete the file and at the end, verify the folder is empty. - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!artifact.getArtifactId().equals("one"), artifact); } } @@ -401,7 +401,7 @@ public void testExcludeGroupId() throws Exception { mojo.excludeGroupIds = "one"; mojo.execute(); - for (Artifact artifact : (Iterable) mojo.getProject().getArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(!artifact.getGroupId().equals("one"), artifact); } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java index d7aca0520..26034f6dd 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java @@ -19,8 +19,6 @@ package org.apache.maven.plugins.dependency.resolvers; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; @@ -49,10 +47,6 @@ public void testReject() { artifact2.setArtifactId("maven-dependency-plugin-other-dummy"); artifact2.setVersion("1.0"); - Set artifacts = new HashSet<>(); - artifacts.add(artifact1); - artifacts.add(artifact2); - MavenProject project = new MavenProjectStub(); project.setArtifact(artifact1); @@ -62,18 +56,15 @@ public void testReject() { ExcludeReactorProjectsDependencyFilter filter = new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); - Node node = new Node() { - @Override - public Dependency getDependency() { - final Dependency result = new Dependency(); - result.setGroupId(artifact1.getGroupId()); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - } + Node node = () -> { + final Dependency result = new Dependency(); + result.setGroupId(artifact1.getGroupId()); + result.setArtifactId(artifact1.getArtifactId()); + result.setVersion(artifact1.getVersion()); + return result; }; - assertFalse(filter.accept(node, Collections.emptyList())); + assertFalse(filter.accept(node, Collections.emptyList())); } public void testRejectWithLogging() { @@ -87,10 +78,6 @@ public void testRejectWithLogging() { artifact2.setArtifactId("maven-dependency-plugin-other-dummy"); artifact2.setVersion("1.0"); - Set artifacts = new HashSet<>(); - artifacts.add(artifact1); - artifacts.add(artifact2); - MavenProject project = new MavenProjectStub(); project.setArtifact(artifact1); @@ -100,18 +87,15 @@ public void testRejectWithLogging() { ExcludeReactorProjectsDependencyFilter filter = new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); - Node node = new Node() { - @Override - public Dependency getDependency() { - final Dependency result = new Dependency(); - result.setGroupId(artifact1.getGroupId()); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - } + Node node = () -> { + final Dependency result = new Dependency(); + result.setGroupId(artifact1.getGroupId()); + result.setArtifactId(artifact1.getArtifactId()); + result.setVersion(artifact1.getVersion()); + return result; }; - filter.accept(node, Collections.emptyList()); + filter.accept(node, Collections.emptyList()); ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); verify(log).debug(captor.capture()); @@ -129,10 +113,6 @@ public void testAccept() { artifact2.setArtifactId("maven-dependency-plugin-other-dummy"); artifact2.setVersion("1.0"); - Set artifacts = new HashSet<>(); - artifacts.add(artifact1); - artifacts.add(artifact2); - MavenProject project = new MavenProjectStub(); project.setArtifact(artifact1); @@ -142,17 +122,14 @@ public void testAccept() { ExcludeReactorProjectsDependencyFilter filter = new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); - Node node = new Node() { - @Override - public Dependency getDependency() { - final Dependency result = new Dependency(); - result.setGroupId("something-else"); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - } + Node node = () -> { + final Dependency result = new Dependency(); + result.setGroupId("something-else"); + result.setArtifactId(artifact1.getArtifactId()); + result.setVersion(artifact1.getVersion()); + return result; }; - assertTrue(filter.accept(node, Collections.emptyList())); + assertTrue(filter.accept(node, Collections.emptyList())); } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java index 18ca35940..05a52ef97 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java @@ -53,8 +53,7 @@ public DependencyArtifactStubFactory(File theWorkingDir, boolean theCreateFiles) } public ArtifactItem getArtifactItem(Artifact artifact) { - ArtifactItem item = new ArtifactItem(artifact); - return item; + return new ArtifactItem(artifact); } public List getArtifactItems(Collection artifacts) { @@ -120,9 +119,7 @@ public void createUnpackableFile(Artifact artifact, File destFile) if (archiver instanceof WarArchiver) { WarArchiver war = (WarArchiver) archiver; - // the use of this is counter-intuitive: - // http://jira.codehaus.org/browse/PLX-286 - war.setIgnoreWebxml(false); + war.setExpectWebXml(false); } archiver.createArchive(); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java index 9083b3887..e48df87aa 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java @@ -19,7 +19,6 @@ package org.apache.maven.plugins.dependency.testUtils.stubs; import java.io.File; -import java.io.IOException; import java.io.Writer; import java.util.Collections; import java.util.List; @@ -29,7 +28,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -59,7 +57,6 @@ import org.apache.maven.model.Scm; import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -161,10 +158,13 @@ public DependencyProjectStub(MavenProject project) { super((Model) null); } - public String getModulePathAdjustment(MavenProject mavenProject) throws IOException { + @Override + @Deprecated + public String getModulePathAdjustment(MavenProject mavenProject) { return ""; } + @Override public Artifact getArtifact() { if (artifact == null) { ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", null); @@ -176,48 +176,60 @@ public Artifact getArtifact() { return artifact; } + @Override public void setArtifact(Artifact artifact) { this.artifact = artifact; } + @Override public Model getModel() { return model; } + @Override public MavenProject getParent() { return parent; } + @Override public void setParent(MavenProject mavenProject) { this.parent = mavenProject; } + @Override public void setRemoteArtifactRepositories(List list) {} + @Override public List getRemoteArtifactRepositories() { return Collections.emptyList(); } + @Override public boolean hasParent() { return (parent != null); } + @Override public File getFile() { return file; } + @Override public void setFile(File file) { this.file = file; } + @Override public File getBasedir() { return new File(PlexusTestCase.getBasedir()); } + @Override public void setDependencies(List list) { dependencies = list; } + @Override public List getDependencies() { if (dependencies == null) { dependencies = Collections.emptyList(); @@ -229,6 +241,7 @@ public void setDependencyManagement(DependencyManagement depMgt) { this.dependencyManagement = depMgt; } + @Override public DependencyManagement getDependencyManagement() { if (dependencyManagement == null) { dependencyManagement = new DependencyManagement(); @@ -237,6 +250,7 @@ public DependencyManagement getDependencyManagement() { return dependencyManagement; } + @Override public void addCompileSourceRoot(String string) { if (compileSourceRoots == null) { compileSourceRoots = Collections.singletonList(string); @@ -245,6 +259,8 @@ public void addCompileSourceRoot(String string) { } } + @Override + @Deprecated public void addScriptSourceRoot(String string) { if (scriptSourceRoots == null) { scriptSourceRoots = Collections.singletonList(string); @@ -253,6 +269,7 @@ public void addScriptSourceRoot(String string) { } } + @Override public void addTestCompileSourceRoot(String string) { if (testCompileSourceRoots == null) { testCompileSourceRoots = Collections.singletonList(string); @@ -261,236 +278,253 @@ public void addTestCompileSourceRoot(String string) { } } + @Override public List getCompileSourceRoots() { return compileSourceRoots; } + @Override + @Deprecated public List getScriptSourceRoots() { return scriptSourceRoots; } + @Override public List getTestCompileSourceRoots() { return testCompileSourceRoots; } - public List getCompileClasspathElements() throws DependencyResolutionRequiredException { + @Override + public List getCompileClasspathElements() { return compileSourceRoots; } - public void setCompileArtifacts(List compileArtifacts) { - this.compileArtifacts = compileArtifacts; - } - + @Override + @Deprecated public List getCompileArtifacts() { return compileArtifacts; } + @Override + @Deprecated public List getCompileDependencies() { return compileDependencies; } - public List getTestClasspathElements() throws DependencyResolutionRequiredException { + @Override + public List getTestClasspathElements() { return testClasspathElements; } + @Override + @Deprecated public List getTestArtifacts() { return testArtifacts; } + @Override + @Deprecated public List getTestDependencies() { return testDependencies; } - public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException { + @Override + public List getRuntimeClasspathElements() { return runtimeClasspathElements; } + @Override + @Deprecated public List getRuntimeArtifacts() { return runtimeArtifacts; } + @Override + @Deprecated public List getRuntimeDependencies() { return runtimeDependencies; } - public List getSystemClasspathElements() throws DependencyResolutionRequiredException { + @Override + @Deprecated + public List getSystemClasspathElements() { return systemClasspathElements; } + @Override + @Deprecated public List getSystemArtifacts() { return systemArtifacts; } - public void setRuntimeClasspathElements(List runtimeClasspathElements) { - this.runtimeClasspathElements = runtimeClasspathElements; - } - + @Override public void setAttachedArtifacts(List attachedArtifacts) { this.attachedArtifacts = attachedArtifacts; } + @Override public void setCompileSourceRoots(List compileSourceRoots) { this.compileSourceRoots = compileSourceRoots; } + @Override public void setTestCompileSourceRoots(List testCompileSourceRoots) { this.testCompileSourceRoots = testCompileSourceRoots; } + @Override + @Deprecated public void setScriptSourceRoots(List scriptSourceRoots) { this.scriptSourceRoots = scriptSourceRoots; } - public void setCompileDependencies(List compileDependencies) { - this.compileDependencies = compileDependencies; - } - - public void setSystemDependencies(List systemDependencies) { - this.systemDependencies = systemDependencies; - } - - public void setTestClasspathElements(List testClasspathElements) { - this.testClasspathElements = testClasspathElements; - } - - public void setTestDependencies(List testDependencies) { - this.testDependencies = testDependencies; - } - - public void setSystemClasspathElements(List systemClasspathElements) { - this.systemClasspathElements = systemClasspathElements; - } - - public void setSystemArtifacts(List systemArtifacts) { - this.systemArtifacts = systemArtifacts; - } - - public void setTestArtifacts(List testArtifacts) { - this.testArtifacts = testArtifacts; - } - - public void setRuntimeArtifacts(List runtimeArtifacts) { - this.runtimeArtifacts = runtimeArtifacts; - } - - public void setRuntimeDependencies(List runtimeDependencies) { - this.runtimeDependencies = runtimeDependencies; - } - + @Override public void setModel(Model model) { this.model = model; } + @Override + @Deprecated public List getSystemDependencies() { return systemDependencies; } + @Override public void setModelVersion(String string) { this.modelVersion = string; } + @Override public String getModelVersion() { return modelVersion; } + @Override public String getId() { return ""; } + @Override public void setGroupId(String string) { this.groupId = string; } + @Override public String getGroupId() { return groupId; } + @Override public void setArtifactId(String string) { this.artifactId = string; } + @Override public String getArtifactId() { return artifactId; } + @Override public void setName(String string) { this.name = string; } + @Override public String getName() { return name; } + @Override public void setVersion(String string) { this.version = string; } + @Override public String getVersion() { return version; } + @Override public String getPackaging() { return packaging; } + @Override public void setPackaging(String string) { this.packaging = string; } + @Override public void setInceptionYear(String string) { this.inceptionYear = string; } + @Override public String getInceptionYear() { return inceptionYear; } + @Override public void setUrl(String string) { this.url = string; } + @Override public String getUrl() { return url; } + @Override public Prerequisites getPrerequisites() { return null; } + @Override public void setIssueManagement(IssueManagement issueManagement) {} + @Override public CiManagement getCiManagement() { return null; } + @Override public void setCiManagement(CiManagement ciManagement) {} + @Override public IssueManagement getIssueManagement() { return null; } + @Override public void setDistributionManagement(DistributionManagement distributionManagement) {} + @Override public DistributionManagement getDistributionManagement() { return null; } + @Override public void setDescription(String string) { this.description = string; } + @Override public String getDescription() { return description; } + @Override public void setOrganization(Organization organization) {} + @Override public Organization getOrganization() { return null; } + @Override public void setScm(Scm scm) {} + @Override public Scm getScm() { return null; } @@ -498,65 +532,87 @@ public Scm getScm() { @Override public void setMailingLists(List list) {} + @Override public List getMailingLists() { return Collections.emptyList(); } + @Override public void addMailingList(MailingList mailingList) {} @Override public void setDevelopers(List list) {} + @Override public List getDevelopers() { return Collections.emptyList(); } + @Override public void addDeveloper(Developer developer) {} + @Override public void setContributors(List list) {} + @Override public List getContributors() { return Collections.emptyList(); } + @Override public void addContributor(Contributor contributor) {} + @Override public void setBuild(Build build) {} + @Override public Build getBuild() { return null; } + @Override public List getResources() { return Collections.emptyList(); } + @Override public List getTestResources() { return Collections.emptyList(); } + @Override public void addResource(Resource resource) {} + @Override public void addTestResource(Resource resource) {} + @Override + @Deprecated public void setReporting(Reporting reporting) {} + @Override + @Deprecated public Reporting getReporting() { return null; } + @Override public void setLicenses(List list) {} + @Override public List getLicenses() { return Collections.emptyList(); } + @Override public void addLicense(License license) {} + @Override public void setArtifacts(Set set) { this.artifacts = set; } + @Override public Set getArtifacts() { if (artifacts == null) { return Collections.emptySet(); @@ -565,102 +621,130 @@ public Set getArtifacts() { } } + @Override public Map getArtifactMap() { return Collections.emptyMap(); } + @Override public void setPluginArtifacts(Set set) {} + @Override public Set getPluginArtifacts() { return Collections.emptySet(); } + @Override public Map getPluginArtifactMap() { return Collections.emptyMap(); } + @Override + @Deprecated public void setReportArtifacts(Set set) {} + @Override + @Deprecated public Set getReportArtifacts() { return Collections.emptySet(); } + @Override public Map getReportArtifactMap() { return Collections.emptyMap(); } + @Override + @Deprecated public void setExtensionArtifacts(Set set) {} + @Override + @Deprecated public Set getExtensionArtifacts() { return Collections.emptySet(); } + @Override + @Deprecated public Map getExtensionArtifactMap() { return Collections.emptyMap(); } + @Override public void setParentArtifact(Artifact artifact) {} + @Override public Artifact getParentArtifact() { return null; } + @Override public List getRepositories() { return Collections.emptyList(); } + @Override + @Deprecated public List getReportPlugins() { return Collections.emptyList(); } + @Override public List getBuildPlugins() { return Collections.emptyList(); } + @Override public List getModules() { return Collections.singletonList(""); } + @Override public PluginManagement getPluginManagement() { return null; } - public void addPlugin(Plugin plugin) {} - - public void injectPluginManagementInfo(Plugin plugin) {} - + @Override public List getCollectedProjects() { return collectedProjects; } + @Override public void setCollectedProjects(List list) { this.collectedProjects = list; } + @Override public void setPluginArtifactRepositories(List list) { this.pluginArtifactRepositories = list; } + @Override public List getPluginArtifactRepositories() { return pluginArtifactRepositories; } + @Override public ArtifactRepository getDistributionManagementArtifactRepository() { return null; } + @Override public List getPluginRepositories() { return Collections.emptyList(); } + @Override public void setActiveProfiles(List list) { activeProfiles = list; } + @Override public List getActiveProfiles() { return activeProfiles; } + @Override public void addAttachedArtifact(Artifact theArtifact) { if (attachedArtifacts == null) { this.attachedArtifacts = Collections.singletonList(theArtifact); @@ -669,66 +753,88 @@ public void addAttachedArtifact(Artifact theArtifact) { } } + @Override public List getAttachedArtifacts() { return attachedArtifacts; } + @Override public Xpp3Dom getGoalConfiguration(String string, String string1, String string2, String string3) { return null; } + @Override + @Deprecated public Xpp3Dom getReportConfiguration(String string, String string1, String string2) { return null; } + @Override public MavenProject getExecutionProject() { return null; } + @Override public void setExecutionProject(MavenProject mavenProject) {} - public void writeModel(Writer writer) throws IOException {} + @Override + @Deprecated + public void writeModel(Writer writer) {} - public void writeOriginalModel(Writer writer) throws IOException {} + @Override + @Deprecated + public void writeOriginalModel(Writer writer) {} + @Override public Set getDependencyArtifacts() { return dependencyArtifacts; } + @Override public void setDependencyArtifacts(Set set) { this.dependencyArtifacts = set; } + @Override public void setReleaseArtifactRepository(ArtifactRepository artifactRepository) { // this.releaseArtifactRepository = artifactRepository; } + @Override public void setSnapshotArtifactRepository(ArtifactRepository artifactRepository) { // this.snapshotArtifactRepository = artifactRepository; } + @Override public void setOriginalModel(Model model) { this.originalModel = model; } + @Override public Model getOriginalModel() { return originalModel; } + @Override public List getBuildExtensions() { return Collections.emptyList(); } @Override - public Set createArtifacts(ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter) - throws InvalidDependencyVersionException { + @Deprecated + public Set createArtifacts( + ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter) { return Collections.emptySet(); } + @Override public void addProjectReference(MavenProject mavenProject) {} + @Override + @Deprecated public void attachArtifact(String string, String string1, File theFile) {} + @Override public Properties getProperties() { if (properties == null) { properties = new Properties(); @@ -736,26 +842,33 @@ public Properties getProperties() { return properties; } + @Override public List getFilters() { return Collections.singletonList(""); } + @Override public Map getProjectReferences() { return Collections.emptyMap(); } + @Override public boolean isExecutionRoot() { return executionRoot; } + @Override public void setExecutionRoot(boolean b) { this.executionRoot = b; } + @Override public String getDefaultGoal() { return defaultGoal; } + @Override + @Deprecated public Artifact replaceWithActiveArtifact(Artifact theArtifact) { return null; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java index ff5d5a840..2c52f5f3e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java @@ -60,8 +60,8 @@ protected void tearDown() throws IOException { FileUtils.deleteDirectory(outputFolder); } - public File createFile(Artifact artifact) throws IOException { - return createFile(artifact, false, false, false); + public void createFile(Artifact artifact) throws IOException { + createFile(artifact, false, false, false); } public File createFile( diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java index d32550ef3..25e629355 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java @@ -18,9 +18,6 @@ */ package org.apache.maven.plugins.dependency.utils.filters; -/** - * - */ import java.io.File; import java.io.IOException; import java.util.HashSet; From 50d561eb4fd2f8a05870ddc8bfb8ef0ebdd64820 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 21 Apr 2024 15:25:13 +0200 Subject: [PATCH 102/283] [MDEP-914] Fix link in collect goal description --- .../dependency/resolvers/CollectDependenciesMojo.java | 6 ++---- .../dependency/resolvers/ResolveDependenciesMojo.java | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java index bc23a637d..8b5fe8504 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java @@ -32,19 +32,17 @@ * This is very useful when full dependency resolution might fail due to projects which haven't been built yet. *

*

- * It is identical to {@link ResolveDependenciesMojo} except for using the requiresDependencyCollection annotation - * attribute instead of requiresDependencyResolution. + * It is identical to resolve + * except for using the requiresDependencyCollection annotation attribute instead of requiresDependencyResolution. *

* * @author Eric Pabst * @author Brian Fox * @since 3.0 */ -// CHECKSTYLE_OFF: LineLength @Mojo( name = "collect", requiresDependencyCollection = ResolutionScope.TEST, defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -// CHECKSTYLE_ON: LineLength public class CollectDependenciesMojo extends ResolveDependenciesMojo {} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 3d023a823..98e0d521e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -52,13 +52,11 @@ * @author Brian Fox * @since 2.0 */ -// CHECKSTYLE_OFF: LineLength @Mojo( name = "resolve", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -// CHECKSTYLE_ON: LineLength public class ResolveDependenciesMojo extends AbstractResolveMojo { @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") From fda11843f7c48d524d92918ff2a79fbee259d2fc Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 23 Apr 2024 00:05:20 +0200 Subject: [PATCH 103/283] [MDEP-925] Require Maven 3.6.3 --- pom.xml | 31 ++++++++++--------- .../AbstractDependencyMojoTest.java | 1 + .../dependency/analyze/TestAnalyzeDepMgt.java | 9 ++++++ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 1ea2e19c6..d4b9dc09d 100644 --- a/pom.xml +++ b/pom.xml @@ -87,10 +87,10 @@ under the License. - 3.2.5 + 3.6.3 9.4.54.v20240208 3.3.0 - 1.0.2.v20150114 + 1.4.1 8 2023-10-20T21:21:50Z 1.7.36 @@ -148,7 +148,7 @@ under the License. org.apache.maven - maven-aether-provider + maven-resolver-provider ${mavenVersion} provided @@ -244,6 +244,10 @@ under the License. org.apache.maven * + + org.eclipse.aether + aether-util + @@ -282,16 +286,15 @@ under the License. - org.eclipse.aether - aether-api + org.apache.maven.resolver + maven-resolver-api ${resolverVersion} provided - org.eclipse.aether - aether-util + org.apache.maven.resolver + maven-resolver-util ${resolverVersion} - provided @@ -304,20 +307,20 @@ under the License. - org.eclipse.aether - aether-connector-basic + org.apache.maven.resolver + maven-resolver-connector-basic ${resolverVersion} test - org.eclipse.aether - aether-transport-file + org.apache.maven.resolver + maven-resolver-transport-file ${resolverVersion} test - org.eclipse.aether - aether-transport-http + org.apache.maven.resolver + maven-resolver-transport-http ${resolverVersion} test diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java index eba047534..5c450f3d0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java @@ -81,6 +81,7 @@ protected void setUp() throws Exception { artifactRepos.add(newRepositoryWithId("ar-snapshots")); artifactRepos.add(newRepositoryWithId("ar-staging")); + when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java index 7b78a6eab..44e32cbbe 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java @@ -111,32 +111,41 @@ public void testGetManagementKey() throws IOException { // sure it's ok before // testing the next one dep.setType("t"); + dep.clearManagementKey(); assertNotEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setType("type"); + dep.clearManagementKey(); assertEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setArtifactId("a"); + dep.clearManagementKey(); assertNotEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setArtifactId("artifact"); + dep.clearManagementKey(); assertEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setClassifier("c"); + dep.clearManagementKey(); assertNotEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setClassifier("class"); + dep.clearManagementKey(); assertEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setGroupId("g"); + dep.clearManagementKey(); assertNotEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setGroupId("group"); dep.setClassifier(null); + dep.clearManagementKey(); artifact = stubFactory.createArtifact("group", "artifact", "1.0", Artifact.SCOPE_COMPILE, "type", null); assertEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); dep.setClassifier(""); + dep.clearManagementKey(); artifact = stubFactory.createArtifact("group", "artifact", "1.0", Artifact.SCOPE_COMPILE, "type", ""); assertEquals(dep.getManagementKey(), mojo.getArtifactManagementKey(artifact)); } From 20a12abcb7c63714f95eebeb681227e46a7b1400 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 23 Apr 2024 23:44:55 +0200 Subject: [PATCH 104/283] [MDEP-923] Remove plexus logger from DependencySilentLog --- .../dependency/utils/DependencySilentLog.java | 147 +----------------- .../dependency/utils/TestSilentLog.java | 32 +--- 2 files changed, 4 insertions(+), 175 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencySilentLog.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencySilentLog.java index 165a327d0..7e2106a2f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencySilentLog.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencySilentLog.java @@ -19,14 +19,13 @@ package org.apache.maven.plugins.dependency.utils; import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.logging.Logger; /** * This logger implements both types of logs currently in use and turns off logs. * * @author Brian Fox */ -public class DependencySilentLog implements Log, Logger { +public class DependencySilentLog implements Log { /** * @return false * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() @@ -184,148 +183,4 @@ public void error(CharSequence content, Throwable error) { public void error(Throwable error) { // nop } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#debug(java.lang.String) - */ - @Override - public void debug(String message) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#debug(java.lang.String, java.lang.Throwable) - */ - @Override - public void debug(String message, Throwable throwable) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#info(java.lang.String) - */ - @Override - public void info(String message) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#info(java.lang.String, java.lang.Throwable) - */ - @Override - public void info(String message, Throwable throwable) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#warn(java.lang.String) - */ - @Override - public void warn(String message) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#warn(java.lang.String, java.lang.Throwable) - */ - @Override - public void warn(String message, Throwable throwable) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#error(java.lang.String) - */ - @Override - public void error(String message) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#error(java.lang.String, java.lang.Throwable) - */ - @Override - public void error(String message, Throwable throwable) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String) - */ - @Override - public void fatalError(String message) { - // nop - } - - /** - * By default, do nothing. - * - * @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String, java.lang.Throwable) - */ - @Override - public void fatalError(String message, Throwable throwable) { - // nop - } - - /** - * @return false - * @see org.codehaus.plexus.logging.Logger#isFatalErrorEnabled() - */ - @Override - public boolean isFatalErrorEnabled() { - return false; - } - - /** - * @return null - * @see org.codehaus.plexus.logging.Logger#getChildLogger(java.lang.String) - */ - @Override - public Logger getChildLogger(String name) { - return null; - } - - /** - * @return 0 - * @see org.codehaus.plexus.logging.Logger#getThreshold() - */ - @Override - public int getThreshold() { - return 0; - } - - /** - * By default, do nothing - */ - @Override - public void setThreshold(int threshold) { - // nop - } - - /** - * @return null - * @see org.codehaus.plexus.logging.Logger#getName() - */ - @Override - public String getName() { - return null; - } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java index 231419ea3..b6cd7e435 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java @@ -18,12 +18,12 @@ */ package org.apache.maven.plugins.dependency.utils; -import junit.framework.TestCase; import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.logging.Logger; +import org.junit.Test; -public class TestSilentLog extends TestCase { +public class TestSilentLog { + @Test public void testLog() { Log log = new DependencySilentLog(); String text = "Text"; @@ -45,30 +45,4 @@ public void testLog() { log.isWarnEnabled(); log.isInfoEnabled(); } - - public void testLogger() { - Logger log = new DependencySilentLog(); - String text = "Text"; - Throwable e = new RuntimeException(); - - log.debug(text); - log.debug(text, e); - log.error(text); - log.error(text, e); - log.warn(text); - log.warn(text, e); - log.info(text); - log.info(text, e); - - log.fatalError(text); - log.fatalError(text, e); - log.getChildLogger(text); - log.getName(); - log.getThreshold(); - log.isDebugEnabled(); - log.isErrorEnabled(); - log.isFatalErrorEnabled(); - log.isInfoEnabled(); - log.isWarnEnabled(); - } } From 860d04ba3d0c3c33bc587baab84f52ba314c0884 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 22 Apr 2024 23:26:02 +0200 Subject: [PATCH 105/283] [MDEP-924] Get rid of maven-artifact-transfer from list-classes goal --- pom.xml | 33 ++- .../plugins/dependency/ListClassesMojo.java | 263 +++++------------- .../dependency/utils/ParamArtifact.java | 91 ++++++ .../dependency/utils/ResolverUtil.java | 167 ++++++++++- .../AbstractDependencyMojoTestCase.java | 9 + .../dependency/TestListClassesMojo.java | 65 +++-- .../stubs/DependencyProjectStub.java | 6 + .../dependency/utils/ResolverUtilTest.java | 108 +++++++ 8 files changed, 520 insertions(+), 222 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java create mode 100644 src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java diff --git a/pom.xml b/pom.xml index d4b9dc09d..3cf62a9ad 100644 --- a/pom.xml +++ b/pom.xml @@ -88,13 +88,16 @@ under the License. 3.6.3 + 8 + 9.4.54.v20240208 + 4.11.0 + 4.9.2 3.3.0 1.4.1 - 8 - 2023-10-20T21:21:50Z 1.7.36 - 4.9.2 + + 2023-10-20T21:21:50Z @@ -324,6 +327,22 @@ under the License. ${resolverVersion} test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-params + test + + + + org.junit.vintage + junit-vintage-engine + test + junit junit @@ -345,7 +364,13 @@ under the License. org.mockito mockito-core - 4.11.0 + ${mockito.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} test diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index 31ba07a9d..1cd29ba21 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -18,132 +18,121 @@ */ package org.apache.maven.plugins.dependency; +import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; 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.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; -import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; -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.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; -import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.apache.maven.plugins.dependency.utils.ParamArtifact; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.DependencyResolutionException; /** * Retrieves and lists all classes contained in the specified artifact from the specified remote repositories. + * + * @since 3.1.3 */ @Mojo(name = "list-classes", requiresProject = false, threadSafe = true) public class ListClassesMojo extends AbstractMojo { - private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.*)::(.+)"); - - @Component - private MavenSession session; - - @Component - private ArtifactResolver artifactResolver; @Component - private DependencyResolver dependencyResolver; + private ResolverUtil resolverUtil; - @Component - private ArtifactHandlerManager artifactHandlerManager; + private ParamArtifact paramArtifact = new ParamArtifact(); /** - * Map that contains the layouts. - */ - @Component(role = ArtifactRepositoryLayout.class) - private Map repositoryLayouts; - - /** - * The repository system. - */ - @Component - private RepositorySystem repositorySystem; - - private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); - - /** - * The group ID of the artifact to download. Ignored if {@link #artifact} is used. + * The group ID of the artifact to download. Ignored if {@code artifact} is used. + * + * @since 3.1.3 */ @Parameter(property = "groupId") - private String groupId; + public void setGroupId(String groupId) { + paramArtifact.setGroupId(groupId); + } /** - * The artifact ID of the artifact to download. Ignored if {@link #artifact} is used. + * The artifact ID of the artifact to download. Ignored if {@code artifact} is used. + * + * @since 3.1.3 */ @Parameter(property = "artifactId") - private String artifactId; + public void setArtifactId(String artifactId) { + paramArtifact.setArtifactId(artifactId); + } /** - * The version of the artifact to download. Ignored if {@link #artifact} is used. + * The version of the artifact to download. Ignored if {@code artifact} is used. + * + * @since 3.1.3 */ @Parameter(property = "version") - private String version; + public void setVersion(String version) { + paramArtifact.setVersion(version); + } /** - * The classifier of the artifact to download. Ignored if {@link #artifact} is used. + * The classifier of the artifact to download. Ignored if {@code artifact} is used. * - * @since 2.3 + * @since 3.1.3 */ @Parameter(property = "classifier") - private String classifier; + public void setClassifier(String classifier) { + paramArtifact.setClassifier(classifier); + } /** - * The packaging of the artifact to download. Ignored if {@link #artifact} is used. + * The packaging of the artifact to download. Ignored if {@code artifact} is used. + * + * @since 3.1.3 */ @Parameter(property = "packaging", defaultValue = "jar") - private String packaging = "jar"; + public void setPackaging(String packaging) { + paramArtifact.setPackaging(packaging); + } /** - * Repositories in the format id::[layout]::url or just URLs, separated by comma. That is, - * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com + * A string of the form {@code groupId:artifactId:version[:packaging[:classifier]]}. + * + * @since 3.1.3 */ - @Parameter(property = "remoteRepositories") - private String remoteRepositories; + @Parameter(property = "artifact") + public void setArtifact(String artifact) { + paramArtifact.setArtifact(artifact); + } /** - * A string of the form groupId:artifactId:version[:packaging[:classifier]]. + * Repositories in the format {@code id::[layout::]url} or just URLs. That is, + * + * central::default::https://repo.maven.apache.org/maven2,myrepo::https://repo.acme.com,https://repo.acme2.com + * + * + * @since 3.1.3 */ - @Parameter(property = "artifact") - private String artifact; - - @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) - private List pomRemoteRepositories; + @Parameter(property = "remoteRepositories") + private List remoteRepositories; /** * Download transitively, retrieving the specified artifact and all of its dependencies. + * + * @since 3.1.3 */ @Parameter(property = "transitive", defaultValue = "false") private boolean transitive = false; /** * Skip plugin execution completely. + * + * @since 3.6.0 */ @Parameter(property = "mdep.skip", defaultValue = "false") private boolean skip; @@ -155,30 +144,35 @@ public void execute() throws MojoExecutionException, MojoFailureException { return; } - ProjectBuildingRequest buildingRequest = makeBuildingRequest(); + if (!paramArtifact.isDataSet()) { + throw new MojoExecutionException("You must specify an artifact OR GAV separately, " + + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0 OR " + + "-DgroupId=org.apache.maven.plugins -DartifactId=maven-downloader-plugin -Dversion=1.0"); + } + + Artifact artifact = resolverUtil.createArtifactFromParams(paramArtifact); try { if (transitive) { - Iterable artifacts = - dependencyResolver.resolveDependencies(buildingRequest, coordinate, null); + List artifacts = + resolverUtil.resolveDependencies(artifact, resolverUtil.remoteRepositories(remoteRepositories)); - for (ArtifactResult result : artifacts) { - printClassesFromArtifactResult(result); + for (Artifact a : artifacts) { + printClassesFromArtifactResult(a.getFile()); } } else { - ArtifactResult result = - artifactResolver.resolveArtifact(buildingRequest, toArtifactCoordinate(coordinate)); - - printClassesFromArtifactResult(result); + Artifact a = + resolverUtil.resolveArtifact(artifact, resolverUtil.remoteRepositories(remoteRepositories)); + printClassesFromArtifactResult(a.getFile()); } - } catch (ArtifactResolverException | DependencyResolverException | IOException e) { + } catch (IOException | ArtifactResolutionException | DependencyResolutionException e) { throw new MojoExecutionException("Couldn't download artifact: " + e.getMessage(), e); } } - private void printClassesFromArtifactResult(ArtifactResult result) throws IOException { + private void printClassesFromArtifactResult(File file) throws IOException { // open jar file in try-with-resources statement to guarantee the file closes after use regardless of errors - try (JarFile jarFile = new JarFile(result.getArtifact().getFile())) { + try (JarFile jarFile = new JarFile(file)) { Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { @@ -197,111 +191,4 @@ private void printClassesFromArtifactResult(ArtifactResult result) throws IOExce } } } - - boolean hasGAVSpecified() { - return artifact != null || (groupId != null && artifactId != null && version != null); - } - - private ProjectBuildingRequest makeBuildingRequest() throws MojoExecutionException, MojoFailureException { - if (!hasGAVSpecified()) { - throw new MojoFailureException("You must specify an artifact OR GAV separately, " - + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0 OR " - + "-DgroupId=org.apache.maven.plugins -DartifactId=maven-downloader-plugin -Dversion=1.0"); - } - - String[] tokens = artifact != null - ? artifact.split(":") - : classifier != null - ? new String[] {groupId, artifactId, version, packaging, classifier} - : packaging != null - ? new String[] {groupId, artifactId, version, packaging} - : new String[] {groupId, artifactId, version}; - if (tokens.length < 3 || tokens.length > 5) { - throw new MojoFailureException("Invalid artifact, you must specify " - + "groupId:artifactId:version[:packaging[:classifier]] " + artifact); - } - coordinate.setGroupId(tokens[0]); - coordinate.setArtifactId(tokens[1]); - coordinate.setVersion(tokens[2]); - if (tokens.length >= 4) { - coordinate.setType(tokens[3]); - } - if (tokens.length == 5) { - coordinate.setClassifier(tokens[4]); - } - - ArtifactRepositoryPolicy always = new ArtifactRepositoryPolicy( - true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN); - - List repoList = new ArrayList<>(); - - if (pomRemoteRepositories != null) { - repoList.addAll(pomRemoteRepositories); - } - - if (remoteRepositories != null) { - // Use the same format as in the deploy plugin id::layout::url - String[] repos = remoteRepositories.split(","); - for (String repo : repos) { - repoList.add(parseRepository(repo, always)); - } - } - - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - - Settings settings = session.getSettings(); - repositorySystem.injectMirror(repoList, settings.getMirrors()); - repositorySystem.injectProxy(repoList, settings.getProxies()); - repositorySystem.injectAuthentication(repoList, settings.getServers()); - - buildingRequest.setRemoteRepositories(repoList); - - return buildingRequest; - } - - private ArtifactCoordinate toArtifactCoordinate(DependableCoordinate dependableCoordinate) { - ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(dependableCoordinate.getType()); - DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate(); - artifactCoordinate.setGroupId(dependableCoordinate.getGroupId()); - artifactCoordinate.setArtifactId(dependableCoordinate.getArtifactId()); - artifactCoordinate.setVersion(dependableCoordinate.getVersion()); - artifactCoordinate.setClassifier(dependableCoordinate.getClassifier()); - artifactCoordinate.setExtension(artifactHandler.getExtension()); - return artifactCoordinate; - } - - protected ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) - throws MojoFailureException { - // if it's a simple url - String id = "temp"; - ArtifactRepositoryLayout layout = getLayout("default"); - - // if it's an extended repo URL of the form id::layout::url - if (repo.contains("::")) { - Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo); - if (!matcher.matches()) { - throw new MojoFailureException( - repo, - "Invalid syntax for repository: " + repo, - "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"."); - } - - id = matcher.group(1).trim(); - if (!(matcher.group(2) == null || matcher.group(2).trim().isEmpty())) { - layout = getLayout(matcher.group(2).trim()); - } - repo = matcher.group(3).trim(); - } - return new MavenArtifactRepository(id, repo, layout, policy, policy); - } - - private ArtifactRepositoryLayout getLayout(String id) throws MojoFailureException { - ArtifactRepositoryLayout layout = repositoryLayouts.get(id); - - if (layout == null) { - throw new MojoFailureException(id, "Invalid repository layout", "Invalid repository layout: " + id); - } - - return layout; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java new file mode 100644 index 000000000..1727c4852 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java @@ -0,0 +1,91 @@ +/* + * 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.dependency.utils; + +/** + * Represent artifact data collected from Mojo parameters + */ +public class ParamArtifact { + private String groupId; + + private String artifactId; + + private String version; + + private String classifier; + + private String packaging; + + private String artifact; + + public String getGroupId() { + return groupId; + } + + public String getArtifactId() { + return artifactId; + } + + public String getVersion() { + return version; + } + + public String getClassifier() { + return classifier; + } + + public String getPackaging() { + return packaging; + } + + public String getArtifact() { + return artifact; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public void setArtifactId(String artifactId) { + this.artifactId = artifactId; + } + + public void setVersion(String version) { + this.version = version; + } + + public void setClassifier(String classifier) { + this.classifier = classifier; + } + + public void setPackaging(String packaging) { + this.packaging = packaging; + } + + public void setArtifact(String artifact) { + this.artifact = artifact; + } + + /** + * Determinate if all needed data is set + */ + public boolean isDataSet() { + return artifact != null || (groupId != null && artifactId != null && version != null); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java index 6138ddd16..d661377fe 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -23,14 +23,31 @@ import javax.inject.Provider; import javax.inject.Singleton; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import org.apache.maven.execution.MavenSession; import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.CollectRequest; import org.eclipse.aether.collection.CollectResult; import org.eclipse.aether.collection.DependencyCollectionException; import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; +import org.eclipse.aether.resolution.DependencyResult; import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; /** @@ -45,7 +62,7 @@ public class ResolverUtil { private final Provider mavenSessionProvider; @Inject - private ResolverUtil(RepositorySystem repositorySystem, Provider mavenSessionProvider) { + public ResolverUtil(RepositorySystem repositorySystem, Provider mavenSessionProvider) { this.repositorySystem = repositorySystem; this.mavenSessionProvider = mavenSessionProvider; } @@ -68,4 +85,152 @@ public Collection collectDependencies(Dependency root) throws Depend result.getRoot().accept(nodeListGenerator); return nodeListGenerator.getDependencies(true); } + + /** + * Resolve given artifact + * + * @param artifact an artifact to resolve + * @param repositories remote repositories list + * @return resolved artifact + * @throws ArtifactResolutionException If the artifact could not be resolved. + */ + public Artifact resolveArtifact(Artifact artifact, List repositories) + throws ArtifactResolutionException { + MavenSession session = mavenSessionProvider.get(); + ArtifactRequest request = new ArtifactRequest(artifact, repositories, null); + ArtifactResult result = repositorySystem.resolveArtifact(session.getRepositorySession(), request); + return result.getArtifact(); + } + + /** + * Resolve transitive dependencies for artifact. + * + * @param artifact an artifact to resolve + * @param repositories remote repositories list + * @return list of transitive dependencies for artifact + * @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could + * not be resolved. + */ + public List resolveDependencies(Artifact artifact, List repositories) + throws DependencyResolutionException { + MavenSession session = mavenSessionProvider.get(); + + CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, null), repositories); + DependencyRequest request = new DependencyRequest(collectRequest, null); + DependencyResult result = repositorySystem.resolveDependencies(session.getRepositorySession(), request); + return result.getArtifactResults().stream() + .map(ArtifactResult::getArtifact) + .collect(Collectors.toList()); + } + + /** + * Prepare a remote repositories list for given descriptions. + * + * @param repositories remote repositories descriptions + * @return a list of remote repositories + */ + public List remoteRepositories(List repositories) { + MavenSession mavenSession = mavenSessionProvider.get(); + List projectRepositories = + mavenSession.getCurrentProject().getRemoteProjectRepositories(); + if (repositories == null || repositories.isEmpty()) { + return projectRepositories; + } + + List repositoriesList = + repositories.stream().map(this::prepareRemoteRepository).collect(Collectors.toList()); + repositoriesList = + repositorySystem.newResolutionRepositories(mavenSession.getRepositorySession(), repositoriesList); + + List result = new ArrayList<>(projectRepositories); + result.addAll(repositoriesList); + return result; + } + + // protected for testing purpose + protected RemoteRepository prepareRemoteRepository(String repository) { + String[] items = Objects.requireNonNull(repository, "repository must be not null") + .split("::"); + String id = "temp"; + String type = null; + String url; + switch (items.length) { + case 3: + id = items[0]; + type = items[1]; + url = items[2]; + break; + case 2: + id = items[0]; + url = items[1]; + break; + case 1: + url = items[0]; + break; + default: + throw new IllegalArgumentException("Invalid repository: " + repository); + } + + if (type == null || type.isEmpty()) { + type = "default"; + } + + MavenSession mavenSession = mavenSessionProvider.get(); + RepositorySystemSession repositorySession = mavenSession.getRepositorySession(); + + String checksumPolicy = repositorySession.getChecksumPolicy(); + if (checksumPolicy == null) { + checksumPolicy = RepositoryPolicy.CHECKSUM_POLICY_WARN; + } + String updatePolicy = + mavenSession.getRequest().isUpdateSnapshots() ? RepositoryPolicy.UPDATE_POLICY_ALWAYS : null; + RepositoryPolicy repositoryPolicy = new RepositoryPolicy(true, updatePolicy, checksumPolicy); + + RemoteRepository.Builder builder = new RemoteRepository.Builder(id, type, url); + builder.setReleasePolicy(repositoryPolicy); + builder.setSnapshotPolicy(repositoryPolicy); + + return builder.build(); + } + + /** + * Create an artifact based on configuration from Mojo. + * + * @param paramArtifact an artifact configuration + * @return new artifact + */ + public Artifact createArtifactFromParams(ParamArtifact paramArtifact) { + Objects.requireNonNull(paramArtifact); + if (paramArtifact.getArtifact() != null) { + return createArtifactFromString(paramArtifact.getArtifact()); + } else { + ArtifactType artifactType = getArtifactType(paramArtifact.getPackaging()); + return new DefaultArtifact( + paramArtifact.getGroupId(), + paramArtifact.getArtifactId(), + paramArtifact.getClassifier(), + artifactType.getExtension(), + paramArtifact.getVersion(), + artifactType); + } + } + + private Artifact createArtifactFromString(String artifact) { + // groupId:artifactId:version[:packaging[:classifier]]. + String[] items = artifact.split(":"); + if (items.length < 3) { + throw new IllegalArgumentException("Invalid artifact format: " + artifact); + } + + ArtifactType artifactType = getArtifactType(items.length > 3 ? items[3] : null); + String classifier = items.length > 4 ? items[4] : null; + + return new DefaultArtifact(items[0], items[1], classifier, artifactType.getExtension(), items[2], artifactType); + } + + private ArtifactType getArtifactType(String packaging) { + ArtifactTypeRegistry artifactTypeRegistry = + mavenSessionProvider.get().getRepositorySession().getArtifactTypeRegistry(); + return artifactTypeRegistry.get(packaging != null ? packaging : "jar"); + } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 64ecd542a..0a4d55cc1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -29,6 +29,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; @@ -79,4 +80,12 @@ protected void installLocalRepository(LegacySupport legacySupport) throws Compon LocalRepositoryManager manager = system.newLocalRepositoryManager(repoSession, localRepository); repoSession.setLocalRepositoryManager(manager); } + + protected void installLocalRepository(RepositorySystemSession repoSession) throws ComponentLookupException { + RepositorySystem system = lookup(RepositorySystem.class); + String directory = stubFactory.getWorkingDir().toString(); + LocalRepository localRepository = new LocalRepository(directory); + LocalRepositoryManager manager = system.newLocalRepositoryManager(repoSession, localRepository); + ((DefaultRepositorySystemSession) repoSession).setLocalRepositoryManager(manager); + } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index 92cf2d68a..0d79086f4 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -22,15 +22,15 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.List; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.Settings; +import org.eclipse.aether.RepositorySystem; import org.junit.Assert; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @@ -45,6 +45,11 @@ protected void setUp() throws Exception { getContainer().addComponent(project, MavenProject.class.getName()); MavenSession session = newMavenSession(project); + + RepositorySystem repositorySystem = lookup(RepositorySystem.class); + ResolverUtil resolverUtil = new ResolverUtil(repositorySystem, () -> session); + getContainer().addComponent(resolverUtil, ResolverUtil.class.getName()); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml"); @@ -54,16 +59,7 @@ protected void setUp() throws Exception { assertNotNull(mojo); - LegacySupport legacySupport = lookup(LegacySupport.class); - Settings settings = session.getSettings(); - Server server = new Server(); - server.setId("myserver"); - server.setUsername("foo"); - server.setPassword("bar"); - settings.addServer(server); - legacySupport.setSession(session); - - installLocalRepository(legacySupport); + installLocalRepository(session.getRepositorySession()); } public void testListClassesNotTransitive() throws Exception { @@ -74,9 +70,11 @@ public void testListClassesNotTransitive() throws Exception { setVariableValueToObject( mojo, "remoteRepositories", - "central::default::https://repo.maven.apache.org/maven2," - + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); - setVariableValueToObject(mojo, "artifact", "org.apache.commons:commons-lang3:3.6"); + Arrays.asList( + "central::default::https://repo.maven.apache.org/maven2", + "central::::https://repo.maven.apache.org/maven2", + "https://repo.maven.apache.org/maven2")); + mojo.setArtifact("org.apache.commons:commons-lang3:3.6"); setVariableValueToObject(mojo, "transitive", Boolean.FALSE); Log log = Mockito.mock(Log.class); @@ -96,11 +94,15 @@ public void testListClassesNotTransitiveByGAV() throws Exception { setVariableValueToObject( mojo, "remoteRepositories", - "central::default::https://repo.maven.apache.org/maven2," - + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); - setVariableValueToObject(mojo, "groupId", "org.apache.commons"); - setVariableValueToObject(mojo, "artifactId", "commons-lang3"); - setVariableValueToObject(mojo, "version", "3.6"); + Arrays.asList( + "central1::default::https://repo.maven.apache.org/maven2", + "central2::::https://repo.maven.apache.org/maven2", + "https://repo.maven.apache.org/maven2")); + + mojo.setGroupId("org.apache.commons"); + mojo.setArtifactId("commons-lang3"); + mojo.setVersion("3.6"); + setVariableValueToObject(mojo, "transitive", Boolean.FALSE); Log log = Mockito.mock(Log.class); @@ -120,9 +122,12 @@ public void testListClassesTransitive() throws Exception { setVariableValueToObject( mojo, "remoteRepositories", - "central::default::https://repo.maven.apache.org/maven2," - + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); - setVariableValueToObject(mojo, "artifact", "org.apache.commons:commons-lang3:3.6"); + Arrays.asList( + "central::default::https://repo.maven.apache.org/maven2", + "central::::https://repo.maven.apache.org/maven2", + "https://repo.maven.apache.org/maven2")); + + mojo.setArtifact("org.apache.commons:commons-lang3:3.6"); setVariableValueToObject(mojo, "transitive", Boolean.TRUE); Log log = Mockito.mock(Log.class); @@ -142,11 +147,13 @@ public void testListClassesTransitiveByGAV() throws Exception { setVariableValueToObject( mojo, "remoteRepositories", - "central::default::https://repo.maven.apache.org/maven2," - + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2"); - setVariableValueToObject(mojo, "groupId", "org.apache.commons"); - setVariableValueToObject(mojo, "artifactId", "commons-lang3"); - setVariableValueToObject(mojo, "version", "3.6"); + Arrays.asList( + "central::default::https://repo.maven.apache.org/maven2", + "central::::https://repo.maven.apache.org/maven2", + "https://repo.maven.apache.org/maven2")); + mojo.setGroupId("org.apache.commons"); + mojo.setArtifactId("commons-lang3"); + mojo.setVersion("3.6"); setVariableValueToObject(mojo, "transitive", Boolean.TRUE); Log log = Mockito.mock(Log.class); diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java index e48df87aa..9edcfb354 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java @@ -59,6 +59,7 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.eclipse.aether.repository.RemoteRepository; /** * very simple stub of maven project, going to take a lot of work to make it useful as a stub though @@ -204,6 +205,11 @@ public List getRemoteArtifactRepositories() { return Collections.emptyList(); } + @Override + public List getRemoteProjectRepositories() { + return Collections.emptyList(); + } + @Override public boolean hasParent() { return (parent != null); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java b/src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java new file mode 100644 index 000000000..4359c6949 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java @@ -0,0 +1,108 @@ +/* + * 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.dependency.utils; + +import javax.inject.Provider; + +import java.util.stream.Stream; + +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenSession; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.junit.jupiter.params.provider.Arguments.of; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ResolverUtilTest { + + @Mock + private MavenExecutionRequest executionRequest; + + @Mock + private RepositorySystemSession repositorySystemSession; + + @Mock + private MavenSession mavenSession; + + @Mock + private Provider sessionProvider; + + @InjectMocks + private ResolverUtil resolverUtil; + + public static Stream prepareRepositoryTest() { + + return Stream.of( + of("", "temp", "default", ""), + of("https://repo.maven.apache.org", "temp", "default", "https://repo.maven.apache.org"), + of("central::https://repo.maven.apache.org", "central", "default", "https://repo.maven.apache.org"), + of("central::::https://repo.maven.apache.org", "central", "default", "https://repo.maven.apache.org"), + of( + "central::layout2::https://repo.maven.apache.org", + "central", + "layout2", + "https://repo.maven.apache.org")); + } + + @ParameterizedTest + @MethodSource + void prepareRepositoryTest(String repository, String id, String type, String url) { + when(sessionProvider.get()).thenReturn(mavenSession); + when(mavenSession.getRepositorySession()).thenReturn(repositorySystemSession); + when(mavenSession.getRequest()).thenReturn(executionRequest); + when(executionRequest.isUpdateSnapshots()).thenReturn(true); + + RemoteRepository remoteRepository = resolverUtil.prepareRemoteRepository(repository); + + assertThat(remoteRepository).isNotNull(); + assertThat(remoteRepository.getId()).isEqualTo(id); + assertThat(remoteRepository.getContentType()).isEqualTo(type); + assertThat(remoteRepository.getUrl()).isEqualTo(url); + + RepositoryPolicy snapshotPolicy = remoteRepository.getPolicy(true); + assertThat(snapshotPolicy).isNotNull(); + assertThat(snapshotPolicy.getUpdatePolicy()).isEqualTo(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + assertThat(snapshotPolicy.getChecksumPolicy()).isEqualTo(RepositoryPolicy.CHECKSUM_POLICY_WARN); + + RepositoryPolicy releasePolicy = remoteRepository.getPolicy(true); + assertThat(releasePolicy).isNotNull(); + assertThat(releasePolicy.getUpdatePolicy()).isEqualTo(RepositoryPolicy.UPDATE_POLICY_ALWAYS); + assertThat(releasePolicy.getChecksumPolicy()).isEqualTo(RepositoryPolicy.CHECKSUM_POLICY_WARN); + } + + @Test + void prepareRepositoryWithNull() { + assertThatCode(() -> resolverUtil.prepareRemoteRepository(null)) + .isExactlyInstanceOf(NullPointerException.class) + .hasMessage("repository must be not null"); + } +} From 4311011714a12f373caf400758ad58a12e6b98fe Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 5 May 2024 12:22:51 +0200 Subject: [PATCH 106/283] [MDEP-923] Exclude only specific artifacts from dependencies --- pom.xml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 3cf62a9ad..23089e51c 100644 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,19 @@ under the License. org.apache.maven - * + maven-artifact + + + org.apache.maven + maven-core + + + org.apache.maven + maven-model + + + org.apache.maven + maven-plugin-api @@ -243,10 +255,6 @@ under the License. maven-dependency-tree 3.2.1 - - org.apache.maven - * - org.eclipse.aether aether-util @@ -265,7 +273,11 @@ under the License. org.apache.maven - * + maven-artifact + + + org.apache.maven + maven-core From e87a5bd6b3205a2e5ae8b1f77b4c67f92a3443cf Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 11 May 2024 13:21:06 +0200 Subject: [PATCH 107/283] [MDEP-919] Set m.r.dependencyManagerTransitivity for tree ITs - Maven 4 compatibility --- .../projects/tree-multimodule/test.properties | 1 + .../tree-verbose-multimodule/test.properties | 1 + src/it/projects/tree-verbose/test.properties | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/it/projects/tree-verbose/test.properties diff --git a/src/it/projects/tree-multimodule/test.properties b/src/it/projects/tree-multimodule/test.properties index 2a312e22e..1a148045c 100644 --- a/src/it/projects/tree-multimodule/test.properties +++ b/src/it/projects/tree-multimodule/test.properties @@ -16,3 +16,4 @@ # under the License. outputFile = target/tree.txt +maven.resolver.dependencyManagerTransitivity=false diff --git a/src/it/projects/tree-verbose-multimodule/test.properties b/src/it/projects/tree-verbose-multimodule/test.properties index 2a312e22e..1a148045c 100644 --- a/src/it/projects/tree-verbose-multimodule/test.properties +++ b/src/it/projects/tree-verbose-multimodule/test.properties @@ -16,3 +16,4 @@ # under the License. outputFile = target/tree.txt +maven.resolver.dependencyManagerTransitivity=false diff --git a/src/it/projects/tree-verbose/test.properties b/src/it/projects/tree-verbose/test.properties new file mode 100644 index 000000000..08bf0c035 --- /dev/null +++ b/src/it/projects/tree-verbose/test.properties @@ -0,0 +1,18 @@ +# 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. + +maven.resolver.dependencyManagerTransitivity=false From 1ee4a22d53fdc419e207af62244ea38114727c13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 11:47:21 +0000 Subject: [PATCH 108/283] Bump org.apache.maven.shared:maven-dependency-analyzer (#392) Bumps [org.apache.maven.shared:maven-dependency-analyzer](https://github.com/apache/maven-dependency-analyzer) from 1.13.2 to 1.14.0. - [Release notes](https://github.com/apache/maven-dependency-analyzer/releases) - [Commits](https://github.com/apache/maven-dependency-analyzer/compare/maven-dependency-analyzer-1.13.2...maven-dependency-analyzer-1.14.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-dependency-analyzer dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 23089e51c..301f67b10 100644 --- a/pom.xml +++ b/pom.xml @@ -242,7 +242,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.13.2 + 1.14.0 org.apache.maven From cf2f3a9e5cbf79b0c8f7088374ce0379d34673a2 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 21 May 2024 21:36:42 +0200 Subject: [PATCH 109/283] [MDEP-928] Allow to exclude classes from dependency:analyze --- pom.xml | 6 -- .../invoker.properties | 18 +++++ .../projects/analyze-excluded-classes/pom.xml | 70 +++++++++++++++++++ .../analyze-excluded-classes/setup.groovy | 26 +++++++ .../src/main/java/Main.java | 31 ++++++++ .../analyze-excluded-classes/verify.groovy | 31 ++++++++ .../analyze/AbstractAnalyzeMojo.java | 10 ++- .../dependency/analyze/AnalyzeReportMojo.java | 11 ++- 8 files changed, 195 insertions(+), 8 deletions(-) create mode 100644 src/it/projects/analyze-excluded-classes/invoker.properties create mode 100644 src/it/projects/analyze-excluded-classes/pom.xml create mode 100644 src/it/projects/analyze-excluded-classes/setup.groovy create mode 100644 src/it/projects/analyze-excluded-classes/src/main/java/Main.java create mode 100644 src/it/projects/analyze-excluded-classes/verify.groovy diff --git a/pom.xml b/pom.xml index 301f67b10..c6b7658c7 100644 --- a/pom.xml +++ b/pom.xml @@ -243,12 +243,6 @@ under the License. org.apache.maven.shared maven-dependency-analyzer 1.14.0 - - - org.apache.maven - * - - org.apache.maven.shared diff --git a/src/it/projects/analyze-excluded-classes/invoker.properties b/src/it/projects/analyze-excluded-classes/invoker.properties new file mode 100644 index 000000000..0eca1be80 --- /dev/null +++ b/src/it/projects/analyze-excluded-classes/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze diff --git a/src/it/projects/analyze-excluded-classes/pom.xml b/src/it/projects/analyze-excluded-classes/pom.xml new file mode 100644 index 000000000..7d678478f --- /dev/null +++ b/src/it/projects/analyze-excluded-classes/pom.xml @@ -0,0 +1,70 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:analyze with excluded classes + + + + UTF-8 + + + + + org.apache.maven + maven-artifact + @mavenVersion@ + + + org.apache.maven + maven-core + @mavenVersion@ + + + + + + + + maven-dependency-plugin + @project.version@ + + true + true + true + + org.example.Bad.* + + + + + + + diff --git a/src/it/projects/analyze-excluded-classes/setup.groovy b/src/it/projects/analyze-excluded-classes/setup.groovy new file mode 100644 index 000000000..c45210978 --- /dev/null +++ b/src/it/projects/analyze-excluded-classes/setup.groovy @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// prepare a class with wrong bytecode +def badClass = new File(basedir, 'target/classes/org/example/BadClass.class') + +badClass.getParentFile().mkdirs() +badClass << 'some content' + +assert badClass.isFile() diff --git a/src/it/projects/analyze-excluded-classes/src/main/java/Main.java b/src/it/projects/analyze-excluded-classes/src/main/java/Main.java new file mode 100644 index 000000000..e4d166fa1 --- /dev/null +++ b/src/it/projects/analyze-excluded-classes/src/main/java/Main.java @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.model.Model; + +public class Main +{ + public static final String SCOPE_COMPILE = Artifact.SCOPE_COMPILE; + + public Model model = null; + + public Metadata metadata = null; +} diff --git a/src/it/projects/analyze-excluded-classes/verify.groovy b/src/it/projects/analyze-excluded-classes/verify.groovy new file mode 100644 index 000000000..47457c6f6 --- /dev/null +++ b/src/it/projects/analyze-excluded-classes/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +File classFile = new File( basedir, "target/classes/Main.class" ) +assert classFile.exists() +assert classFile.isFile() : "Build was not forked, class missing " + classFile + +File file = new File( basedir, "build.log" ) +assert file.exists() + +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( '[WARNING] Used undeclared dependencies found:') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-model:jar:3.6.3:compile') +assert buildLog.contains( '[WARNING] Unused declared dependencies found:') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:jar:3.6.3:compile') diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 59b3ba3c8..35b287ec1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -266,6 +266,14 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { @Parameter private List ignoredPackagings = Arrays.asList("pom", "ear"); + /** + * List Excluded classes patterns from analyze. Java regular expression pattern is applied to full class name. + * + * @since 3.7.0 + */ + @Parameter(property = "mdep.analyze.excludedClasses") + private Set excludedClasses; + // Mojo methods ----------------------------------------------------------- /* @@ -321,7 +329,7 @@ protected final boolean isSkip() { private boolean checkDependencies() throws MojoExecutionException { ProjectDependencyAnalysis analysis; try { - analysis = createProjectDependencyAnalyzer().analyze(project); + analysis = createProjectDependencyAnalyzer().analyze(project, excludedClasses); if (usedDependencies != null) { analysis = analysis.forceDeclaredDependenciesUsage(usedDependencies); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java index 5ef0ea7c9..0c8d4ce60 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.analyze; import java.util.Locale; +import java.util.Set; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Execute; @@ -75,6 +76,14 @@ public class AnalyzeReportMojo extends AbstractMavenReport { @Parameter(property = "mdep.analyze.skip", defaultValue = "false") private boolean skip; + /** + * List Excluded classes patterns from analyze. Java regular expression pattern is applied to full class name. + * + * @since 3.7.0 + */ + @Parameter(property = "mdep.analyze.excludedClasses") + private Set excludedClasses; + /** * Internationalization component */ @@ -91,7 +100,7 @@ public void executeReport(Locale locale) throws MavenReportException { // Step 1: Analyze the project ProjectDependencyAnalysis analysis; try { - analysis = analyzer.analyze(project); + analysis = analyzer.analyze(project, excludedClasses); if (usedDependencies != null) { analysis = analysis.forceDeclaredDependenciesUsage(usedDependencies); From 27d2eb9ef92e5ea52ecebea3554950d6399d42e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 00:42:14 +0200 Subject: [PATCH 110/283] [MDEP-929] Bump org.apache.maven.shared:maven-dependency-analyzer (#394) Bumps [org.apache.maven.shared:maven-dependency-analyzer](https://github.com/apache/maven-dependency-analyzer) from 1.14.0 to 1.14.1. - [Release notes](https://github.com/apache/maven-dependency-analyzer/releases) - [Commits](https://github.com/apache/maven-dependency-analyzer/compare/maven-dependency-analyzer-1.14.0...maven-dependency-analyzer-1.14.1) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-dependency-analyzer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6b7658c7..b28e8a3d8 100644 --- a/pom.xml +++ b/pom.xml @@ -242,7 +242,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.14.0 + 1.14.1 org.apache.maven.shared From 09775b3c0effa7d102b4e71ce8c3688caa6dee71 Mon Sep 17 00:00:00 2001 From: Elias Lundell <36220731+LogFlames@users.noreply.github.com> Date: Thu, 23 May 2024 13:59:40 +0200 Subject: [PATCH 111/283] [MDEP-799] tree: add optional output type json (#391) * [MDEP-799] tree: add optional output type json --------- Co-authored-by: Martin Wittlinger --- pom.xml | 12 ++ .../tree/JsonDependencyNodeVisitor.java | 204 ++++++++++++++++++ .../plugins/dependency/tree/TreeMojo.java | 2 + .../plugins/dependency/tree/TestTreeMojo.java | 79 +++++++ 4 files changed, 297 insertions(+) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java diff --git a/pom.xml b/pom.xml index b28e8a3d8..44ff40a49 100644 --- a/pom.xml +++ b/pom.xml @@ -343,6 +343,18 @@ under the License. junit-jupiter-params test + + javax.json + javax.json-api + 1.1.4 + test + + + org.glassfish + javax.json + 1.1.4 + test + org.junit.vintage diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java new file mode 100644 index 000000000..52fd180b4 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java @@ -0,0 +1,204 @@ +/* + * 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.dependency.tree; + +import java.io.Writer; +import java.util.HashSet; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.shared.dependency.graph.DependencyNode; +import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor; + +/** + * A dependency node visitor that serializes visited nodes to a writer using the JSON format. + */ +public class JsonDependencyNodeVisitor extends AbstractSerializingVisitor implements DependencyNodeVisitor { + + private String indentChar = " "; + + /** + * Creates a new instance of {@link JsonDependencyNodeVisitor}. The writer will be used to write the output. + * + * @param writer the writer to write to + */ + public JsonDependencyNodeVisitor(Writer writer) { + super(writer); + } + + @Override + public boolean visit(DependencyNode node) { + if (node.getParent() == null || node.getParent() == node) { + writeRootNode(node); + } + return true; + } + + /** + * Writes the node to the writer. This method is recursive and will write all children nodes. + * + * @param node the node to write + */ + private void writeRootNode(DependencyNode node) { + Set visited = new HashSet(); + int indent = 2; + StringBuilder sb = new StringBuilder(); + sb.append("{").append("\n"); + writeNode(indent, node, sb, visited); + sb.append("}").append("\n"); + writer.write(sb.toString()); + } + /** + * Appends the node and its children to the string builder. + * + * @param indent the current indent level + * @param node the node to write + * @param sb the string builder to append to + */ + private void writeNode(int indent, DependencyNode node, StringBuilder sb, Set visited) { + if (visited.contains(node)) { + // Circular dependency detected + // Should an exception be thrown? + return; + } + visited.add(node); + appendNodeValues(sb, indent, node.getArtifact(), !node.getChildren().isEmpty()); + if (!node.getChildren().isEmpty()) { + writeChildren(indent, node, sb, visited); + } + } + /** + * Writes the children of the node to the string builder. And each children of each node will be written recursively. + * + * @param indent the current indent level + * @param node the node to write + * @param sb the string builder to append to + */ + private void writeChildren(int indent, DependencyNode node, StringBuilder sb, Set visited) { + sb.append(indent(indent)).append("\"children\": [").append("\n"); + indent += 2; + for (int i = 0; i < node.getChildren().size(); i++) { + DependencyNode child = node.getChildren().get(i); + sb.append(indent(indent)); + sb.append("{").append("\n"); + writeNode(indent + 2, child, sb, visited); + sb.append(indent(indent)).append("}"); + // we skip the comma for the last child + if (i != node.getChildren().size() - 1) { + sb.append(","); + } + sb.append("\n"); + } + sb.append(indent(indent)).append("]").append("\n"); + } + + @Override + public boolean endVisit(DependencyNode node) { + return true; + } + /** + * Appends the artifact values to the string builder. + * + * @param sb the string builder to append to + * @param indent the current indent level + * @param artifact the artifact to write + * @param hasChildren true if the artifact has children + */ + private void appendNodeValues(StringBuilder sb, int indent, Artifact artifact, boolean hasChildren) { + appendKeyValue(sb, indent, "groupId", artifact.getGroupId()); + appendKeyValue(sb, indent, "artifactId", artifact.getArtifactId()); + appendKeyValue(sb, indent, "version", artifact.getVersion()); + appendKeyValue(sb, indent, "type", artifact.getType()); + appendKeyValue(sb, indent, "scope", artifact.getScope()); + appendKeyValue(sb, indent, "classifier", artifact.getClassifier()); + if (hasChildren) { + appendKeyValue(sb, indent, "optional", String.valueOf(artifact.isOptional())); + } else { + appendKeyWithoutComma(sb, indent, "optional", String.valueOf(artifact.isOptional())); + } + } + /** + * Appends a key value pair to the string builder. + * + * @param sb the string builder to append to + * @param indent the current indent level + * @param key the key used as json key + * @param value the value used as json value + */ + private void appendKeyValue(StringBuilder sb, int indent, String key, String value) { + if (value == null) { + value = ""; + } + + sb.append(indent(indent)) + .append("\"") + .append(key) + .append("\"") + .append(":") + .append(indentChar) + .append("\"") + .append(value) + .append("\"") + .append(",") + .append("\n"); + } + /** + * Appends a key value pair to the string builder without a comma at the end. This is used for the last children of a node. + * + * @param sb the string builder to append to + * @param indent the current indent level + * @param key the key used as json key + * @param value the value used as json value + */ + private void appendKeyWithoutComma(StringBuilder sb, int indent, String key, String value) { + if (value == null) { + value = ""; + } + + sb.append(indent(indent)) + .append("\"") + .append(key) + .append("\"") + .append(":") + .append(indentChar) + .append("\"") + .append(value) + .append("\"") + .append("\n"); + } + + /** + * Returns a string of {@link #indentChar} for the indent level. + * + * @param indent the number of indent levels + * @return the string of indent characters + */ + private String indent(int indent) { + if (indent < 1) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < indent; i++) { + sb.append(indentChar); + } + + return sb.toString(); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 0b587a0d6..3ee40cf5b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -377,6 +377,8 @@ public DependencyNodeVisitor getSerializingDependencyNodeVisitor(Writer writer) return new TGFDependencyNodeVisitor(writer); } else if ("dot".equals(outputType)) { return new DOTDependencyNodeVisitor(writer); + } else if ("json".equals(outputType)) { + return new JsonDependencyNodeVisitor(writer); } else { return new SerializingDependencyNodeVisitor(writer, toGraphTokens(tokens)); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index 79e734825..dc8051523 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -18,9 +18,19 @@ */ package org.apache.maven.plugins.dependency.tree; +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; + import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.StringReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -32,6 +42,7 @@ import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.dependency.graph.DependencyNode; +import org.apache.maven.shared.dependency.graph.internal.DefaultDependencyNode; /** * Tests TreeMojo. @@ -137,6 +148,74 @@ public void testTreeTGFSerializing() throws Exception { assertTrue(findString(contents, "testGroupId:release:jar:1.0:compile")); } + /** + * Test the JSON format serialization on DependencyNodes with circular dependence + */ + public void testTreeJsonCircularDependency() throws IOException { + String outputFileName = testDir.getAbsolutePath() + "tree1.json"; + File outputFile = new File(outputFileName); + Files.createDirectories(outputFile.getParentFile().toPath()); + outputFile.createNewFile(); + + Artifact artifact1 = this.stubFactory.createArtifact("testGroupId", "project1", "1.0"); + Artifact artifact2 = this.stubFactory.createArtifact("testGroupId", "project2", "1.0"); + DefaultDependencyNode node1 = new DefaultDependencyNode(artifact1); + DefaultDependencyNode node2 = new DefaultDependencyNode(artifact2); + + node1.setChildren(new ArrayList()); + node2.setChildren(new ArrayList()); + + node1.getChildren().add(node2); + node2.getChildren().add(node1); + + JsonDependencyNodeVisitor jsonDependencyNodeVisitor = + new JsonDependencyNodeVisitor(new OutputStreamWriter(new FileOutputStream(outputFile))); + + jsonDependencyNodeVisitor.visit(node1); + } + + /* + * Test parsing of Json output and verify all key-value pairs + */ + public void testTreeJsonParsing() throws Exception { + List contents = runTreeMojo("tree2.json", "json"); + + try (JsonReader reader = Json.createReader(new StringReader(String.join("\n", contents)))) { + JsonObject root = reader.readObject(); + + assertEquals(root.getString("groupId"), "testGroupId"); + assertEquals(root.getString("artifactId"), "project"); + assertEquals(root.getString("version"), "1.0"); + assertEquals(root.getString("type"), "jar"); + assertEquals(root.getString("scope"), "compile"); + assertEquals(root.getString("classifier"), ""); + assertEquals(root.getString("optional"), "false"); + + JsonArray children = root.getJsonArray("children"); + assertEquals(children.size(), 2); + + JsonObject child0 = children.getJsonObject(0); + + assertEquals(child0.getString("groupId"), "testGroupId"); + assertEquals(child0.getString("artifactId"), "release"); + assertEquals(child0.getString("version"), "1.0"); + assertEquals(child0.getString("type"), "jar"); + assertEquals(child0.getString("scope"), "compile"); + assertEquals(child0.getString("classifier"), ""); + assertEquals(child0.getString("optional"), "false"); + + JsonObject child1 = children.getJsonObject(1); + + assertEquals(child1.getString("groupId"), "testGroupId"); + assertEquals(child1.getString("artifactId"), "snapshot"); + assertEquals(child1.getString("version"), "2.0-SNAPSHOT"); + assertEquals(child1.getString("type"), "jar"); + assertEquals(child1.getString("scope"), "compile"); + assertEquals(child1.getString("classifier"), ""); + assertEquals(child1.getString("optional"), "false"); + } + } + /** * Help finding content in the given list of string * From c0e894992131df3df40fdbd8b5c71ebf6c88e9b3 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 27 May 2024 18:54:27 +0200 Subject: [PATCH 112/283] [MDEP-923] Extract copyFile method from AbstractDependencyMojo (#389) --- .../dependency/AbstractDependencyMojo.java | 37 ---------- .../fromConfiguration/CopyMojo.java | 14 +++- .../CopyDependenciesMojo.java | 20 ++++- .../resolvers/ResolveDependenciesMojo.java | 8 ++ .../resolvers/ResolvePluginsMojo.java | 8 ++ .../plugins/dependency/utils/CopyUtil.java | 73 +++++++++++++++++++ .../AbstractDependencyMojoTestCase.java | 6 +- .../TestCopyDependenciesMojo.java | 4 +- 8 files changed, 124 insertions(+), 46 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index c57bc99d3..114824996 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -18,8 +18,6 @@ */ package org.apache.maven.plugins.dependency; -import java.io.File; -import java.io.IOException; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -33,7 +31,6 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.codehaus.plexus.util.FileUtils; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -94,14 +91,6 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { @Parameter(property = "silent", defaultValue = "false") private boolean silent; - /** - * Output absolute filename for resolved artifacts - * - * @since 2.0 - */ - @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") - protected boolean outputAbsoluteArtifactFilename; - /** * Skip plugin execution completely. * @@ -131,32 +120,6 @@ public final void execute() throws MojoExecutionException, MojoFailureException */ protected abstract void doExecute() throws MojoExecutionException, MojoFailureException; - /** - * Does the actual copy of the file and logging. - * - * @param artifact represents the file to copy. - * @param destFile file name of destination file. - * @throws MojoExecutionException with a message if an error occurs. - */ - protected void copyFile(File artifact, File destFile) throws MojoExecutionException { - try { - getLog().info("Copying " - + (this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName()) + " to " - + destFile); - - if (artifact.isDirectory()) { - // usual case is a future jar packaging, but there are special cases: classifier and other packaging - throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, " - + "copy should be executed after packaging: see MDEP-187."); - } - - FileUtils.copyFile(artifact, destFile); - buildContext.refresh(destFile); - } catch (IOException e) { - throw new MojoExecutionException("Error copying artifact from " + artifact + " to " + destFile, e); - } - } - /** * @return Returns a new ProjectBuildingRequest populated from the current session and the current project remote * repositories, used to resolve artifacts. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index 9cf85e210..b4d5bcab2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -19,13 +19,16 @@ package org.apache.maven.plugins.dependency.fromConfiguration; import java.io.File; +import java.io.IOException; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.utils.CopyUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; @@ -38,6 +41,8 @@ @Mojo(name = "copy", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresProject = false, threadSafe = true) public class CopyMojo extends AbstractFromConfigurationMojo { + @Component + private CopyUtil copyUtil; /** * Strip artifact version during copy */ @@ -109,12 +114,17 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { * * @param artifactItem containing the information about the Artifact to copy. * @throws MojoExecutionException with a message if an error occurs. - * @see #copyFile(File, File) + * @see CopyUtil#copyFile(File, File) */ protected void copyArtifact(ArtifactItem artifactItem) throws MojoExecutionException { File destFile = new File(artifactItem.getOutputDirectory(), artifactItem.getDestFileName()); - copyFile(artifactItem.getArtifact().getFile(), destFile); + try { + copyUtil.copyFile(artifactItem.getArtifact().getFile(), destFile); + } catch (IOException e) { + throw new MojoExecutionException( + "Failed copy " + artifactItem.getArtifact().getFile() + " to " + destFile, e); + } } @Override diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index ebf766e54..d92f5674f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.fromDependencies; import java.io.File; +import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -31,6 +32,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.CopyUtil; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; @@ -63,6 +65,9 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.copyPom", defaultValue = "false") protected boolean copyPom = true; + @Component + private CopyUtil copyUtil; + /** * */ @@ -202,7 +207,7 @@ protected void copyArtifact( * @param theUseBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. * @param removeClassifier specifies if the classifier should be removed from the file name when copying. * @throws MojoExecutionException with a message if an error occurs. - * @see #copyFile(File, File) + * @see CopyUtil#copyFile(File, File) * @see DependencyUtil#getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact) */ protected void copyArtifact( @@ -227,7 +232,11 @@ protected void copyArtifact( artifact); File destFile = new File(destDir, destFileName); - copyFile(artifact.getFile(), destFile); + try { + copyUtil.copyFile(artifact.getFile(), destFile); + } catch (IOException e) { + throw new MojoExecutionException("Failed copy " + artifact.getFile() + " to " + destFile, e); + } } /** @@ -267,7 +276,12 @@ public void copyPoms(File destDir, Set artifacts, boolean removeVersio DependencyUtil.getFormattedFileName( pomArtifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier)); if (!pomDestFile.exists()) { - copyFile(pomArtifact.getFile(), pomDestFile); + try { + copyUtil.copyFile(pomArtifact.getFile(), pomDestFile); + } catch (IOException e) { + throw new MojoExecutionException( + "Failed copy " + pomArtifact.getFile() + " to " + pomDestFile, e); + } } } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 98e0d521e..6f49a4767 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -70,6 +70,14 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { @Parameter(property = "mdep.outputScope", defaultValue = "true") protected boolean outputScope; + /** + * Output absolute filename for resolved artifacts + * + * @since 2.0 + */ + @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") + private boolean outputAbsoluteArtifactFilename; + /** * Only used to store results for integration test validation */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index bb2d7c574..69994d962 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -49,6 +49,14 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") private String outputEncoding; + /** + * Output absolute filename for resolved artifacts + * + * @since 2.0 + */ + @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") + private boolean outputAbsoluteArtifactFilename; + /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java new file mode 100644 index 000000000..8078081e1 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -0,0 +1,73 @@ +/* + * 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.dependency.utils; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.util.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonatype.plexus.build.incremental.BuildContext; + +/** + * Provide a copyFile method in one place. + * + * @since 3.7.0 + */ +@Named +@Singleton +public class CopyUtil { + + private final Logger logger = LoggerFactory.getLogger(CopyUtil.class); + + private final BuildContext buildContext; + + @Inject + public CopyUtil(BuildContext buildContext) { + this.buildContext = buildContext; + } + + /** + * Does the actual copy of the file and logging. + * + * @param source represents the file to copy. + * @param destination file name of destination file. + * @throws IOException with a message if an error occurs. + * + * @since 3.7.0 + */ + public void copyFile(File source, File destination) throws IOException, MojoExecutionException { + logger.info("Copying {} to {}", source, destination); + + if (source.isDirectory()) { + // usual case is a future jar packaging, but there are special cases: classifier and other packaging + throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, " + + "copy should be executed after packaging: see MDEP-187."); + } + + FileUtils.copyFile(source, destination); + buildContext.refresh(destination); + } +} diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 0a4d55cc1..5fb0180ea 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -26,12 +26,14 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.utils.CopyUtil; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; +import org.sonatype.plexus.build.incremental.DefaultBuildContext; public abstract class AbstractDependencyMojoTestCase extends AbstractMojoTestCase { @@ -67,8 +69,8 @@ protected void tearDown() { } } - protected void copyFile(AbstractDependencyMojo mojo, File artifact, File destFile) throws MojoExecutionException { - mojo.copyFile(artifact, destFile); + protected void copyFile(File artifact, File destFile) throws MojoExecutionException, IOException { + new CopyUtil(new DefaultBuildContext()).copyFile(artifact, destFile); } protected void installLocalRepository(LegacySupport legacySupport) throws ComponentLookupException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index f83743a05..c2f7c6946 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -80,14 +80,14 @@ public void assertNoMarkerFile(Artifact artifact) throws MojoExecutionException assertFalse(handle.isMarkerSet()); } - public void testCopyFile() throws MojoExecutionException, IOException { + public void testCopyFile() throws Exception { File src = File.createTempFile("copy", null); File dest = new File(mojo.outputDirectory, "toMe.jar"); assertFalse(dest.exists()); - copyFile(mojo, src, dest); + copyFile(src, dest); assertTrue(dest.exists()); } From f29c80b23109b7613fdf06504dc4bef46f1681d7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 30 May 2024 00:23:08 +0200 Subject: [PATCH 113/283] [MDEP-710] re-enable test in TestTreeMojo --- .../apache/maven/plugins/dependency/tree/TestTreeMojo.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index dc8051523..003f57c66 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -76,11 +76,10 @@ protected void setUp() throws Exception { /** * Tests the proper discovery and configuration of the mojo. - * // TODO: tests disabled during MDEP-339 work, to be reactivated * * @throws Exception in case of an error. */ - public void _testTreeTestEnvironment() throws Exception { + public void testTreeTestEnvironment() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml"); TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom); @@ -101,8 +100,8 @@ public void _testTreeTestEnvironment() throws Exception { DependencyNode rootNode = mojo.getDependencyGraph(); assertNodeEquals("testGroupId:project:jar:1.0:compile", rootNode); assertEquals(2, rootNode.getChildren().size()); - assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 0); - assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 1); + assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 0); + assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 1); } /** From 1c4b24d3d76b19d72bcfc9174ef0bda4c49450d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 10:30:09 +0200 Subject: [PATCH 114/283] [MDEP-920] Bump org.assertj:assertj-core from 3.25.3 to 3.26.0 (#395) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.3 to 3.26.0. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.3...assertj-build-3.26.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44ff40a49..b7caf1b09 100644 --- a/pom.xml +++ b/pom.xml @@ -395,7 +395,7 @@ under the License. org.assertj assertj-core - 3.25.3 + 3.26.0 test From bd94ad908ae6fd360d74fdb087bac507a232669b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 30 May 2024 12:48:30 +0200 Subject: [PATCH 115/283] [MDEP-799] Add simple info json format for tree and cleanups --- .../plugins/dependency/tree/TreeMojo.java | 55 +++++-------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 3ee40cf5b..59c05448f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -23,7 +23,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -57,15 +56,14 @@ import org.apache.maven.shared.dependency.graph.traversal.FilteringDependencyNodeVisitor; import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor; import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor.GraphTokens; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; /** * Displays the dependency tree for this project. Multiple formats are supported: text (by default), but also * DOT, - * GraphML, and - * TGF. + * GraphML, + * TGF and + * JSON. + * * * @author Mark Hobson * @since 2.0-alpha-5 @@ -86,30 +84,6 @@ public class TreeMojo extends AbstractMojo { @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") private String outputEncoding; - /** - * Contains the full list of projects in the reactor. - */ - @Parameter(defaultValue = "${reactorProjects}", readonly = true, required = true) - private List reactorProjects; - - @Component - private RepositorySystem repositorySystem; - - @Parameter(defaultValue = "${repositorySystem}") - RepositorySystem repositorySystemParam; - - /** - * The current repository/network configuration of Maven. - */ - @Parameter(defaultValue = "${repositorySystemSession}") - private RepositorySystemSession repoSession; - - /** - * The project's remote repositories to use for the resolution of project dependencies. - */ - @Parameter(defaultValue = "${project.remoteProjectRepositories}") - private List projectRepos; - /** * The dependency collector builder to use. */ @@ -133,7 +107,8 @@ public class TreeMojo extends AbstractMojo { /** * If specified, this parameter will cause the dependency tree to be written using the specified format. Currently - * supported format are: text (default), dot, graphml and tgf. + * supported formats are: text (default), dot, graphml, tgf + * and json. * These additional formats can be plotted to image files. * * @since 2.2 @@ -187,7 +162,7 @@ public class TreeMojo extends AbstractMojo { * @since 2.0-alpha-6 */ @Parameter(property = "includes") - private String includes; + private List includes; /** * A comma-separated list of artifacts to filter from the serialized dependency tree, or null not to @@ -208,7 +183,7 @@ public class TreeMojo extends AbstractMojo { * @since 2.0-alpha-6 */ @Parameter(property = "excludes") - private String excludes; + private List excludes; /** * The computed dependency tree root node of the Maven project. @@ -417,22 +392,20 @@ private DependencyNodeFilter createDependencyNodeFilter() { List filters = new ArrayList<>(); // filter includes - if (includes != null) { - List patterns = Arrays.asList(includes.split(",")); + if (includes != null && !includes.isEmpty()) { - getLog().debug("+ Filtering dependency tree by artifact include patterns: " + patterns); + getLog().debug("+ Filtering dependency tree by artifact include patterns: " + includes); - ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter(patterns); + ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter(includes); filters.add(new ArtifactDependencyNodeFilter(artifactFilter)); } // filter excludes - if (excludes != null) { - List patterns = Arrays.asList(excludes.split(",")); + if (excludes != null && !excludes.isEmpty()) { - getLog().debug("+ Filtering dependency tree by artifact exclude patterns: " + patterns); + getLog().debug("+ Filtering dependency tree by artifact exclude patterns: " + excludes); - ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter(patterns); + ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter(excludes); filters.add(new ArtifactDependencyNodeFilter(artifactFilter)); } From 3da6db70283e9a7013260b57afefea46176d2453 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 31 May 2024 08:48:41 +0200 Subject: [PATCH 116/283] [MDEP-935] Improvement ITs for dependency:tree - add tests for excludes and scope --- pom.xml | 12 +--- src/it/projects/tree-excluded/expected.txt | 13 ++++ .../projects/tree-excluded/invoker.properties | 18 ++++++ src/it/projects/tree-excluded/pom.xml | 47 ++++++++++++++ src/it/projects/tree-excluded/test.properties | 19 ++++++ src/it/projects/tree-excluded/verify.groovy | 25 ++++++++ src/it/projects/tree-includes/verify.groovy | 25 ++++++++ src/it/projects/tree-multimodule/verify.bsh | 63 ------------------- .../verify.groovy} | 20 +++--- src/it/projects/tree-scope/expected1.txt | 37 +++++++++++ src/it/projects/tree-scope/expected2.txt | 39 ++++++++++++ src/it/projects/tree-scope/invoker.properties | 22 +++++++ src/it/projects/tree-scope/pom.xml | 55 ++++++++++++++++ src/it/projects/tree-scope/test1.properties | 20 ++++++ src/it/projects/tree-scope/test2.properties | 20 ++++++ .../verify.bsh => tree-scope/verify.groovy} | 18 ++---- .../tree-verbose-multimodule/verify.bsh | 57 ----------------- .../verify.groovy} | 19 +++--- .../projects/tree-verbose-small/verify.groovy | 25 ++++++++ src/it/projects/tree-verbose/verify.groovy | 25 ++++++++ 20 files changed, 412 insertions(+), 167 deletions(-) create mode 100644 src/it/projects/tree-excluded/expected.txt create mode 100644 src/it/projects/tree-excluded/invoker.properties create mode 100644 src/it/projects/tree-excluded/pom.xml create mode 100644 src/it/projects/tree-excluded/test.properties create mode 100644 src/it/projects/tree-excluded/verify.groovy create mode 100644 src/it/projects/tree-includes/verify.groovy delete mode 100644 src/it/projects/tree-multimodule/verify.bsh rename src/it/projects/{tree-includes/verify.bsh => tree-multimodule/verify.groovy} (64%) create mode 100644 src/it/projects/tree-scope/expected1.txt create mode 100644 src/it/projects/tree-scope/expected2.txt create mode 100644 src/it/projects/tree-scope/invoker.properties create mode 100644 src/it/projects/tree-scope/pom.xml create mode 100644 src/it/projects/tree-scope/test1.properties create mode 100644 src/it/projects/tree-scope/test2.properties rename src/it/projects/{tree-verbose-small/verify.bsh => tree-scope/verify.groovy} (58%) delete mode 100644 src/it/projects/tree-verbose-multimodule/verify.bsh rename src/it/projects/{tree-verbose/verify.bsh => tree-verbose-multimodule/verify.groovy} (59%) create mode 100644 src/it/projects/tree-verbose-small/verify.groovy create mode 100644 src/it/projects/tree-verbose/verify.groovy diff --git a/pom.xml b/pom.xml index b7caf1b09..b447742a2 100644 --- a/pom.xml +++ b/pom.xml @@ -445,16 +445,7 @@ under the License. These files contain results for integration tests which can't contain license header otherwise the IT's will fail. --> - src/it/projects/tree/expected.txt - src/it/projects/tree-includes/expected.txt - src/it/projects/tree-multimodule/expected.txt - src/it/projects/tree-multimodule/module-a/expected.txt - src/it/projects/tree-multimodule/module-b/expected.txt - src/it/projects/tree-verbose-multimodule/expected.txt - src/it/projects/tree-verbose-multimodule/module-a/expected.txt - src/it/projects/tree-verbose-multimodule/module-b/expected.txt - src/it/projects/tree-verbose/expected*.txt - src/it/projects/tree-verbose-small/expected.txt + src/it/projects/**/expected*.txt src/test/resources/unit/verbose-serializer-test/* diff --git a/src/it/projects/tree-excluded/expected.txt b/src/it/projects/tree-excluded/expected.txt new file mode 100644 index 000000000..38be1dd0d --- /dev/null +++ b/src/it/projects/tree-excluded/expected.txt @@ -0,0 +1,13 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + +- org.apache.maven:maven-profile:jar:2.0.6:compile + +- org.apache.maven:maven-model:jar:2.0.6:compile + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + \- classworlds:classworlds:jar:1.1-alpha-2:compile diff --git a/src/it/projects/tree-excluded/invoker.properties b/src/it/projects/tree-excluded/invoker.properties new file mode 100644 index 000000000..afb73d253 --- /dev/null +++ b/src/it/projects/tree-excluded/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:tree diff --git a/src/it/projects/tree-excluded/pom.xml b/src/it/projects/tree-excluded/pom.xml new file mode 100644 index 000000000..dac11a5b1 --- /dev/null +++ b/src/it/projects/tree-excluded/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + dependency:tree -Dexcludes + + Test dependency:tree -Dexcludes=... + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff --git a/src/it/projects/tree-excluded/test.properties b/src/it/projects/tree-excluded/test.properties new file mode 100644 index 000000000..42a01ce23 --- /dev/null +++ b/src/it/projects/tree-excluded/test.properties @@ -0,0 +1,19 @@ +# 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. + +outputFile = target/tree.txt +excludes = org.codehaus.plexus:* diff --git a/src/it/projects/tree-excluded/verify.groovy b/src/it/projects/tree-excluded/verify.groovy new file mode 100644 index 000000000..b79d25ba4 --- /dev/null +++ b/src/it/projects/tree-excluded/verify.groovy @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import static org.assertj.core.api.Assertions.assertThat + +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) + +return true diff --git a/src/it/projects/tree-includes/verify.groovy b/src/it/projects/tree-includes/verify.groovy new file mode 100644 index 000000000..b79d25ba4 --- /dev/null +++ b/src/it/projects/tree-includes/verify.groovy @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import static org.assertj.core.api.Assertions.assertThat + +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) + +return true diff --git a/src/it/projects/tree-multimodule/verify.bsh b/src/it/projects/tree-multimodule/verify.bsh deleted file mode 100644 index a4fce7eda..000000000 --- a/src/it/projects/tree-multimodule/verify.bsh +++ /dev/null @@ -1,63 +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. - */ - -import java.io.*; - -import org.codehaus.plexus.util.*; - -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -System.out.println( "Checking root dependency tree..." ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected root dependency tree" ); -} - -actual = FileUtils.fileRead( new File( basedir, "module-a/target/tree.txt" ) ); -expected = FileUtils.fileRead( new File( basedir, "module-a/expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -System.out.println( "Checking module-a dependency tree..." ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected module-a dependency tree" ); -} - -actual = FileUtils.fileRead( new File( basedir, "module-b/target/tree.txt" ) ); -expected = FileUtils.fileRead( new File( basedir, "module-b/expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -System.out.println( "Checking module-b dependency tree..." ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected module-b dependency tree" ); -} - -return true; diff --git a/src/it/projects/tree-includes/verify.bsh b/src/it/projects/tree-multimodule/verify.groovy similarity index 64% rename from src/it/projects/tree-includes/verify.bsh rename to src/it/projects/tree-multimodule/verify.groovy index 39689abaf..868ac9d9c 100644 --- a/src/it/projects/tree-includes/verify.bsh +++ b/src/it/projects/tree-multimodule/verify.groovy @@ -17,21 +17,15 @@ * under the License. */ -import java.io.*; +import static org.assertj.core.api.Assertions.assertThat -import org.codehaus.plexus.util.*; +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); +assertThat(new File(basedir, "module-a/target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "module-a/expected.txt")) -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -System.out.println( "Checking dependency tree..." ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected dependency tree" ); -} +assertThat(new File(basedir, "module-b/target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "module-b/expected.txt")) return true; diff --git a/src/it/projects/tree-scope/expected1.txt b/src/it/projects/tree-scope/expected1.txt new file mode 100644 index 000000000..a86117e10 --- /dev/null +++ b/src/it/projects/tree-scope/expected1.txt @@ -0,0 +1,37 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-core:jar:3.6.3:compile + +- org.apache.maven:maven-model:jar:3.6.3:compile + +- org.apache.maven:maven-settings:jar:3.6.3:compile + +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile + | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile + | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile + | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile + +- org.apache.maven:maven-builder-support:jar:3.6.3:compile + +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile + +- org.apache.maven:maven-artifact:jar:3.6.3:compile + +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile + +- org.apache.maven:maven-model-builder:jar:3.6.3:compile + +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile + +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile + +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile + | \- commons-io:commons-io:jar:2.5:compile + +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile + | \- javax.enterprise:cdi-api:jar:1.0:compile + | \- javax.annotation:jsr250-api:jar:1.0:compile + +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile + +- com.google.inject:guice:jar:no_aop:4.2.1:compile + | +- aopalliance:aopalliance:jar:1.0:compile + | \- com.google.guava:guava:jar:25.1-android:compile + | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile + | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile + | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile + | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile + | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile + +- javax.inject:javax.inject:jar:1:compile + +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile + +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile + +- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile + \- org.apache.commons:commons-lang3:jar:3.8.1:compile diff --git a/src/it/projects/tree-scope/expected2.txt b/src/it/projects/tree-scope/expected2.txt new file mode 100644 index 000000000..03f4e394b --- /dev/null +++ b/src/it/projects/tree-scope/expected2.txt @@ -0,0 +1,39 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT ++- org.apache.maven:maven-core:jar:3.6.3:compile +| +- org.apache.maven:maven-model:jar:3.6.3:compile +| +- org.apache.maven:maven-settings:jar:3.6.3:compile +| +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile +| | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile +| | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile +| | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile +| +- org.apache.maven:maven-builder-support:jar:3.6.3:compile +| +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile +| +- org.apache.maven:maven-artifact:jar:3.6.3:compile +| +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile +| +- org.apache.maven:maven-model-builder:jar:3.6.3:compile +| +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile +| +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile +| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile +| | \- commons-io:commons-io:jar:2.5:compile +| +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile +| | \- javax.enterprise:cdi-api:jar:1.0:compile +| | \- javax.annotation:jsr250-api:jar:1.0:compile +| +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile +| +- com.google.inject:guice:jar:no_aop:4.2.1:compile +| | +- aopalliance:aopalliance:jar:1.0:compile +| | \- com.google.guava:guava:jar:25.1-android:compile +| | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile +| | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile +| | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile +| | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile +| | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile +| +- javax.inject:javax.inject:jar:1:compile +| +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile +| +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile +| +- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile +| \- org.apache.commons:commons-lang3:jar:3.8.1:compile +\- org.slf4j:slf4j-simple:jar:2.0.13:test + \- org.slf4j:slf4j-api:jar:2.0.13:compile diff --git a/src/it/projects/tree-scope/invoker.properties b/src/it/projects/tree-scope/invoker.properties new file mode 100644 index 000000000..2535673ad --- /dev/null +++ b/src/it/projects/tree-scope/invoker.properties @@ -0,0 +1,22 @@ +# 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. + +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:tree +invoker.systemPropertiesFile.1 = test1.properties + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:tree +invoker.systemPropertiesFile.2 = test2.properties diff --git a/src/it/projects/tree-scope/pom.xml b/src/it/projects/tree-scope/pom.xml new file mode 100644 index 000000000..6b915596c --- /dev/null +++ b/src/it/projects/tree-scope/pom.xml @@ -0,0 +1,55 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:tree with scope + + + + UTF-8 + + + + + org.apache.maven + maven-core + 3.6.3 + + + + org.slf4j + slf4j-simple + 2.0.13 + test + + + + + diff --git a/src/it/projects/tree-scope/test1.properties b/src/it/projects/tree-scope/test1.properties new file mode 100644 index 000000000..4f3ff1dc1 --- /dev/null +++ b/src/it/projects/tree-scope/test1.properties @@ -0,0 +1,20 @@ +# 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. + +outputFile = target/tree1.txt +scope = compile +maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree-scope/test2.properties b/src/it/projects/tree-scope/test2.properties new file mode 100644 index 000000000..e9d6c7d05 --- /dev/null +++ b/src/it/projects/tree-scope/test2.properties @@ -0,0 +1,20 @@ +# 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. + +outputFile = target/tree2.txt +scope = test +maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree-verbose-small/verify.bsh b/src/it/projects/tree-scope/verify.groovy similarity index 58% rename from src/it/projects/tree-verbose-small/verify.bsh rename to src/it/projects/tree-scope/verify.groovy index cf0ab8f67..c6ed22429 100644 --- a/src/it/projects/tree-verbose-small/verify.bsh +++ b/src/it/projects/tree-scope/verify.groovy @@ -17,19 +17,13 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); +import static org.assertj.core.api.Assertions.assertThat -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); +assertThat(new File(basedir, "target/tree1.txt")) + .hasSameTextualContentAs(new File(basedir, "expected1.txt")) -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected dependency tree." + System.lineSeparator() + "Expected:" + System.lineSeparator() - + expected + System.lineSeparator() + "Actual:" + System.lineSeparator() + actual ); -} +assertThat(new File(basedir, "target/tree2.txt")) + .hasSameTextualContentAs(new File(basedir, "expected2.txt")) -return true; +return true \ No newline at end of file diff --git a/src/it/projects/tree-verbose-multimodule/verify.bsh b/src/it/projects/tree-verbose-multimodule/verify.bsh deleted file mode 100644 index fcbece716..000000000 --- a/src/it/projects/tree-verbose-multimodule/verify.bsh +++ /dev/null @@ -1,57 +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. - */ - -import java.io.*; - -import org.codehaus.plexus.util.*; - -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected root dependency tree" ); -} - -actual = FileUtils.fileRead( new File( basedir, "module-a/target/tree.txt" ) ); -expected = FileUtils.fileRead( new File( basedir, "module-a/expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected module-a dependency tree" ); -} - -actual = FileUtils.fileRead( new File( basedir, "module-b/target/tree.txt" ) ); -expected = FileUtils.fileRead( new File( basedir, "module-b/expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected module-b dependency tree" ); -} - -return true; diff --git a/src/it/projects/tree-verbose/verify.bsh b/src/it/projects/tree-verbose-multimodule/verify.groovy similarity index 59% rename from src/it/projects/tree-verbose/verify.bsh rename to src/it/projects/tree-verbose-multimodule/verify.groovy index 26391a483..868ac9d9c 100644 --- a/src/it/projects/tree-verbose/verify.bsh +++ b/src/it/projects/tree-verbose-multimodule/verify.groovy @@ -17,20 +17,15 @@ * under the License. */ -import java.io.*; +import static org.assertj.core.api.Assertions.assertThat -import org.codehaus.plexus.util.*; +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); +assertThat(new File(basedir, "module-a/target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "module-a/expected.txt")) -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected dependency tree." + System.lineSeparator() + "Expected:" + System.lineSeparator() - + expected + System.lineSeparator() + "Actual:" + System.lineSeparator() + actual ); -} +assertThat(new File(basedir, "module-b/target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "module-b/expected.txt")) return true; diff --git a/src/it/projects/tree-verbose-small/verify.groovy b/src/it/projects/tree-verbose-small/verify.groovy new file mode 100644 index 000000000..0da3382c4 --- /dev/null +++ b/src/it/projects/tree-verbose-small/verify.groovy @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import static org.assertj.core.api.Assertions.assertThat + +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) + +return true \ No newline at end of file diff --git a/src/it/projects/tree-verbose/verify.groovy b/src/it/projects/tree-verbose/verify.groovy new file mode 100644 index 000000000..b79d25ba4 --- /dev/null +++ b/src/it/projects/tree-verbose/verify.groovy @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import static org.assertj.core.api.Assertions.assertThat + +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) + +return true From f82a019b5b6feccc516ecf0e71b1f56e3718cadb Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 1 Jun 2024 22:37:03 +0200 Subject: [PATCH 117/283] Add missing dependency --- pom.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b447742a2..a8b4a191c 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ under the License. 4.9.2 3.3.0 1.4.1 - 1.7.36 + 1.7.36 2023-10-20T21:21:50Z @@ -313,6 +313,11 @@ under the License. compile + + org.slf4j + slf4j-api + ${slf4jVersion} + @@ -428,7 +433,7 @@ under the License. org.slf4j slf4j-simple - ${slf4j.version} + ${slf4jVersion} test From 31fa4f726e74d0067660938eb903607a39c53fef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:01:09 +0200 Subject: [PATCH 118/283] [MDEP-936] Bump org.apache.maven.shared:maven-dependency-tree from 3.2.1 to 3.3.0 (#397) Bumps [org.apache.maven.shared:maven-dependency-tree](https://github.com/apache/maven-dependency-tree) from 3.2.1 to 3.3.0. - [Release notes](https://github.com/apache/maven-dependency-tree/releases) - [Commits](https://github.com/apache/maven-dependency-tree/compare/maven-dependency-tree-3.2.1...maven-dependency-tree-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-dependency-tree dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8b4a191c..a1c5d7939 100644 --- a/pom.xml +++ b/pom.xml @@ -247,7 +247,7 @@ under the License. org.apache.maven.shared maven-dependency-tree - 3.2.1 + 3.3.0 org.eclipse.aether From 07dbccc8db436374a22ea6a698e50e3a15af755b Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 2 Jun 2024 18:13:33 +0200 Subject: [PATCH 119/283] Remove useless exclude --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index a1c5d7939..6208fa001 100644 --- a/pom.xml +++ b/pom.xml @@ -248,12 +248,6 @@ under the License. org.apache.maven.shared maven-dependency-tree 3.3.0 - - - org.eclipse.aether - aether-util - - org.apache.maven.shared From d95615fa6b4c9c2e41a124116e948d146e79018c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 2 Jun 2024 20:12:28 +0200 Subject: [PATCH 120/283] [MDEP-835] Add optional dependency for tree IT --- src/it/projects/tree/expected.txt | 50 ++++++++++++++----- src/it/projects/tree/pom.xml | 10 +++- src/it/projects/tree/test.properties | 1 + .../tree/{verify.bsh => verify.groovy} | 20 ++------ 4 files changed, 50 insertions(+), 31 deletions(-) rename src/it/projects/tree/{verify.bsh => verify.groovy} (63%) diff --git a/src/it/projects/tree/expected.txt b/src/it/projects/tree/expected.txt index 4f2038776..a1fe1338f 100644 --- a/src/it/projects/tree/expected.txt +++ b/src/it/projects/tree/expected.txt @@ -1,14 +1,38 @@ org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT -\- org.apache.maven:maven-project:jar:2.0.6:compile - +- org.apache.maven:maven-settings:jar:2.0.6:compile - +- org.apache.maven:maven-profile:jar:2.0.6:compile - +- org.apache.maven:maven-model:jar:2.0.6:compile - +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile - | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile - | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile - +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile - +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - +- org.apache.maven:maven-artifact:jar:2.0.6:compile - \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - +- junit:junit:jar:3.8.1:compile - \- classworlds:classworlds:jar:1.1-alpha-2:compile ++- org.apache.maven:maven-core:jar:3.6.3:compile +| +- org.apache.maven:maven-model:jar:3.6.3:compile +| +- org.apache.maven:maven-settings:jar:3.6.3:compile +| +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile +| | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile +| | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile +| | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile +| +- org.apache.maven:maven-builder-support:jar:3.6.3:compile +| +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile +| +- org.apache.maven:maven-artifact:jar:3.6.3:compile +| +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile +| +- org.apache.maven:maven-model-builder:jar:3.6.3:compile +| +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile +| | \- org.slf4j:slf4j-api:jar:1.7.29:compile +| +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile +| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile +| | \- commons-io:commons-io:jar:2.5:compile +| +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile +| | \- javax.enterprise:cdi-api:jar:1.0:compile +| | \- javax.annotation:jsr250-api:jar:1.0:compile +| +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile +| +- com.google.inject:guice:jar:no_aop:4.2.1:compile +| | +- aopalliance:aopalliance:jar:1.0:compile +| | \- com.google.guava:guava:jar:25.1-android:compile +| | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile +| | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile +| | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile +| | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile +| | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile +| +- javax.inject:javax.inject:jar:1:compile +| +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile +| +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile +| \- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile +\- org.apache.commons:commons-lang3:jar:3.14.0:compile (optional) \ No newline at end of file diff --git a/src/it/projects/tree/pom.xml b/src/it/projects/tree/pom.xml index 30794e64b..d18c8ffdd 100644 --- a/src/it/projects/tree/pom.xml +++ b/src/it/projects/tree/pom.xml @@ -39,8 +39,14 @@ org.apache.maven - maven-project - 2.0.6 + maven-core + 3.6.3 + + + org.apache.commons + commons-lang3 + 3.14.0 + true diff --git a/src/it/projects/tree/test.properties b/src/it/projects/tree/test.properties index 2a312e22e..2cc9c4a0d 100644 --- a/src/it/projects/tree/test.properties +++ b/src/it/projects/tree/test.properties @@ -16,3 +16,4 @@ # under the License. outputFile = target/tree.txt +maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree/verify.bsh b/src/it/projects/tree/verify.groovy similarity index 63% rename from src/it/projects/tree/verify.bsh rename to src/it/projects/tree/verify.groovy index 39689abaf..b79d25ba4 100644 --- a/src/it/projects/tree/verify.bsh +++ b/src/it/projects/tree/verify.groovy @@ -17,21 +17,9 @@ * under the License. */ -import java.io.*; +import static org.assertj.core.api.Assertions.assertThat -import org.codehaus.plexus.util.*; +assertThat(new File(basedir, "target/tree.txt")) + .hasSameTextualContentAs(new File(basedir, "expected.txt")) -String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); -String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); - -actual = actual.replaceAll( "[\n\r]+", "\n" ); -expected = expected.replaceAll( "[\n\r]+", "\n" ); - -System.out.println( "Checking dependency tree..." ); - -if ( !actual.equals( expected ) ) -{ - throw new Exception( "Unexpected dependency tree" ); -} - -return true; +return true From ad5fdc57ef8bee311138b8586e9dba8a219dda4d Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Thu, 26 Jan 2023 19:36:19 -0500 Subject: [PATCH 121/283] [MDEP-938] Correct invalid property name and add deprecated old one should be 'overWriteIfNewer' instead of 'overIfNewer' for clarity. --- .../AbstractFromConfigurationMojo.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 5cf6c91f4..debac7748 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -79,8 +79,18 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo * Overwrite if newer * * @since 2.0 + * @deprecated Use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing now. */ + @Deprecated @Parameter(property = "mdep.overIfNewer", defaultValue = "true") + private boolean overIfNewer; + + /** + * Overwrite if newer + * + * @since 3.7.0 + */ + @Parameter(property = "mdep.overWriteIfNewer", defaultValue = "true") private boolean overWriteIfNewer; /** From fd17de46e7ac8cc8778ab697192b4c343ff6f94d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 6 Jun 2024 22:15:22 +0200 Subject: [PATCH 122/283] [MDEP-923] Move methods in place where are used --- .../fromConfiguration/CopyMojo.java | 6 -- .../CopyDependenciesMojo.java | 6 -- .../resolvers/AbstractResolveMojo.java | 78 +------------------ .../resolvers/ResolvePluginsMojo.java | 66 +++++++++++++++- 4 files changed, 66 insertions(+), 90 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index b4d5bcab2..d7a3ba61d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -79,12 +79,6 @@ public class CopyMojo extends AbstractFromConfigurationMojo { @Parameter(property = "artifact") private String artifact; - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - /** * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * copyArtifact. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index d92f5674f..97956ec72 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -97,12 +97,6 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.addParentPoms", defaultValue = "false") protected boolean addParentPoms; - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 9ed8d961a..a452968ee 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -19,28 +19,15 @@ package org.apache.maven.plugins.dependency.resolvers; import java.io.File; -import java.util.LinkedHashSet; -import java.util.Set; -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; -import org.apache.maven.plugins.dependency.utils.DependencyUtil; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; -import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; -import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; -import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; -import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; /** * @author Brian Fox */ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { + /** * If specified, this parameter causes the dependencies to be written to the path specified instead of * the console. @@ -65,67 +52,4 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { */ @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; - - /** - * not used in this goal - */ - @Parameter - protected boolean ignorePermissions; - - /** - * @return {@link FilterArtifacts} - */ - protected FilterArtifacts getArtifactsFilter() { - final FilterArtifacts filter = new FilterArtifacts(); - - if (excludeReactor) { - - filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); - } - - filter.addFilter(new ScopeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeScope), - DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); - - filter.addFilter(new TypeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeTypes), - DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); - - filter.addFilter(new ClassifierFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), - DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); - - filter.addFilter(new GroupIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); - - filter.addFilter(new ArtifactIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); - - return filter; - } - - /** - * This method resolves all transitive dependencies of an artifact. - * - * @param artifact the artifact used to retrieve dependencies - * @return resolved set of dependencies - * @throws DependencyResolverException in case of error while resolving artifacts. - */ - protected Set resolveArtifactDependencies(final DependableCoordinate artifact) - throws DependencyResolverException { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - Iterable artifactResults = - getDependencyResolver().resolveDependencies(buildingRequest, artifact, null); - - Set artifacts = new LinkedHashSet<>(); - - for (final ArtifactResult artifactResult : artifactResults) { - artifacts.add(artifactResult.getArtifact()); - } - - return artifacts; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 69994d962..cae06b224 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -31,10 +31,17 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; +import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; +import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; +import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; /** @@ -137,6 +144,63 @@ protected void doExecute() throws MojoExecutionException { } } + /** + * This method resolves all transitive dependencies of an artifact. + * + * @param artifact the artifact used to retrieve dependencies + * @return resolved set of dependencies + * @throws DependencyResolverException in case of error while resolving artifacts. + */ + private Set resolveArtifactDependencies(final DependableCoordinate artifact) + throws DependencyResolverException { + ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); + + Iterable artifactResults = + getDependencyResolver().resolveDependencies(buildingRequest, artifact, null); + + Set artifacts = new LinkedHashSet<>(); + + for (final ArtifactResult artifactResult : artifactResults) { + artifacts.add(artifactResult.getArtifact()); + } + + return artifacts; + } + + /** + * @return {@link FilterArtifacts} + */ + private FilterArtifacts getArtifactsFilter() { + final FilterArtifacts filter = new FilterArtifacts(); + + if (excludeReactor) { + + filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); + } + + filter.addFilter(new ScopeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeScope), + DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); + + filter.addFilter(new TypeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeTypes), + DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); + + filter.addFilter(new ClassifierFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), + DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); + + filter.addFilter(new GroupIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); + + filter.addFilter(new ArtifactIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); + + return filter; + } + /** * This method resolves the plugin artifacts from the project. * @@ -144,7 +208,7 @@ protected void doExecute() throws MojoExecutionException { * @throws ArtifactFilterException in case of an error * @throws ArtifactResolverException in case of an error */ - protected Set resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException { + private Set resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException { final Set plugins = getProject().getPluginArtifacts(); final Set reports = getProject().getReportArtifacts(); From 9fd4ed53b23e35de8ad8179e5b379acf3721ffbe Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 7 Jun 2024 23:02:49 +0200 Subject: [PATCH 123/283] Revert "Fix sources goal for multimodule projects" This reverts commit 0bb4c5917222c4f4a6df53bbc70dd770507a3d4d. --- src/it/projects/sources/module-a/pom.xml | 48 ------------------- src/it/projects/sources/module-b/pom.xml | 48 ------------------- src/it/projects/sources/pom.xml | 18 +++---- .../ResolveDependencySourcesMojo.java | 2 +- 4 files changed, 11 insertions(+), 105 deletions(-) delete mode 100644 src/it/projects/sources/module-a/pom.xml delete mode 100644 src/it/projects/sources/module-b/pom.xml diff --git a/src/it/projects/sources/module-a/pom.xml b/src/it/projects/sources/module-a/pom.xml deleted file mode 100644 index 7c6fe3c1d..000000000 --- a/src/it/projects/sources/module-a/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.its.dependency - tree-multimodule - 1.0-SNAPSHOT - - - MultimoduleTest Module A - - tree-multimodule-module-a - - - UTF-8 - - - - - org.apache.maven - maven-project - 2.0.6 - - - - diff --git a/src/it/projects/sources/module-b/pom.xml b/src/it/projects/sources/module-b/pom.xml deleted file mode 100644 index bffea42af..000000000 --- a/src/it/projects/sources/module-b/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - 4.0.0 - - - org.apache.maven.its.dependency - tree-multimodule - 1.0-SNAPSHOT - - - MultimoduleTest Module B - - tree-multimodule-module-b - - - UTF-8 - - - - - org.apache.maven.its.dependency - tree-multimodule-module-a - ${project.version} - - - - diff --git a/src/it/projects/sources/pom.xml b/src/it/projects/sources/pom.xml index 062e10d43..f04fc4d88 100644 --- a/src/it/projects/sources/pom.xml +++ b/src/it/projects/sources/pom.xml @@ -24,22 +24,24 @@ 4.0.0 org.apache.maven.its.dependency - tree-multimodule + test 1.0-SNAPSHOT - pom - MultimoduleTest + Test - Test dependency:tree on multimodule project + Test dependency:sources UTF-8 - - module-a - module-b - + + + org.apache.maven + maven-project + 2.0.8 + + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index f4871de0b..21e8cce3b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -32,7 +32,7 @@ @Mojo( name = "sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, - requiresDependencyCollection = ResolutionScope.TEST, + requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { From 04c32164bcb3ecef6115616fee291d5ee071d370 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 7 Jun 2024 23:54:02 +0200 Subject: [PATCH 124/283] [MDEP-939] Lock down classifier in dependency:sources goal This closes #409 --- src/it/projects/sources/test.properties | 6 ++++-- .../ResolveDependencySourcesMojo.java | 19 +++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/it/projects/sources/test.properties b/src/it/projects/sources/test.properties index 238ec42e9..d6b4c923d 100644 --- a/src/it/projects/sources/test.properties +++ b/src/it/projects/sources/test.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,3 +16,5 @@ # under the License. outputFile = target/resolved.txt +# This is intentional to prove that no classifier is passed (read-only value) +classifier = foo diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index 21e8cce3b..cc1300e77 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -18,9 +18,9 @@ */ package org.apache.maven.plugins.dependency.resolvers; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; /** @@ -36,19 +36,10 @@ threadSafe = true) public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { - private static final String SOURCE_CLASSIFIER = "sources"; + private static final String SOURCES_CLASSIFIER = "sources"; - /** - * Main entry into mojo. Gets the list of dependencies and iterates through resolving the source jars. - * - * @throws MojoExecutionException with a message if an error occurs. - */ - @Override - protected void doExecute() throws MojoExecutionException { - if (this.classifier == null || this.classifier.isEmpty()) { - this.classifier = SOURCE_CLASSIFIER; - } - - super.doExecute(); + @Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true) + public void setClassifier(String classifier) { + this.classifier = classifier; } } From 9902456ae515769daa6068a278267c62fb300e67 Mon Sep 17 00:00:00 2001 From: Florian Lindermaier Date: Sun, 15 Jan 2023 11:53:42 +0100 Subject: [PATCH 125/283] [MDEP-669] Optimize the documentation of of build-classpath mojo Co-authored-by: Elliotte Rusty Harold This closes #283 --- .../plugins/dependency/fromDependencies/BuildClasspathMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 57c0d9c4d..698c2739e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -86,7 +86,7 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements private String prefix; /** - * A property to set to the content of the classpath string. + * If defined, the name of a property to which the classpath string will be written. */ @Parameter(property = "mdep.outputProperty") private String outputProperty; From f090b5efdeff0b2f2ebcc88a40f4b02dc4a6f408 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 8 Jun 2024 21:59:10 +0200 Subject: [PATCH 126/283] [MDEP-838] "Artifact has not been packaged yet" error message is not very helpful This closes #412 --- .../dependency/fromConfiguration/CopyMojo.java | 9 ++++++--- .../fromDependencies/CopyDependenciesMojo.java | 13 ++++++++----- .../maven/plugins/dependency/utils/CopyUtil.java | 16 ++++++++++------ .../AbstractDependencyMojoTestCase.java | 7 ++++--- .../TestCopyDependenciesMojo.java | 10 ++++++++-- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index d7a3ba61d..a9de46fe0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.List; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -108,16 +109,18 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { * * @param artifactItem containing the information about the Artifact to copy. * @throws MojoExecutionException with a message if an error occurs. - * @see CopyUtil#copyFile(File, File) + * @see CopyUtil#copyArtifactFile(Artifact, File) */ protected void copyArtifact(ArtifactItem artifactItem) throws MojoExecutionException { File destFile = new File(artifactItem.getOutputDirectory(), artifactItem.getDestFileName()); try { - copyUtil.copyFile(artifactItem.getArtifact().getFile(), destFile); + copyUtil.copyArtifactFile(artifactItem.getArtifact(), destFile); } catch (IOException e) { throw new MojoExecutionException( - "Failed copy " + artifactItem.getArtifact().getFile() + " to " + destFile, e); + "Failed to copy artifact '" + artifactItem.getArtifact() + "' (" + + artifactItem.getArtifact().getFile() + ") to " + destFile, + e); } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 97956ec72..48759af25 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -201,7 +201,7 @@ protected void copyArtifact( * @param theUseBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. * @param removeClassifier specifies if the classifier should be removed from the file name when copying. * @throws MojoExecutionException with a message if an error occurs. - * @see CopyUtil#copyFile(File, File) + * @see CopyUtil#copyArtifactFile(Artifact, File) * @see DependencyUtil#getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact) */ protected void copyArtifact( @@ -227,9 +227,10 @@ protected void copyArtifact( File destFile = new File(destDir, destFileName); try { - copyUtil.copyFile(artifact.getFile(), destFile); + copyUtil.copyArtifactFile(artifact, destFile); } catch (IOException e) { - throw new MojoExecutionException("Failed copy " + artifact.getFile() + " to " + destFile, e); + throw new MojoExecutionException( + "Failed to copy artifact '" + artifact + "' (" + artifact.getFile() + ") to " + destFile, e); } } @@ -271,10 +272,12 @@ public void copyPoms(File destDir, Set artifacts, boolean removeVersio pomArtifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier)); if (!pomDestFile.exists()) { try { - copyUtil.copyFile(pomArtifact.getFile(), pomDestFile); + copyUtil.copyArtifactFile(pomArtifact, pomDestFile); } catch (IOException e) { throw new MojoExecutionException( - "Failed copy " + pomArtifact.getFile() + " to " + pomDestFile, e); + "Failed to copy artifact '" + pomArtifact + "' (" + pomArtifact.getFile() + ") to " + + pomDestFile, + e); } } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java index 8078081e1..21d067ae7 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.plexus.util.FileUtils; import org.slf4j.Logger; @@ -50,20 +51,23 @@ public CopyUtil(BuildContext buildContext) { } /** - * Does the actual copy of the file and logging. + * Does the actual copy of the artifact (file) and logging. * - * @param source represents the file to copy. + * @param sourceArtifact represents the artifact (file) to copy. * @param destination file name of destination file. - * @throws IOException with a message if an error occurs. + * @throws IOException if copy has failed + * @throws MojoExecutionException if artifact file is a directory (which has not been packaged yet) * * @since 3.7.0 */ - public void copyFile(File source, File destination) throws IOException, MojoExecutionException { - logger.info("Copying {} to {}", source, destination); + public void copyArtifactFile(Artifact sourceArtifact, File destination) throws IOException, MojoExecutionException { + logger.info("Copying artifact '{}' ({}) to {}", sourceArtifact, sourceArtifact.getFile(), destination); + File source = sourceArtifact.getFile(); if (source.isDirectory()) { // usual case is a future jar packaging, but there are special cases: classifier and other packaging - throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, " + throw new MojoExecutionException("Artifact '" + sourceArtifact + + "' has not been packaged yet (is a directory). When used on reactor artifact, " + "copy should be executed after packaging: see MDEP-187."); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 5fb0180ea..cde5ea883 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -22,6 +22,7 @@ import java.io.IOException; import org.apache.commons.io.FileUtils; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -63,14 +64,14 @@ protected void tearDown() { FileUtils.deleteDirectory(testDir); } catch (IOException e) { e.printStackTrace(); - fail("Trying to remove directory:" + testDir + System.lineSeparator() + e); + fail("Trying to remove directory: " + testDir + System.lineSeparator() + e); } assertFalse(testDir.exists()); } } - protected void copyFile(File artifact, File destFile) throws MojoExecutionException, IOException { - new CopyUtil(new DefaultBuildContext()).copyFile(artifact, destFile); + protected void copyArtifactFile(Artifact sourceArtifact, File destFile) throws MojoExecutionException, IOException { + new CopyUtil(new DefaultBuildContext()).copyArtifactFile(sourceArtifact, destFile); } protected void installLocalRepository(LegacySupport legacySupport) throws ComponentLookupException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index c2f7c6946..e2a14f168 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -30,6 +30,7 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.stubs.ArtifactStub; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; @@ -80,14 +81,19 @@ public void assertNoMarkerFile(Artifact artifact) throws MojoExecutionException assertFalse(handle.isMarkerSet()); } - public void testCopyFile() throws Exception { + public void testCopyArtifactFile() throws Exception { + final Artifact srcArtifact = new ArtifactStub(); + srcArtifact.setGroupId("org.apache.maven.plugins"); + srcArtifact.setArtifactId("maven-dependency-plugin-dummy"); + srcArtifact.setVersion("1.0"); File src = File.createTempFile("copy", null); + srcArtifact.setFile(src); File dest = new File(mojo.outputDirectory, "toMe.jar"); assertFalse(dest.exists()); - copyFile(src, dest); + copyArtifactFile(srcArtifact, dest); assertTrue(dest.exists()); } From dbdda0ccba8bebb98c0f2390e000b0561bfc5f4b Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 8 Jun 2024 21:32:05 +0200 Subject: [PATCH 127/283] [MDEP-941] Deprecate dependency:sources in favor of dependency:resolve-sources This closes #411 --- .../invoker.properties | 6 +- .../{sources => resolve-sources}/pom.xml | 2 +- .../test.properties | 0 .../OldResolveDependencySourcesMojo.java | 38 ++++++ .../ResolveDependencySourcesMojo.java | 4 +- src/site/apt/index.apt.vm | 6 +- src/site/apt/usage.apt.vm | 108 +++++++++--------- 7 files changed, 102 insertions(+), 62 deletions(-) rename src/it/projects/{sources => resolve-sources}/invoker.properties (96%) rename src/it/projects/{sources => resolve-sources}/pom.xml (97%) rename src/it/projects/{sources => resolve-sources}/test.properties (100%) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java diff --git a/src/it/projects/sources/invoker.properties b/src/it/projects/resolve-sources/invoker.properties similarity index 96% rename from src/it/projects/sources/invoker.properties rename to src/it/projects/resolve-sources/invoker.properties index 4c31605a2..55dfe7a20 100644 --- a/src/it/projects/sources/invoker.properties +++ b/src/it/projects/resolve-sources/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sources +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve-sources diff --git a/src/it/projects/sources/pom.xml b/src/it/projects/resolve-sources/pom.xml similarity index 97% rename from src/it/projects/sources/pom.xml rename to src/it/projects/resolve-sources/pom.xml index f04fc4d88..1f3f64828 100644 --- a/src/it/projects/sources/pom.xml +++ b/src/it/projects/resolve-sources/pom.xml @@ -29,7 +29,7 @@ Test - Test dependency:sources + Test dependency:resolve-sources diff --git a/src/it/projects/sources/test.properties b/src/it/projects/resolve-sources/test.properties similarity index 100% rename from src/it/projects/sources/test.properties rename to src/it/projects/resolve-sources/test.properties diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java new file mode 100644 index 000000000..88f9ccfa8 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java @@ -0,0 +1,38 @@ +/* + * 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.dependency.resolvers; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Goal that resolves the project source dependencies from the repository. + * + * @author Brian Fox + * @since 2.0-alpha2 + * @deprecated in favor of {@code resolve-sources} goal and will be removed in a future version + */ +@Mojo( + name = "sources", + defaultPhase = LifecyclePhase.GENERATE_SOURCES, + requiresDependencyResolution = ResolutionScope.TEST, + threadSafe = true) +@Deprecated +public class OldResolveDependencySourcesMojo extends ResolveDependencySourcesMojo {} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index cc1300e77..adb87951e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -27,10 +27,10 @@ * Goal that resolves the project source dependencies from the repository. * * @author Brian Fox - * @since 2.0-alpha2 + * @since 2.0-alpha2/3.7.0 */ @Mojo( - name = "sources", + name = "resolve-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index c223708ba..68633b69b 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -61,7 +61,7 @@ ${project.name} optionally transitive dependencies and copies them to a specified location, stripping the version if desired. This goal can also be run from the command line. - *{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays all ancestor POMs of the project. + *{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays all ancestor POMs of the project. This may be useful in a continuous integration system where you want to know all parent poms of the project. This goal can also be run from the command line. @@ -88,9 +88,11 @@ ${project.name} *{{{./resolve-plugins-mojo.html}dependency:resolve-plugins}} tells Maven to resolve plugins and their dependencies. - *{{{./sources-mojo.html}dependency:sources}} tells Maven to resolve all dependencies and their source attachments, + *{{{./resolve-sources-mojo.html}dependency:resolve-sources}} tells Maven to resolve all dependencies and their source attachments, and displays the version. + *{{{./sources-mojo.html}dependency:sources}} has been deprecated for removal in favor of {{{./resolve-sources-mojo.html}dependency:resolve-sources}}. + *{{{./tree-mojo.html}dependency:tree}} displays the dependency tree for this project. *{{{./unpack-mojo.html}dependency:unpack}} like copy but unpacks. diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 58abc43fd..030fa76e8 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -13,8 +13,8 @@ ~~ "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. - +~~ under the License. + ------ Usage ------ @@ -25,11 +25,11 @@ ------ Usage - + Brief examples on how to use the dependency goals: %{toc|fromDepth=2} - + * <<>> This goal is meant to be bound to a lifecycle phase and configured in your @@ -37,8 +37,8 @@ Usage in the specified location. Multiple artifacts can be defined in a single execution. A default output directory is specified but can be overridden for each ArtifactItem by setting the optional outputDirectory field. An - optional new name can be set to rename or the version stripped while copying. - + optional new name can be set to rename or the version stripped while copying. + The artifact version is optional. If not set, the plugin will attempt to resolve it from the project dependencies and then the dependencyManagement section. @@ -87,7 +87,7 @@ Usage [...] +---+ - + If you intend to configure this goal for execution on the command line using: +---+ @@ -128,28 +128,28 @@ mvn dependency:copy +---+ - - * By default, artifacts are copied into using + + * By default, artifacts are copied into using Maven artifact file name convention ( ie ). Use the following rules to override the default convention: - - * Use to override the default file name. - + + * Use to override the default file name. + * Use to remove from default file name. This field is ignored when is set. - - * Use to override the plugin's configuration + + * Use to override the plugin's configuration per . - + [] - + [] * <<>> This goal can be bound to a lifecycle phase and configured in your <<>>. It will resolve the dependencies (including transitive dependencies) from - the repository and place a copy in the specified location. + the repository and place a copy in the specified location. The artifacts can be placed in subfolders based on type. For example: @@ -171,7 +171,7 @@ mvn dependency:copy <<>> will try to find the sources for all dependencies and copy them. - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. @@ -216,8 +216,8 @@ mvn dependency:copy It will resolve the artifact from the repository and place a copy in the specified location. Multiple artifacts can be defined in a single execution. A default outputDirectory is specified but can be overridden for each - ArtifactItem by setting the optional outputDirectory field. - + ArtifactItem by setting the optional outputDirectory field. + A single artifact can be unpacked multiple times if different include/exclude parameters are defined for each artifactItem @@ -225,9 +225,9 @@ mvn dependency:copy The artifact version is optional. If not set, the plugin will attempt to resolve it from the project dependencies and then the dependencyManagement section. - + Configure the plugin something like this if you intend to bind it to execute along with your build: - + +---+ [...] @@ -328,15 +328,15 @@ mvn dependency:unpack resolve artifacts with the classifier and type. For example: <<>> will try to find the sources for all dependencies and unpack them. - + Filters can be applied to include or exclude certain file or filesets as necessary - - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + + Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. <> You can mix includes and excludes of the same category (i.e. scope). Includes are processed before excludes. See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled. - + The goal can also be launched from the command line like: <<>> @@ -373,31 +373,31 @@ mvn dependency:unpack Artifacts are copied or unpacked using the following rules: * If the artifact doesn't exist in the destination, then copy/unpack it. - + Otherwise: - + * For copy/unpack goal only: if <<>> or <<>> is true, then it will force an overwrite. - + * Releases check the <<>> value (default = false). If true, then it will force an overwrite. * Snapshots check the <<>> value (default = false). If true, then it will force an overwrite. - + * If none of the above is set to true, then it defaults to the <<>> value (default = true). This value, if true, causes the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the <<>> path. To avoid unexpected behavior after <<>>, this path should normally be contained within the <<>> hierarchy.) - + Examples: - + * Using the default settings (<<>> = false, <<>> = false, <<>> = true), then a release or snapshot artifact will only over write the destination if the source is newer than the destination (or marker file if unpacking). - + * If <<>> = true, then a release artifact (ie <<>>) will always overwrite. - + * If <<>> = true, then a snapshot artifact (ie <<>>) will always overwrite. - + * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<>> if unpacking). - - + + * <<>> @@ -419,15 +419,15 @@ mvn dependency:unpack <<>> will try to find the test-jar for all dependencies resolve them to the local repository. -* <<>> +* <<>> - Sources is intended to be used from the command line like: - <<>> + Resolve-sources is intended to be used from the command line like: + <<>> This is the same as the resolve goal except it includes the source attachments if they exist. This is useful when you want to download source - attachments to your local repository. - + attachments to your local repository. + You can also define the <<>> either in the pom or settings to be a common location for all projects. This allows the system to resolve sources faster for dependencies that don't have the sources published. The plugin will store a marker file to describe if the sources were resolved or not. By placing @@ -452,7 +452,7 @@ mvn dependency:unpack (or projects, in the case of a multimodule build) from the local repository. Purges can be run with a variety of limiting parameters, including artifact exclusions, limiting to direct dependencies only, and different levels of - depth for deletion. By default, deleted artifacts can be re-resolved + depth for deletion. By default, deleted artifacts can be re-resolved afterwards; you can disable this by specifying <<<-DreResolve=false>>>. In its simplest form, the goal can be called like this: @@ -468,7 +468,7 @@ mvn dependency:purge-local-repository mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-api +---+ - <> The <<>> parameter is a comma-delimited list of + <> The <<>> parameter is a comma-delimited list of groupId:artifactId pairs. It has a corresponding List-based parameter - <<>> - for convenient use inside the POM. @@ -529,7 +529,7 @@ mvn dependency:analyze * <<>> - This goal looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. + This goal looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See {{{https://issues.apache.org/jira/browse/MNG-1577}MNG-1577}} for more info. If this goal detects issues, you should attempt to resolve the discrepancies before upgrading to 2.0.6 to avoid any surprises. This can be done by upgrading or downgrading the version in dependencyManagement to match what is actually @@ -559,7 +559,7 @@ mvn dependency:analyze-dep-mgt [INFO] Resolved: 2.4 [WARNING] Potential problems found in Dependency Management +---+ - + * <<>> @@ -624,15 +624,15 @@ mvn dependency:tree -DoutputFile=/path/to/file.graphml -DoutputType=graphml * <<>> Since: 2.0-alpha-2 - + This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this: +---+ /home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ .... -+---+ ++---+ The resulting file could then be used like this: - + +---+ java -cp `cat resultFile` MyClass +---+ @@ -650,8 +650,8 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt +---+ The goal can also be bound to a lifecycle phase with the following configuration: - -+---+ + ++---+ [...] @@ -682,7 +682,7 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt * <<>> - This goal lists all the repositories that this build depends upon. It shows repositories defined in your settings, + This goal lists all the repositories that this build depends upon. It shows repositories defined in your settings, poms, and declared in transitive dependency poms. @@ -692,7 +692,7 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt +-----+ mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=central::default::https://repo.maven.apache.org/maven2,myrepo::::http://myrepo.com/maven2 -mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2 +mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2 mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar +-----+ @@ -715,4 +715,4 @@ mvn dependency:analyze-exclusions [WARNING] org.apache.maven:maven-artifact: [WARNING] - javax.annotation:javax.annotation-api [WARNING] - javax.activation:javax.activation-api -+---+ \ No newline at end of file ++---+ From f975bcb68bbd200d9890c44abe219c3712462f17 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 9 Jun 2024 13:01:17 +0200 Subject: [PATCH 128/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.7.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6208fa001..092067e29 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.7.0-SNAPSHOT + 3.7.0 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + maven-dependency-plugin-3.7.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -97,7 +97,7 @@ under the License. 1.4.1 1.7.36 - 2023-10-20T21:21:50Z + 2024-06-09T10:59:58Z From a11d253c0ea441ea64824262a2a4b9967aae642c Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 9 Jun 2024 13:01:27 +0200 Subject: [PATCH 129/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 092067e29..1cfa34681 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.7.0 + 3.7.1-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.7.0 + maven-dependency-plugin-3.5.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -97,7 +97,7 @@ under the License. 1.4.1 1.7.36 - 2024-06-09T10:59:58Z + 2024-06-09T11:01:26Z From e06630c4db3b7d45c150075e1dbc12405062fff9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:54:24 +0000 Subject: [PATCH 130/283] Bump org.apache.maven.shared:maven-common-artifact-filters Bumps [org.apache.maven.shared:maven-common-artifact-filters](https://github.com/apache/maven-common-artifact-filters) from 3.3.2 to 3.4.0. - [Release notes](https://github.com/apache/maven-common-artifact-filters/releases) - [Commits](https://github.com/apache/maven-common-artifact-filters/compare/maven-common-artifact-filters-3.3.2...maven-common-artifact-filters-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-common-artifact-filters dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1cfa34681..daabc85f6 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,7 @@ under the License. org.apache.maven.shared maven-common-artifact-filters - 3.3.2 + 3.4.0 org.apache.maven.shared From 8e1f1b5dce1e6d059c87b2941ed2efcea9a5aa4d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 15 Jun 2024 12:06:20 +0200 Subject: [PATCH 131/283] [MDEP-943] Fix appendOutput option --- .../dependency/utils/DependencyUtil.java | 16 +++- .../dependency/utils/TestDependencyUtil.java | 94 ++++++++++++------- 2 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index eaff55ca0..2de653dc4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -25,6 +25,8 @@ import java.io.Writer; import java.nio.charset.Charset; import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.StandardOpenOption; import java.util.Objects; import org.apache.maven.artifact.Artifact; @@ -132,8 +134,9 @@ public static String getFormattedFileName( * @param useSubdirsPerScope if a new sub directory should be used for each scope. * @param useSubdirsPerType if a new sub directory should be used for each type. * @param useSubdirPerArtifact if a new sub directory should be used for each artifact. - * @param useRepositoryLayout if dependencies must be moved into a Maven repository layout, if set, other settings - * will be ignored. + * @param useRepositoryLayout if dependencies must be moved into a Maven repository layout, if set, other + * settings + * will be ignored. * @param removeVersion if the version must not be mentioned in the filename * @param removeType if the type must not be mentioned in the filename * @param outputDirectory base outputDirectory. @@ -226,7 +229,14 @@ public static synchronized void write(String string, File file, boolean append, throws IOException { Files.createDirectories(file.getParentFile().toPath()); - try (Writer writer = Files.newBufferedWriter(file.toPath(), Charset.forName(encoding))) { + OpenOption appendOption = append ? StandardOpenOption.APPEND : StandardOpenOption.TRUNCATE_EXISTING; + + try (Writer writer = Files.newBufferedWriter( + file.toPath(), + Charset.forName(encoding), + appendOption, + StandardOpenOption.CREATE, + StandardOpenOption.WRITE)) { writer.write(string); } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java index b22ee84ed..ceaa05a76 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java @@ -19,28 +19,31 @@ package org.apache.maven.plugins.dependency.utils; import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import java.io.IOException; -import junit.framework.TestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author brianf */ -public class TestDependencyUtil extends TestCase { - List artifacts = new ArrayList<>(); +class TestDependencyUtil { - Log log = new SilentLog(); + private static final String TEST_CONTENT = + "Test line 1" + System.lineSeparator() + "Test line 2" + System.lineSeparator(); - File outputFolder; + @TempDir + File temDir; Artifact snap; @@ -50,40 +53,31 @@ public class TestDependencyUtil extends TestCase { Artifact sources; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void setUp() { ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", null); VersionRange vr = VersionRange.createFromVersion("1.1"); release = new DefaultArtifact("test", "one", vr, Artifact.SCOPE_COMPILE, "jar", "sources", ah, false); - artifacts.add(release); ah = new DefaultArtifactHandlerStub("war", null); vr = VersionRange.createFromVersion("1.1-SNAPSHOT"); snap = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "war", null, ah, false); - artifacts.add(snap); ah = new DefaultArtifactHandlerStub("war", null); vr = VersionRange.createFromVersion("1.1-SNAPSHOT"); snapResolvedVersion = new DefaultArtifact("test", "three", vr, Artifact.SCOPE_PROVIDED, "war", null, ah, false); snapResolvedVersion.setResolvedVersion("1.1-20121003.035531-117"); - artifacts.add(snapResolvedVersion); ah = new DefaultArtifactHandlerStub("war", null); vr = VersionRange.createFromVersion("1.1-SNAPSHOT"); sources = new DefaultArtifact("test", "two", vr, Artifact.SCOPE_PROVIDED, "sources", "sources", ah, false); - - // pick random output location - Random a = new Random(); - outputFolder = new File("target/copy" + a.nextLong() + "/"); - outputFolder.delete(); - assertFalse(outputFolder.exists()); } - public void testDirectoryName() { + @Test + void testDirectoryName() { File folder = new File("target/a"); - final Artifact artifact = artifacts.get(0); + final Artifact artifact = release; File name = DependencyUtil.getFormattedOutputDirectory(false, false, false, false, false, false, folder, artifact); // object is the same. @@ -153,9 +147,10 @@ public void testDirectoryName() { assertEquals(expectedResult, name.getAbsolutePath()); } - public void testDirectoryName2() { + @Test + void testDirectoryName2() { File folder = new File("target/a"); - final Artifact artifact = artifacts.get(1); + final Artifact artifact = snap; File name = DependencyUtil.getFormattedOutputDirectory(false, false, false, false, false, false, folder, artifact); // object is the same. @@ -205,7 +200,8 @@ public void testDirectoryName2() { assertEquals(expectedResult, name.getAbsolutePath()); } - public void testDirectoryNameSources() { + @Test + void testDirectoryNameSources() { File folder = new File("target/a"); File name = DependencyUtil.getFormattedOutputDirectory(false, false, true, false, true, false, folder, sources); String expectedResult = folder.getAbsolutePath() + File.separatorChar + "two-sources"; @@ -224,8 +220,9 @@ public void testDirectoryNameSources() { assertEquals(expectedResult, name.getAbsolutePath()); } - public void testFileName() { - Artifact artifact = artifacts.get(0); + @Test + void testFileName() { + Artifact artifact = release; String name = DependencyUtil.getFormattedFileName(artifact, false); String expectedResult = "one-1.1-sources.jar"; @@ -235,7 +232,8 @@ public void testFileName() { assertEquals(expectedResult, name); } - public void testFileNameUseBaseVersion() { + @Test + void testFileNameUseBaseVersion() { Artifact artifact = snapResolvedVersion; String name = DependencyUtil.getFormattedFileName(artifact, false, false, true); @@ -246,7 +244,8 @@ public void testFileNameUseBaseVersion() { assertEquals(expectedResult, name); } - public void testTestJar() { + @Test + void testTestJar() { ArtifactHandler ah = new DefaultArtifactHandlerStub("test-jar", null); VersionRange vr = VersionRange.createFromVersion("1.1-SNAPSHOT"); Artifact artifact = @@ -257,7 +256,8 @@ public void testTestJar() { assertEquals(expectedResult, name); } - public void testFileNameClassifier() { + @Test + void testFileNameClassifier() { ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", "sources"); VersionRange vr = VersionRange.createFromVersion("1.1-SNAPSHOT"); Artifact artifact = @@ -282,7 +282,8 @@ public void testFileNameClassifier() { assertEquals(expectedResult, name); } - public void testFileNameClassifierWithFile() { + @Test + void testFileNameClassifierWithFile() { // specifically testing the default operation that getFormattedFileName // returns // the actual name of the file if available unless remove version is @@ -319,7 +320,8 @@ public void testFileNameClassifierWithFile() { assertEquals(expectedResult, name); } - public void testTokenizer() { + @Test + void testTokenizer() { String[] tokens = DependencyUtil.tokenizer(" alpha,bravo, charlie , delta kappa, theta"); String[] expected = new String[] {"alpha", "bravo", "charlie", "delta kappa", "theta"}; // easier to see in the JUnit reports @@ -337,4 +339,28 @@ public void testTokenizer() { tokens = DependencyUtil.tokenizer(" "); assertEquals(0, tokens.length); } + + @Test + void outputFileShouldBeOverridden() throws IOException { + File file = new File(temDir, "file1.out"); + assertThat(file).doesNotExist(); + + DependencyUtil.write(TEST_CONTENT, file, false, "UTF-8"); + assertThat(file).hasContent(TEST_CONTENT); + + DependencyUtil.write(TEST_CONTENT, file, false, "UTF-8"); + assertThat(file).hasContent(TEST_CONTENT); + } + + @Test + void outputFileShouldBeAppended() throws IOException { + File file = new File(temDir, "file2.out"); + assertThat(file).doesNotExist(); + + DependencyUtil.write(TEST_CONTENT, file, true, "UTF-8"); + assertThat(file).hasContent(TEST_CONTENT); + + DependencyUtil.write(TEST_CONTENT, file, true, "UTF-8"); + assertThat(file).hasContent(TEST_CONTENT + TEST_CONTENT); + } } From 82a9d60a4c0eaadbab7b575a033727d88d5f4313 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 7 Jun 2024 20:55:14 +0200 Subject: [PATCH 132/283] [MDEP-940] Use Resolver API instead of m-a-t for resolving artifacts --- .../AbstractDependencyFilterMojo.java | 52 ++++++++----------- .../CopyDependenciesMojo.java | 22 ++++---- .../resolvers/ResolvePluginsMojo.java | 41 +++++++-------- .../utils/translators/ArtifactTranslator.java | 5 +- .../translators/ClassifierTypeTranslator.java | 39 +++----------- .../TestCopyDependenciesMojo.java | 6 +++ .../TestCopyDependenciesMojo2.java | 6 +++ .../TestUnpackDependenciesMojo.java | 6 +++ .../TestClassifierTypeTranslator.java | 23 ++++---- 9 files changed, 89 insertions(+), 111 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 85e395768..655458b5d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -24,6 +24,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; @@ -32,12 +33,12 @@ import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.translators.ArtifactTranslator; import org.apache.maven.plugins.dependency.utils.translators.ClassifierTypeTranslator; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -47,11 +48,9 @@ import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.eclipse.aether.resolution.ArtifactResolutionException; /** * Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering @@ -60,8 +59,9 @@ * @see org.apache.maven.plugins.dependency.AbstractDependencyMojo */ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMojo { + @Component - private ArtifactResolver artifactResolver; + private ResolverUtil resolverUtil; @Component private DependencyResolver dependencyResolver; @@ -364,14 +364,11 @@ private void addParentArtifacts(MavenProject project, Set artifacts) t break; } try { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - Artifact resolvedArtifact = artifactResolver - .resolveArtifact(buildingRequest, project.getArtifact()) - .getArtifact(); + org.eclipse.aether.artifact.Artifact resolvedArtifact = resolverUtil.resolveArtifact( + RepositoryUtils.toArtifact(project.getArtifact()), project.getRemoteProjectRepositories()); - artifacts.add(resolvedArtifact); - } catch (ArtifactResolverException e) { + artifacts.add(RepositoryUtils.toArtifact(resolvedArtifact)); + } catch (ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } @@ -385,7 +382,7 @@ private void addParentArtifacts(MavenProject project, Set artifacts) t * @return DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies * @throws MojoExecutionException in case of an error. */ - protected DependencyStatusSets getClassifierTranslatedDependencies(Set artifacts, boolean stopOnFailure) + private DependencyStatusSets getClassifierTranslatedDependencies(Set artifacts, boolean stopOnFailure) throws MojoExecutionException { Set unResolvedArtifacts = new LinkedHashSet<>(); Set resolvedArtifacts = artifacts; @@ -397,7 +394,7 @@ protected DependencyStatusSets getClassifierTranslatedDependencies(Set if (classifier != null && !classifier.isEmpty()) { ArtifactTranslator translator = new ClassifierTypeTranslator(artifactHandlerManager, this.classifier, this.type); - Collection coordinates = translator.translate(artifacts, getLog()); + Collection coordinates = translator.translate(artifacts, getLog()); status = filterMarkedDependencies(artifacts); @@ -447,29 +444,26 @@ protected DependencyStatusSets filterMarkedDependencies(Set artifacts) } /** - * @param coordinates The set of artifact coordinates{@link ArtifactCoordinate}. + * @param artifacts The set of artifacts * @param stopOnFailure true if we should fail with exception if an artifact couldn't be resolved * false otherwise. * @return the resolved artifacts. {@link Artifact}. * @throws MojoExecutionException in case of error. */ - protected Set resolve(Set coordinates, boolean stopOnFailure) + private Set resolve(Set artifacts, boolean stopOnFailure) throws MojoExecutionException { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); Set resolvedArtifacts = new LinkedHashSet<>(); - for (ArtifactCoordinate coordinate : coordinates) { + for (org.eclipse.aether.artifact.Artifact artifact : artifacts) { try { - Artifact artifact = artifactResolver - .resolveArtifact(buildingRequest, coordinate) - .getArtifact(); - resolvedArtifacts.add(artifact); - } catch (ArtifactResolverException ex) { + org.eclipse.aether.artifact.Artifact resolveArtifact = + resolverUtil.resolveArtifact(artifact, getProject().getRemoteProjectRepositories()); + resolvedArtifacts.add(RepositoryUtils.toArtifact(resolveArtifact)); + } catch (ArtifactResolutionException ex) { // an error occurred during resolution, log it an continue - getLog().debug("error resolving: " + coordinate); - getLog().debug(ex); + getLog().debug("error resolving: " + artifact, ex); if (stopOnFailure) { - throw new MojoExecutionException("error resolving: " + coordinate, ex); + throw new MojoExecutionException("error resolving: " + artifact, ex); } } } @@ -507,10 +501,10 @@ public void setPrependGroupId(boolean prependGroupId) { } /** - * @return {@link #artifactResolver} + * @return {@link #resolverUtil} */ - protected final ArtifactResolver getArtifactResolver() { - return artifactResolver; + protected final ResolverUtil getResolverUtil() { + return resolverUtil; } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 48759af25..8b2d8c07d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Set; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; @@ -38,10 +39,10 @@ import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.util.artifact.SubArtifact; /** * Goal that copies the project dependencies from the repository to a defined location. @@ -289,21 +290,16 @@ public void copyPoms(File destDir, Set artifacts, boolean removeVersio * @return {@link Artifact} */ protected Artifact getResolvedPomArtifact(Artifact artifact) { - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId(artifact.getGroupId()); - coordinate.setArtifactId(artifact.getArtifactId()); - coordinate.setVersion(artifact.getVersion()); - coordinate.setExtension("pom"); Artifact pomArtifact = null; // Resolve the pom artifact using repos try { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - pomArtifact = getArtifactResolver() - .resolveArtifact(buildingRequest, coordinate) - .getArtifact(); - } catch (ArtifactResolverException e) { + org.eclipse.aether.artifact.Artifact aArtifact = RepositoryUtils.toArtifact(artifact); + org.eclipse.aether.artifact.Artifact aPomArtifact = new SubArtifact(aArtifact, null, "pom"); + org.eclipse.aether.artifact.Artifact resolvedPom = + getResolverUtil().resolveArtifact(aPomArtifact, getProject().getRemoteProjectRepositories()); + pomArtifact = RepositoryUtils.toArtifact(resolvedPom); + } catch (ArtifactResolutionException e) { getLog().info(e.getMessage()); } return pomArtifact; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index cae06b224..4c6e91ac3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -19,10 +19,12 @@ package org.apache.maven.plugins.dependency.resolvers; import java.io.IOException; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Objects; import java.util.Set; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -43,6 +45,7 @@ import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.eclipse.aether.resolution.ArtifactResolutionException; /** * Goal that resolves all project plugins and reports and their dependencies. @@ -139,7 +142,11 @@ protected void doExecute() throws MojoExecutionException { DependencyUtil.write(output, outputFile, appendOutput, encoding); } } - } catch (IOException | ArtifactFilterException | ArtifactResolverException | DependencyResolverException e) { + } catch (IOException + | ArtifactFilterException + | ArtifactResolverException + | DependencyResolverException + | ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } @@ -208,39 +215,27 @@ private FilterArtifacts getArtifactsFilter() { * @throws ArtifactFilterException in case of an error * @throws ArtifactResolverException in case of an error */ - private Set resolvePluginArtifacts() throws ArtifactFilterException, ArtifactResolverException { + private Set resolvePluginArtifacts() + throws ArtifactFilterException, ArtifactResolverException, ArtifactResolutionException { final Set plugins = getProject().getPluginArtifacts(); final Set reports = getProject().getReportArtifacts(); - Set artifacts = new LinkedHashSet<>(); + Set artifacts = new HashSet<>(); artifacts.addAll(reports); artifacts.addAll(plugins); final FilterArtifacts filter = getArtifactsFilter(); artifacts = filter.filter(artifacts); - // final ArtifactFilter filter = getPluginFilter(); + Set result = new HashSet<>(); for (final Artifact artifact : new LinkedHashSet<>(artifacts)) { - // if ( !filter.include( artifact ) ) - // { - // final String logStr = - // String.format( " Plugin SKIPPED: %s", DependencyUtil.getFormattedFileName( artifact, false ) ); - // - // if ( !silent ) - // { - // this.getLog().info( logStr ); - // } - // - // artifacts.remove( artifact ); - // continue; - // } - - ProjectBuildingRequest buildingRequest = newResolvePluginProjectBuildingRequest(); - - // resolve the new artifact - getArtifactResolver().resolveArtifact(buildingRequest, artifact).getArtifact(); + + org.eclipse.aether.artifact.Artifact resolveArtifact = getResolverUtil() + .resolveArtifact( + RepositoryUtils.toArtifact(artifact), getProject().getRemotePluginRepositories()); + result.add(RepositoryUtils.toArtifact(resolveArtifact)); } - return artifacts; + return result; } @Override diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java index a1be9dc02..12f4ed4c0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java @@ -22,7 +22,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; /** * @author Brian Fox @@ -31,7 +30,7 @@ public interface ArtifactTranslator { /** * @param artifacts set of {@link Artifact}s. * @param log {@link Log} - * @return {@link ArtifactCoordinate} + * @return set of {@link org.eclipse.aether.artifact.Artifact} */ - Set translate(Set artifacts, Log log); + Set translate(Set artifacts, Log log); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java index c6f858907..3aec5907b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java @@ -21,12 +21,12 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; -import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; +import org.eclipse.aether.util.artifact.SubArtifact; /** * @author Brian Fox @@ -39,13 +39,13 @@ public class ClassifierTypeTranslator implements ArtifactTranslator { private String type; /** - * @param artifactHanderManager {@link ArtifactHandlerManager}. + * @param artifactHandlerManager {@link ArtifactHandlerManager}. * @param theClassifier The classifier to use. * @param theType The type. */ public ClassifierTypeTranslator( - ArtifactHandlerManager artifactHanderManager, String theClassifier, String theType) { - this.artifactHandlerManager = artifactHanderManager; + ArtifactHandlerManager artifactHandlerManager, String theClassifier, String theType) { + this.artifactHandlerManager = artifactHandlerManager; this.classifier = theClassifier; this.type = theType; } @@ -56,8 +56,8 @@ public ClassifierTypeTranslator( * org.apache.maven.plugin.logging.Log) */ @Override - public Set translate(Set artifacts, Log log) { - Set results; + public Set translate(Set artifacts, Log log) { + Set results; log.debug("Translating Artifacts using Classifier: " + this.classifier + " and Type: " + this.type); results = new LinkedHashSet<>(); @@ -88,30 +88,7 @@ public Set translate(Set artifacts, Log log) { useClassifier = artifact.getClassifier(); } - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId(artifact.getGroupId()); - coordinate.setArtifactId(artifact.getArtifactId()); - coordinate.setVersion(artifact.getVersion()); - coordinate.setClassifier(useClassifier); - coordinate.setExtension(extension); - - // // Create a new artifact - // Artifact newArtifact = factory.createArtifactWithClassifier( artifact.getGroupId(), artifact - // .getArtifactId(), artifact.getVersion(), useType, useClassifier ); - // - // // note the new artifacts will always have the scope set to null. We - // // should - // // reset it here so that it will pass other filters if needed - // newArtifact.setScope( artifact.getScope() ); - // - // if ( Artifact.SCOPE_SYSTEM.equals( newArtifact.getScope() ) ) - // { - // File baseDir = repositoryManager.getLocalRepositoryBasedir( buildingRequest ); - // String path = repositoryManager.getPathForLocalArtifact( buildingRequest, newArtifact ); - // newArtifact.setFile( new File( baseDir, path ) ); - // } - - results.add(coordinate); + results.add(new SubArtifact(RepositoryUtils.toArtifact(artifact), useClassifier, extension)); } return results; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index e2a14f168..2a2cdfc3b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -34,8 +34,10 @@ import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; +import org.eclipse.aether.RepositorySystem; public class TestCopyDependenciesMojo extends AbstractDependencyMojoTestCase { @@ -52,6 +54,10 @@ protected void setUp() throws Exception { MavenSession session = newMavenSession(project); getContainer().addComponent(session, MavenSession.class.getName()); + RepositorySystem repositorySystem = lookup(RepositorySystem.class); + ResolverUtil resolverUtil = new ResolverUtil(repositorySystem, () -> session); + getContainer().addComponent(resolverUtil, ResolverUtil.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 231c620a5..5a2998375 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -45,7 +45,9 @@ import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; +import org.eclipse.aether.RepositorySystem; public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { @@ -60,6 +62,10 @@ protected void setUp() throws Exception { MavenSession session = newMavenSession(project); getContainer().addComponent(session, MavenSession.class.getName()); + RepositorySystem repositorySystem = lookup(RepositorySystem.class); + ResolverUtil resolverUtil = new ResolverUtil(repositorySystem, () -> session); + getContainer().addComponent(resolverUtil, ResolverUtil.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index ab17a5030..6ff789178 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -36,9 +36,11 @@ import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; public class TestUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { @@ -58,6 +60,10 @@ protected void setUp() throws Exception { MavenSession session = newMavenSession(project); getContainer().addComponent(session, MavenSession.class.getName()); + RepositorySystem repositorySystem = lookup(RepositorySystem.class); + ResolverUtil resolverUtil = new ResolverUtil(repositorySystem, () -> session); + getContainer().addComponent(resolverUtil, ResolverUtil.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index 422b36d9b..93fd632c9 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -37,7 +37,6 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; -import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate; /** * @author brianf @@ -87,18 +86,18 @@ public void doTestNullEmptyClassifier(String classifier) { String type = "zip"; ArtifactTranslator at = new ClassifierTypeTranslator(artifactHandlerManager, classifier, type); - Set results = at.translate(artifacts, log); + Set results = at.translate(artifacts, log); for (Artifact artifact : artifacts) { - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while (resultIter.hasNext()) { - ArtifactCoordinate translatedArtifact = resultIter.next(); + org.eclipse.aether.artifact.Artifact translatedArtifact = resultIter.next(); if (artifact.getArtifactId().equals(translatedArtifact.getArtifactId()) && artifact.getGroupId().equals(translatedArtifact.getGroupId()) /* && artifact.getScope().equals(translatedArtifact.getScope()) */ ) { - // classifier is null, should be the same as the artifact - assertEquals(artifact.getClassifier(), translatedArtifact.getClassifier()); + // classifier is always empty for Resolver sub artifact + assertEquals("", translatedArtifact.getClassifier()); assertEquals(type, translatedArtifact.getExtension()); found = true; @@ -121,13 +120,13 @@ public void doTestNullEmptyType(String type) { String classifier = "jdk5"; ArtifactTranslator at = new ClassifierTypeTranslator(artifactHandlerManager, classifier, type); - Set results = at.translate(artifacts, log); + Set results = at.translate(artifacts, log); for (Artifact artifact : artifacts) { - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while (!found && resultIter.hasNext()) { - ArtifactCoordinate translatedArtifact = resultIter.next(); + org.eclipse.aether.artifact.Artifact translatedArtifact = resultIter.next(); if (artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId() /* && artifact.getScope() == translatedArtifact.getScope() */ ) { @@ -147,13 +146,13 @@ public void testClassifierAndType() { String classifier = "jdk14"; String type = "sources"; ArtifactTranslator at = new ClassifierTypeTranslator(artifactHandlerManager, classifier, type); - Set results = at.translate(artifacts, log); + Set results = at.translate(artifacts, log); for (Artifact artifact : artifacts) { - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while (!found && resultIter.hasNext()) { - ArtifactCoordinate translatedArtifact = resultIter.next(); + org.eclipse.aether.artifact.Artifact translatedArtifact = resultIter.next(); if (artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId()) { assertEquals(translatedArtifact.getClassifier(), classifier); From d656b0347519a8a3df64cf197ea62d29cb33915b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 16 Jun 2024 17:10:38 +0200 Subject: [PATCH 133/283] [MDEP-945] Fix documentation about get goal --- .../maven/plugins/dependency/GetMojo.java | 12 ++-- src/site/apt/usage.apt.vm | 72 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index d0b86033c..73b3eb312 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -105,7 +105,7 @@ public class GetMojo extends AbstractMojo { private List pomRemoteRepositories; /** - * Download transitively, retrieving the specified artifact and all of its dependencies. + * Resolve transitively, retrieving the specified artifact and all of its dependencies. */ @Parameter(property = "transitive", defaultValue = "true") private boolean transitive = true; @@ -241,7 +241,7 @@ protected boolean isSkip() { } /** - * The groupId of the artifact to download. Ignored if {@link #artifact} is used. + * The groupId of the artifact to resolve. Ignored if {@link #artifact} is used. * * @param groupId The groupId. */ @@ -251,7 +251,7 @@ public void setGroupId(String groupId) { } /** - * The artifactId of the artifact to download. Ignored if {@link #artifact} is used. + * The artifactId of the artifact to resolve. Ignored if {@link #artifact} is used. * * @param artifactId The artifactId. */ @@ -261,7 +261,7 @@ public void setArtifactId(String artifactId) { } /** - * The version of the artifact to download. Ignored if {@link #artifact} is used. + * The version of the artifact to resolve. Ignored if {@link #artifact} is used. * * @param version The version. */ @@ -271,7 +271,7 @@ public void setVersion(String version) { } /** - * The classifier of the artifact to download. Ignored if {@link #artifact} is used. + * The classifier of the artifact to resolve. Ignored if {@link #artifact} is used. * * @param classifier The classifier to be used. * @@ -283,7 +283,7 @@ public void setClassifier(String classifier) { } /** - * The packaging of the artifact to download. Ignored if {@link #artifact} is used. + * The packaging of the artifact to resolve. Ignored if {@link #artifact} is used. * * @param type packaging. */ diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 030fa76e8..1132cd5a0 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -90,9 +90,9 @@ Usage If you intend to configure this goal for execution on the command line using: -+---+ +--- mvn dependency:copy -+---+ +--- you must not put the configuration inside the tag. Your configuration should look like this: @@ -258,9 +258,9 @@ mvn dependency:copy If you intend to configure this goal for execution on the command line using: -+---+ +--- mvn dependency:unpack -+---+ +--- you must not put the configuration inside the tag. Your configuration should look like this: @@ -457,16 +457,16 @@ mvn dependency:unpack In its simplest form, the goal can be called like this: -+---+ +--- mvn dependency:purge-local-repository -+---+ +--- To add the restriction that the <<>> artifact not be deleted, we can modify the command to this: -+---+ +--- mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-api -+---+ +--- <> The <<>> parameter is a comma-delimited list of groupId:artifactId pairs. It has a corresponding List-based parameter - @@ -497,9 +497,9 @@ mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-ap (in order to verify proper artifact resolution, for example), simply use this command: -+---+ +--- mvn dependency:purge-local-repository -DresolutionFuzziness=artifactId -+---+ +--- Finally, it's possible to bind this goal to the build lifecycle. One reason for this might be to clean out all dependencies when the build is initialized, to verify @@ -513,9 +513,9 @@ mvn dependency:purge-local-repository -DresolutionFuzziness=artifactId This goal can be executed from the command line: -+---+ +--- mvn dependency:analyze -+---+ +--- Sample output: @@ -540,9 +540,9 @@ mvn dependency:analyze This goal can be executed from the command line: -+---+ +--- mvn dependency:analyze-dep-mgt -+---+ +--- Sample output: @@ -593,15 +593,15 @@ mvn dependency:analyze-dep-mgt This goal can be executed from the command line: -+-----+ +--- mvn dependency:tree -+-----+ +--- Optionally, the <<>> parameter can be specified to divert the output to a file: -+-----+ +--- mvn dependency:tree -DoutputFile=/path/to/file -+-----+ +--- Also, the <<>> parameter can be used to generate different formats of output. The following formats are currently supported: @@ -616,9 +616,9 @@ mvn dependency:tree -DoutputFile=/path/to/file [] -+-----+ +--- mvn dependency:tree -DoutputFile=/path/to/file.graphml -DoutputType=graphml -+-----+ +--- * <<>> @@ -627,27 +627,27 @@ mvn dependency:tree -DoutputFile=/path/to/file.graphml -DoutputType=graphml This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this: -+---+ +--- /home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ .... -+---+ +--- The resulting file could then be used like this: -+---+ +--- java -cp `cat resultFile` MyClass -+---+ +--- In its simplest form, to output the classpath to the log, the goal can be called like this: -+---+ +--- mvn dependency:build-classpath -+---+ +--- or to write the classpath to cp.txt: -+---+ +--- mvn dependency:build-classpath -Dmdep.outputFile=cp.txt -+---+ +--- The goal can also be bound to a lifecycle phase with the following configuration: @@ -688,13 +688,13 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt * <<>> - This goal fetches an artifact and (optionally) its dependencies from remote repositories using its Maven coordinates. + This goal resolves an artifact and (optionally) its dependencies from remote repositories using its Maven coordinates. + The Maven Central repository are always consider during resolving. -+-----+ -mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=central::default::https://repo.maven.apache.org/maven2,myrepo::::http://myrepo.com/maven2 -mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar -+-----+ +--- +mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources +mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://myrepo.com/maven2 +--- * <<>> @@ -704,9 +704,9 @@ mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -Dre Later a:b:2.0 has removed the unwanted dependency and you upgrade. This goal will inform you that the exclusion is no longer required. -+---+ +--- mvn dependency:analyze-exclusions -+---+ +--- Sample output: From e8c1a621f22f9d3b379217f7dec9596867b0a76f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 18 Jun 2024 09:04:10 +0200 Subject: [PATCH 134/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.7.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index daabc85f6..2331fa7af 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.7.1-SNAPSHOT + 3.7.1 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + maven-dependency-plugin-3.7.1 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -97,7 +97,7 @@ under the License. 1.4.1 1.7.36 - 2024-06-09T11:01:26Z + 2024-06-18T07:03:42Z From f71bd65c4cb71316c79785b27cf2ea0b44621273 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 18 Jun 2024 09:04:19 +0200 Subject: [PATCH 135/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2331fa7af..7abf64b97 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.7.1 + 3.7.2-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.7.1 + maven-dependency-plugin-3.5.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -97,7 +97,7 @@ under the License. 1.4.1 1.7.36 - 2024-06-18T07:03:42Z + 2024-06-18T07:04:19Z From 620f8fb1aed260390a8b84ebd1ea1cc25f676ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCnger?= Date: Sun, 23 Jun 2024 19:01:51 +0200 Subject: [PATCH 136/283] MDEP-913 Add dependency:collect on index-page --- src/site/apt/index.apt.vm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 68633b69b..c2479cd52 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -53,6 +53,10 @@ ${project.name} Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. The classpath file may also be attached and installed/deployed along with the main artifact. + *{{{./collect-dependencies-mojo.html}dependency:collect}} collects the project dependencies from the repository. + It lists the groupId:artifactId:version information by downloading the pom files without downloading the actual + artifacts such as jar files. + *{{{./copy-mojo.html}dependency:copy}} takes a list of artifacts defined in the plugin configuration section and copies them to a specified location, renaming them or stripping the version if desired. This goal can resolve the artifacts from remote repositories if they don't exist in either the local repository or the reactor. From c729702b18a9b496049b0994db7426c72339be75 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 1 Jul 2024 00:09:04 +0200 Subject: [PATCH 137/283] Fix mismatching Parameter initial field values Field values should match `defaultValue` of `Parameter` annotation. Had to adjust the unit tests because they were apparently manually constructing the Mojos and therefore not using the `Parameter#defaultValue`. Also removes the parameters from `TestUnpackDependenciesMojo#dotestArtifactExceptions` because they were apparently unused since commit 809bfe1c4b175e1d684de2da39003d3ecefa1c54. --- .../AbstractFromDependenciesMojo.java | 2 +- .../fromDependencies/CopyDependenciesMojo.java | 2 +- .../fromDependencies/TestCopyDependenciesMojo.java | 1 + .../fromDependencies/TestUnpackDependenciesMojo.java | 11 ++++------- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index a92e8298d..1d03fde69 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -104,7 +104,7 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil * @since 2.0-alpha-2 */ @Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false") - protected boolean failOnMissingClassifierArtifact = true; + protected boolean failOnMissingClassifierArtifact; /** * @return Returns the outputDirectory. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 8b2d8c07d..dcf2e9141 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -64,7 +64,7 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { * @since 2.0 */ @Parameter(property = "mdep.copyPom", defaultValue = "false") - protected boolean copyPom = true; + protected boolean copyPom; @Component private CopyUtil copyUtil; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index 2a2cdfc3b..e1ec92823 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -429,6 +429,7 @@ public void testArtifactResolutionException() throws MojoFailureException { public void dotestArtifactExceptions() throws MojoFailureException { mojo.classifier = "jdk"; + mojo.failOnMissingClassifierArtifact = true; mojo.type = "java-sources"; try { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 6ff789178..463f8f9b6 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -491,16 +491,13 @@ public void dotestClassifierType(String testClassifier, String testType) throws } } - public void testArtifactNotFound() throws Exception { - dotestArtifactExceptions(false, true); + public void testArtifactResolutionException() throws MojoFailureException { + dotestArtifactExceptions(); } - public void testArtifactResolutionException() throws Exception { - dotestArtifactExceptions(true, false); - } - - public void dotestArtifactExceptions(boolean are, boolean anfe) throws Exception { + public void dotestArtifactExceptions() throws MojoFailureException { mojo.classifier = "jdk"; + mojo.failOnMissingClassifierArtifact = true; mojo.type = "java-sources"; try { From 71cee33151c85d11b4d4ca2f63b5be72f1c482f3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Tue, 9 Jul 2024 22:27:23 +0200 Subject: [PATCH 138/283] Remove outdated invoker conditions --- .../mdep-439-analyze-java8/invoker.properties | 5 +-- .../mdep-571-resolve-java9/invoker.properties | 38 +++++++++---------- .../invoker.properties | 6 +-- .../invoker.properties | 6 +-- .../invoker.properties | 5 +-- .../invoker.properties | 6 +-- .../invoker.properties | 6 +-- 7 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/it/projects/mdep-439-analyze-java8/invoker.properties b/src/it/projects/mdep-439-analyze-java8/invoker.properties index b81576bc0..35372acc1 100644 --- a/src/it/projects/mdep-439-analyze-java8/invoker.properties +++ b/src/it/projects/mdep-439-analyze-java8/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,5 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.java.version = 1.8+ invoker.goals=clean verify diff --git a/src/it/projects/mdep-571-resolve-java9/invoker.properties b/src/it/projects/mdep-571-resolve-java9/invoker.properties index f4bce4e4c..e6c16a727 100644 --- a/src/it/projects/mdep-571-resolve-java9/invoker.properties +++ b/src/it/projects/mdep-571-resolve-java9/invoker.properties @@ -1,19 +1,19 @@ -# 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. - -invoker.java.version = 1.9+ -invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve +# 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. + +invoker.java.version = 9+ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve diff --git a/src/it/projects/purge-local-repository-bad-dep/invoker.properties b/src/it/projects/purge-local-repository-bad-dep/invoker.properties index 098745b51..6a64fc6e9 100644 --- a/src/it/projects/purge-local-repository-bad-dep/invoker.properties +++ b/src/it/projects/purge-local-repository-bad-dep/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,5 +16,3 @@ # under the License. invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository -# [MNG-5366] Does not work in Maven >= 3.0.4 due to the resolveAlways operation not correctly forcing a new download -invoker.maven.version = !3.0.4,!3.0.5,!3.1.0,!3.1.1,!3.2.1,!3.2.2,!3.2.3 diff --git a/src/it/projects/purge-local-repository-bad-pom/invoker.properties b/src/it/projects/purge-local-repository-bad-pom/invoker.properties index 9ea542aa9..6a64fc6e9 100644 --- a/src/it/projects/purge-local-repository-bad-pom/invoker.properties +++ b/src/it/projects/purge-local-repository-bad-pom/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,5 +16,3 @@ # under the License. invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository -# [MNG-5366] Only works works with Maven 3.0.x except for 3.0.4 -invoker.maven.version = 3.0.0+, !3.0.4 diff --git a/src/it/projects/purge-local-repository-include/invoker.properties b/src/it/projects/purge-local-repository-include/invoker.properties index 5feb77ebd..8f449f312 100644 --- a/src/it/projects/purge-local-repository-include/invoker.properties +++ b/src/it/projects/purge-local-repository-include/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,4 +16,3 @@ # under the License. invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository -invoker.maven.version = 3.1.0+ \ No newline at end of file diff --git a/src/it/projects/purge-local-repository-reresolve/invoker.properties b/src/it/projects/purge-local-repository-reresolve/invoker.properties index 69ba6bff1..8f449f312 100644 --- a/src/it/projects/purge-local-repository-reresolve/invoker.properties +++ b/src/it/projects/purge-local-repository-reresolve/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,5 +16,3 @@ # under the License. invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository -# [MNG-5366] Does not work in Maven >= 3.0.4 due to the resolveAlways operation not correctly forcing a new download -invoker.maven.version = !3.0.4,!3.0.5,!3.1.0,!3.1.1,!3.2.1,!3.2.2,!3.2.3 diff --git a/src/it/projects/purge-local-repository-version-range/invoker.properties b/src/it/projects/purge-local-repository-version-range/invoker.properties index 098745b51..6a64fc6e9 100644 --- a/src/it/projects/purge-local-repository-version-range/invoker.properties +++ b/src/it/projects/purge-local-repository-version-range/invoker.properties @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,5 +16,3 @@ # under the License. invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository -# [MNG-5366] Does not work in Maven >= 3.0.4 due to the resolveAlways operation not correctly forcing a new download -invoker.maven.version = !3.0.4,!3.0.5,!3.1.0,!3.1.1,!3.2.1,!3.2.2,!3.2.3 From 06b427327bfb28a26c9be78ff840948d26eba197 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 22:13:38 +0000 Subject: [PATCH 139/283] Bump org.assertj:assertj-core from 3.26.0 to 3.26.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.26.0 to 3.26.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.26.0...assertj-build-3.26.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7abf64b97..6989c8597 100644 --- a/pom.xml +++ b/pom.xml @@ -394,7 +394,7 @@ under the License. org.assertj assertj-core - 3.26.0 + 3.26.3 test From 94e1caf57c84a9da81317b19b3611299d6db700d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:47:55 +0000 Subject: [PATCH 140/283] Bump org.jsoup:jsoup from 1.17.2 to 1.18.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.17.2 to 1.18.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.17.2...jsoup-1.18.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6989c8597..d99a8cab3 100644 --- a/pom.xml +++ b/pom.xml @@ -510,7 +510,7 @@ under the License. org.jsoup jsoup - 1.17.2 + 1.18.1
From 86b7772498216280c948f8887f20ce2d03269e8a Mon Sep 17 00:00:00 2001 From: maffe Date: Mon, 12 Aug 2024 22:14:32 +0200 Subject: [PATCH 141/283] (doc) Remove repeated word --- src/site/apt/index.apt.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index c2479cd52..96fe64895 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -82,7 +82,7 @@ ${project.name} used by the build and by the transitive dependencies. *{{{./properties-mojo.html}dependency:properties}} sets a property for each project dependency containing the - the artifact on the file system. + artifact on the file system. *{{{./purge-local-repository-mojo.html}dependency:purge-local-repository}} tells Maven to clear dependency artifact files out of the local repository, and optionally re-resolve them. From 2d0b82a865441a683897f5429b9986ed8c75a835 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 16:57:41 +0000 Subject: [PATCH 142/283] Bump org.codehaus.plexus:plexus-io from 3.4.2 to 3.5.0 Bumps [org.codehaus.plexus:plexus-io](https://github.com/codehaus-plexus/plexus-io) from 3.4.2 to 3.5.0. - [Release notes](https://github.com/codehaus-plexus/plexus-io/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-io/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-io/compare/plexus-io-3.4.2...plexus-io-3.5.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d99a8cab3..e13b75301 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ under the License. org.codehaus.plexus plexus-io - 3.4.2 + 3.5.0 org.codehaus.plexus From ea4d8e249dc7d7c134c128f25e2a62c6772be1fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 16:59:14 +0000 Subject: [PATCH 143/283] Bump jettyVersion from 9.4.54.v20240208 to 9.4.55.v20240627 Bumps `jettyVersion` from 9.4.54.v20240208 to 9.4.55.v20240627. Updates `org.eclipse.jetty:jetty-server` from 9.4.54.v20240208 to 9.4.55.v20240627 Updates `org.eclipse.jetty:jetty-util` from 9.4.54.v20240208 to 9.4.55.v20240627 Updates `org.eclipse.jetty:jetty-security` from 9.4.54.v20240208 to 9.4.55.v20240627 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e13b75301..a295cfc16 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ under the License. 3.6.3 8 - 9.4.54.v20240208 + 9.4.55.v20240627 4.11.0 4.9.2 3.3.0 From 5288cece722923651fbcf5e13741d3f94e910dbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:02:25 +0000 Subject: [PATCH 144/283] Bump org.apache.maven.plugins:maven-plugins from 42 to 43 Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 42 to 43. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 9 ++++++++- src/config/checkstyle-suppressions.xml | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/config/checkstyle-suppressions.xml diff --git a/pom.xml b/pom.xml index a295cfc16..3e0e99ebf 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 42 + 43 @@ -459,6 +459,13 @@ under the License.
+ + org.apache.maven.plugins + maven-checkstyle-plugin + + src/config/checkstyle-suppressions.xml + +
diff --git a/src/config/checkstyle-suppressions.xml b/src/config/checkstyle-suppressions.xml new file mode 100644 index 000000000..3fea1ee7c --- /dev/null +++ b/src/config/checkstyle-suppressions.xml @@ -0,0 +1,25 @@ + + + + + + From 1115ecb4fa11d08f15435b9d094708667e123d18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:01:01 +0000 Subject: [PATCH 145/283] Bump org.codehaus.plexus:plexus-archiver from 4.9.2 to 4.10.0 Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.9.2 to 4.10.0. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.9.2...plexus-archiver-4.10.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e0e99ebf..427e1b565 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ under the License. 9.4.55.v20240627 4.11.0 - 4.9.2 + 4.10.0 3.3.0 1.4.1 1.7.36 @@ -213,6 +213,13 @@ under the License. plexus-archiver ${plexus-archiver.version} + + + org.apache.commons + commons-lang3 + 3.14.0 + runtime + org.codehaus.plexus plexus-utils From 50397c42b9f4ede4ed82c055caaf3ef0733f3aba Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 3 Dec 2022 02:13:19 +0100 Subject: [PATCH 146/283] [MDEP-903] Upgrade to Doxia 2.0.0 Milestone Stack This closes #314 --- pom.xml | 57 +++---------------- src/it/projects/analyze-report/verify.bsh | 6 +- .../verify.bsh | 10 ++-- ...lyzeReportMojo.java => AnalyzeReport.java} | 4 +- .../maven/plugins/dependency/TestSkip.java | 48 ++++++++++++++-- 5 files changed, 62 insertions(+), 63 deletions(-) rename src/main/java/org/apache/maven/plugins/dependency/analyze/{AnalyzeReportMojo.java => AnalyzeReport.java} (96%) diff --git a/pom.xml b/pom.xml index 427e1b565..1d08ac898 100644 --- a/pom.xml +++ b/pom.xml @@ -87,30 +87,17 @@ under the License. - 3.6.3 8 - + 3.6.3 + 1.4.1 + 1.7.36 9.4.55.v20240627 4.11.0 4.10.0 3.3.0 - 1.4.1 - 1.7.36 - 2024-06-18T07:04:19Z - - - - - org.apache.commons - commons-text - 1.12.0 - - - - @@ -156,49 +143,23 @@ under the License. provided - + org.apache.maven.doxia doxia-sink-api - 1.12.0 - - - org.codehaus.plexus - plexus-container-default - - + 2.0.0-M12 + + org.apache.maven.reporting maven-reporting-api - 3.1.1 + 4.0.0-M12 org.apache.maven.reporting maven-reporting-impl - 3.2.0 - - - org.codehaus.plexus - plexus-container-default - - - org.apache.maven - maven-artifact - - - org.apache.maven - maven-core - - - org.apache.maven - maven-model - - - org.apache.maven - maven-plugin-api - - + 4.0.0-M15 commons-io diff --git a/src/it/projects/analyze-report/verify.bsh b/src/it/projects/analyze-report/verify.bsh index d32f9f902..55b19f0b5 100644 --- a/src/it/projects/analyze-report/verify.bsh +++ b/src/it/projects/analyze-report/verify.bsh @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -19,7 +19,7 @@ import java.io.*; -File htmlFile = new File( basedir, "target/site/dependency-analysis.html" ); +File htmlFile = new File( basedir, "target/reports/dependency-analysis.html" ); if ( !htmlFile.isFile() ) { diff --git a/src/it/projects/analyze-testDependencyWithNonTestScope/verify.bsh b/src/it/projects/analyze-testDependencyWithNonTestScope/verify.bsh index ba623ba7a..46c27ff4b 100644 --- a/src/it/projects/analyze-testDependencyWithNonTestScope/verify.bsh +++ b/src/it/projects/analyze-testDependencyWithNonTestScope/verify.bsh @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,7 +24,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -File htmlFile = new File( basedir, "target/site/dependency-analysis.html" ); +File htmlFile = new File( basedir, "target/reports/dependency-analysis.html" ); if ( !htmlFile.isFile() ) { @@ -37,7 +37,7 @@ if ( htmlFile.length() == 0 ) Document doc = Jsoup.parse( htmlFile, "UTF-8"); -Elements entry = doc.select( "#contentBox > section > section:nth-child(5) > table > tbody > tr.b" ); +Elements entry = doc.select( "#bodyColumn > section > section:nth-child(5) > table > tbody > tr.b" ); if( entry.isEmpty() ) { @@ -50,7 +50,7 @@ else if ( entry.size() != 1 ) } Element groupIdElement = doc.select( -"#contentBox > section > section:nth-child(5) > table > tbody > tr.b > td:nth-child(1)" ).first(); +"#bodyColumn > section > section:nth-child(5) > table > tbody > tr.b > td:nth-child(1)" ).first(); String groupId = groupIdElement.text(); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java similarity index 96% rename from src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java rename to src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java index 0c8d4ce60..239bc825c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java @@ -42,7 +42,7 @@ */ @Mojo(name = "analyze-report", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) @Execute(phase = LifecyclePhase.TEST_COMPILE) -public class AnalyzeReportMojo extends AbstractMavenReport { +public class AnalyzeReport extends AbstractMavenReport { // fields ----------------------------------------------------------------- /** @@ -124,13 +124,11 @@ public void executeReport(Locale locale) throws MavenReportException { @Override public boolean canGenerateReport() { if (skip) { - getLog().info("Skipping plugin execution"); return false; } // Step 0: Checking pom availability if ("pom".equals(project.getPackaging())) { - getLog().info("Skipping pom project"); return false; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java index b52a9e812..1fbcacb08 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java @@ -21,7 +21,11 @@ import java.io.File; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.Mojo; +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.logging.Log; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; @@ -56,7 +60,7 @@ public void testSkipAnalyzeOnly() throws Exception { } public void testSkipAnalyzeReport() throws Exception { - doSpecialTest("analyze-report"); + doSpecialTest("analyze-report", true); } public void testSkipAnalyzeDuplicate() throws Exception { @@ -124,19 +128,55 @@ protected void doTest(String mojoName) throws Exception { } protected void doSpecialTest(String mojoName) throws Exception { - doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml"); + doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", false); + } + + protected void doSpecialTest(String mojoName, boolean addMojoExecution) throws Exception { + doConfigTest(mojoName, "plugin-" + mojoName + "-config.xml", addMojoExecution); } private void doConfigTest(String mojoName, String configFile) throws Exception { + doConfigTest(mojoName, configFile, false); + } + + private void doConfigTest(String mojoName, String configFile, boolean addMojoExecution) throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/skip-test/" + configFile); Mojo mojo = lookupMojo(mojoName, testPom); - assertNotNull(mojo); + assertNotNull("Mojo not found.", mojo); + + if (addMojoExecution) { + setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution(mojoName)); + } Log log = mock(Log.class); mojo.setLog(log); mojo.execute(); ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); verify(log, atLeastOnce()).info(captor.capture()); - assertTrue(captor.getValue().contains("Skipping plugin execution")); + String skipMessage; + if (addMojoExecution) { + MojoExecution me = getMockMojoExecution(mojoName); + String reportMojoInfo = me.getPlugin().getId() + ":" + me.getGoal(); + skipMessage = "Skipping " + reportMojoInfo + " report goal"; + } else { + skipMessage = "Skipping plugin execution"; + } + assertTrue(captor.getValue().contains(skipMessage)); + } + + private MojoExecution getMockMojoExecution(String goal) { + MojoDescriptor md = new MojoDescriptor(); + md.setGoal(goal); + + MojoExecution me = new MojoExecution(md); + + PluginDescriptor pd = new PluginDescriptor(); + Plugin p = new Plugin(); + p.setGroupId("org.apache.maven.plugins"); + p.setArtifactId("maven-dependency-plugin"); + pd.setPlugin(p); + md.setPluginDescriptor(pd); + + return me; } } From 75814c79197672264078eb6e181aa2b343150dea Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 18 Aug 2024 21:02:13 +0200 Subject: [PATCH 147/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.8.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1d08ac898..3c4168593 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.7.2-SNAPSHOT + 3.8.0 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + maven-dependency-plugin-3.8.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -95,7 +95,7 @@ under the License. 4.11.0 4.10.0 3.3.0 - 2024-06-18T07:04:19Z + 2024-08-18T19:00:48Z From eca2252b5f39eece5aadb7bac08eeb30507606e7 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 18 Aug 2024 21:02:24 +0200 Subject: [PATCH 148/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3c4168593..367657881 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.8.0 + 3.8.1-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.8.0 + maven-dependency-plugin-3.5.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -95,7 +95,7 @@ under the License. 4.11.0 4.10.0 3.3.0 - 2024-08-18T19:00:48Z + 2024-08-18T19:02:23Z From cb0f302260f9c4d43c2c96a75305dbda57b8b45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 19 Aug 2024 01:20:55 +0200 Subject: [PATCH 149/283] use new Reproducible Central badge endpoint --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f143c0fc..5ff4b4a9f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Contributing to [Apache Maven Dependency Plugin](https://maven.apache.org/plugin [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEP.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-dependency-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-dependency-plugin) -[![Reproducible Builds](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-dependency-plugin/README.md) +[![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/apache/maven/plugins/maven-dependency-plugin//badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-dependency-plugin/README.md) [![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-dependency-plugin/job/master.svg?)][build] [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-dependency-plugin/job/master.svg?)][test-results] From 706f2001e45047ff54af8fbfc8b0051a0d76add5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:10:46 +0000 Subject: [PATCH 150/283] Bump org.apache.maven.doxia:doxia-sink-api from 2.0.0-M12 to 2.0.0 (#432) Bumps [org.apache.maven.doxia:doxia-sink-api](https://github.com/apache/maven-doxia) from 2.0.0-M12 to 2.0.0. - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-2.0.0-M12...doxia-2.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-sink-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 367657881..9adc9a9af 100644 --- a/pom.xml +++ b/pom.xml @@ -147,7 +147,7 @@ under the License. org.apache.maven.doxia doxia-sink-api - 2.0.0-M12 + 2.0.0 From b15f69e285145b8e25ec5643409be67a142070d3 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 12 Oct 2024 21:32:25 +0000 Subject: [PATCH 151/283] [MDEP-956][MDEP-932] Silence artifact copying (#436) * [MDEP-956] Silence artifact copying * move logging to debug level --- .../maven/plugins/dependency/utils/CopyUtil.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java index 21d067ae7..b175fb705 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -41,28 +41,26 @@ @Singleton public class CopyUtil { - private final Logger logger = LoggerFactory.getLogger(CopyUtil.class); - private final BuildContext buildContext; + private final Logger logger = LoggerFactory.getLogger(CopyUtil.class); + @Inject public CopyUtil(BuildContext buildContext) { this.buildContext = buildContext; } /** - * Does the actual copy of the artifact (file) and logging. + * Copies the artifact (file). * - * @param sourceArtifact represents the artifact (file) to copy. - * @param destination file name of destination file. + * @param sourceArtifact represents the artifact (file) to copy + * @param destination file name of destination file * @throws IOException if copy has failed * @throws MojoExecutionException if artifact file is a directory (which has not been packaged yet) * * @since 3.7.0 */ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws IOException, MojoExecutionException { - logger.info("Copying artifact '{}' ({}) to {}", sourceArtifact, sourceArtifact.getFile(), destination); - File source = sourceArtifact.getFile(); if (source.isDirectory()) { // usual case is a future jar packaging, but there are special cases: classifier and other packaging @@ -70,7 +68,7 @@ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws I + "' has not been packaged yet (is a directory). When used on reactor artifact, " + "copy should be executed after packaging: see MDEP-187."); } - + logger.debug("Copying artifact '{}' ({}) to {}", sourceArtifact, sourceArtifact.getFile(), destination); FileUtils.copyFile(source, destination); buildContext.refresh(destination); } From bedf2f9e06014b44b3c618a62beea2da8ed5f81a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 12 Oct 2024 21:34:46 +0000 Subject: [PATCH 152/283] Minor copy editing (#437) --- src/site/apt/usage.apt.vm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 1132cd5a0..6ec2d4fcc 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -171,9 +171,9 @@ mvn dependency:copy <<>> will try to find the sources for all dependencies and copy them. - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + Also included is the ability to include or exclude by type (war, jar, etc.), scope (runtime, test, etc.), classifier (jdk14, sources, etc.), groupId, artifactId, or a combination of them. - <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. + <> You may mix includes and excludes of the same category (e.g. scope). Includes are processed before excludes. See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled. From ffa1009b05d899b10aa339a688a72292ae85e299 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:53:59 +0000 Subject: [PATCH 153/283] Bump org.apache.maven.shared:maven-dependency-analyzer (#434) Bumps [org.apache.maven.shared:maven-dependency-analyzer](https://github.com/apache/maven-dependency-analyzer) from 1.14.1 to 1.15.0. - [Release notes](https://github.com/apache/maven-dependency-analyzer/releases) - [Commits](https://github.com/apache/maven-dependency-analyzer/compare/maven-dependency-analyzer-1.14.1...maven-dependency-analyzer-1.15.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-dependency-analyzer dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9adc9a9af..0e2c27056 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.14.1 + 1.15.0 org.apache.maven.shared From 1b02c5df0d4e2a4d040d9edbaa7e327bc4c75bed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:54:40 +0000 Subject: [PATCH 154/283] Bump org.apache.maven.reporting:maven-reporting-api (#435) Bumps [org.apache.maven.reporting:maven-reporting-api](https://github.com/apache/maven-reporting-api) from 4.0.0-M12 to 4.0.0. - [Commits](https://github.com/apache/maven-reporting-api/compare/maven-reporting-api-4.0.0-M12...maven-reporting-api-4.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e2c27056..9b3e4ef6c 100644 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ under the License. org.apache.maven.reporting maven-reporting-api - 4.0.0-M12 + 4.0.0 org.apache.maven.reporting From 54663fcb9b8c4cc5175289b9c71768f149a789f9 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 14 Oct 2024 13:17:36 +0000 Subject: [PATCH 155/283] Cleanup and correct usage docs (#440) --- src/site/apt/usage.apt.vm | 41 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 6ec2d4fcc..056418335 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -26,7 +26,7 @@ Usage - Brief examples on how to use the dependency goals: + Brief examples of how to use the dependency goals: %{toc|fromDepth=2} @@ -129,8 +129,8 @@ mvn dependency:copy - * By default, artifacts are copied into using - Maven artifact file name convention ( ie ). + * By default, artifacts are copied into using the + Maven artifact file name convention (that is, ). Use the following rules to override the default convention: * Use to override the default file name. @@ -329,11 +329,11 @@ mvn dependency:unpack <<>> will try to find the sources for all dependencies and unpack them. - Filters can be applied to include or exclude certain file or filesets as necessary + Filters can be applied to include or exclude files or filesets as necessary - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + Also included is the ability to include or exclude by type (war, jar, etc.), scope (runtime, test, etc.), classifier (jdk14, sources, etc.), groupId, artifactId, or a combination of them. - <> You can mix includes and excludes of the same category (i.e. scope). Includes are processed before excludes. + <> You can mix includes and excludes of the same category (e.g. scope). Includes are processed before excludes. See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled. @@ -391,9 +391,9 @@ mvn dependency:unpack * Using the default settings (<<>> = false, <<>> = false, <<>> = true), then a release or snapshot artifact will only over write the destination if the source is newer than the destination (or marker file if unpacking). - * If <<>> = true, then a release artifact (ie <<>>) will always overwrite. + * If <<>> = true, then a release artifact (e.g. <<>>) will always overwrite. - * If <<>> = true, then a snapshot artifact (ie <<>>) will always overwrite. + * If <<>> = true, then a snapshot artifact (e.g. <<>>) will always overwrite. * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<>> if unpacking). @@ -404,19 +404,19 @@ mvn dependency:unpack Resolve is intended to be used from the command line like: <<>> - This goal simply tells maven to resolve all test scope (includes compile) - dependencies and then displays the resolved versions. This is intended to - help ensure all dependencies are downloaded to the local repository. This is + This goal resolves all test and compile scoped + dependencies and then displays the resolved versions. This + ensures all dependencies are downloaded to the local repository. This is useful when troubleshooting or during intermittent remote repository - failures when repeatedly building multiproject modules is undersirable and + failures when repeatedly building multiproject modules is undesirable and the build is failing on dependency resolution. It can also be used to quickly determine how versions are being resolved. - Artifacts can also be resolved by specifying the classifer and optionally + Artifacts can also be resolved by specifying the classifier and optionally type. Type is only used with the classifier and defaults to java-sources. When the classifier is set, the list of dependencies is used as the base to - resolve artifacts with the classifer and type. For example: - <<>> will try to find the + resolve artifacts with the classifier and type. For example: + <<>> will try to find the test-jar for all dependencies resolve them to the local repository. * <<>> @@ -530,13 +530,8 @@ mvn dependency:analyze * <<>> This goal looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. - In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See {{{https://issues.apache.org/jira/browse/MNG-1577}MNG-1577}} for more info. - If this goal detects issues, you should attempt to resolve the discrepancies before upgrading to 2.0.6 to avoid any surprises. This can be done by upgrading or downgrading the version in dependencyManagement to match what is actually - being included at runtime, or you can specify a dependency in your project to override what is being included. You can check the results by rerunning this goal. - If you decide to override by using a dependency, be sure to note it so you can remove it later after upgrading to 2.0.6. You could also use the dependency:analyze goal to uncover this unused direct dependency. - - This goal is also useful for just detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions. + This goal is useful for detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions. This goal can be executed from the command line: @@ -623,8 +618,6 @@ mvn dependency:tree -DoutputFile=/path/to/file.graphml -DoutputType=graphml * <<>> - Since: 2.0-alpha-2 - This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this: --- @@ -700,7 +693,7 @@ mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion= * <<>> This goal checks exclusions on dependencies and checks if the artifact actually brings in the given dependency. - For instance given dependency a:b:1.0 transitively includes x:y:1.0 which you do not want for some reason and exclude it. + For instance, given dependency a:b:1.0 transitively includes x:y:1.0 which you do not want for some reason and exclude it. Later a:b:2.0 has removed the unwanted dependency and you upgrade. This goal will inform you that the exclusion is no longer required. From 24d2a76a5c7ec94ede702e2e6c74ded1275d14b0 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 14 Oct 2024 15:06:13 +0000 Subject: [PATCH 156/283] Replace old workaround for Maven 3.2.5 bug (#438) --- .../plugins/dependency/analyze/AbstractAnalyzeMojo.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 35b287ec1..b6eed99ce 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -261,13 +261,11 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * * @since 3.2.1 */ - // defaultValue value on @Parameter - not work with Maven 3.2.5 - // When is set defaultValue always win, and there is no possibility to override by plugin configuration. - @Parameter - private List ignoredPackagings = Arrays.asList("pom", "ear"); + @Parameter(defaultValue = "pom,ear") + private List ignoredPackagings; /** - * List Excluded classes patterns from analyze. Java regular expression pattern is applied to full class name. + * List of class patterns excluded from analyze. Java regular expression pattern is applied to full class name. * * @since 3.7.0 */ From 7b137a17cc71b001e79992b755471a3fbb9702c8 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 16 Oct 2024 07:34:50 -0400 Subject: [PATCH 157/283] [MDEP-946] Add analyze exclusions to list of goals --- .../plugins/dependency/exclusion/AnalyzeExclusionsMojo.java | 4 ++-- src/site/apt/index.apt.vm | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java index 7c6515674..e16410979 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -46,10 +46,10 @@ import static org.apache.maven.plugins.dependency.exclusion.Coordinates.coordinates; /** - * Analyzes the exclusions defined on dependencies in this project and reports if any of them are invalid. + * Analyzes the exclusions defined on dependencies in this project and reports if any of them are unneeded. *

* Relevant use case is when an artifact in a later version has removed usage of a dependency, making the exclusion no - * longer valid. + * longer necessary. *

* * @since 3.7.0 diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 96fe64895..d987dff36 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -40,6 +40,8 @@ ${project.name} *{{{./analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes the project's dependencies and lists mismatches between resolved dependencies and those listed in your dependencyManagement section. + *{{{./analyze-exclusions.html}dependency:analyze-exclusions}} analyzes the exclusions on dependencies and checks if the artifact actually brings in the given dependency. + *{{{./analyze-only-mojo.html}dependency:analyze-only}} is the same as analyze, but is meant to be bound in a pom. It does not fork the build and execute test-compile. From e347ef7298c9064be7f0774a4e00f94d7d407fcc Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 17 Oct 2024 20:06:35 +0000 Subject: [PATCH 158/283] Delete obsolete commented code for issue that was won't fixed 10 years ago (#446) --- .../AbstractFromConfigurationMojo.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index debac7748..7fbedc4ad 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -192,24 +192,14 @@ private boolean checkIfProcessingNeeded(ArtifactItem item) throws ArtifactFilter * Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved * from the dependency list or from the DependencyManagement section of the pom. * - * @param artifactItem containing information about artifact from plugin configuration. - * @return Artifact object representing the specified file. - * @throws MojoExecutionException with a message if the version can't be found in DependencyManagement. + * @param artifactItem containing information about artifact from plugin configuration + * @return Artifact object representing the specified file + * @throws MojoExecutionException if the version can't be found in DependencyManagement */ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException { Artifact artifact; try { - // mdep-50 - rolledback for now because it's breaking some functionality. - /* - * List listeners = new ArrayList(); Set theSet = new HashSet(); theSet.add( artifact ); - * ArtifactResolutionResult artifactResolutionResult = artifactCollector.collect( theSet, project - * .getArtifact(), managedVersions, this.local, project.getRemoteArtifactRepositories(), - * artifactMetadataSource, null, listeners ); Iterator iter = - * artifactResolutionResult.getArtifactResolutionNodes().iterator(); while ( iter.hasNext() ) { - * ResolutionNode node = (ResolutionNode) iter.next(); artifact = node.getArtifact(); } - */ - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); if (localRepositoryDirectory != null) { From b19b7e027085fb215f8f510d7bef8033ecbd4d48 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 18 Oct 2024 12:49:22 +0000 Subject: [PATCH 159/283] [MDEP-930] Make test robust against platform default character sets (#448) --- .../plugins/dependency/tree/TestTreeMojo.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index 003f57c66..b1c756786 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -23,14 +23,14 @@ import javax.json.JsonObject; import javax.json.JsonReader; -import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringReader; import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -57,6 +57,7 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { /* * @see org.apache.maven.plugin.testing.AbstractMojoTestCase#setUp() */ + @Override protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("tree", false); @@ -225,10 +226,11 @@ public void testTreeJsonParsing() throws Exception { */ private List runTreeMojo(String outputFile, String format) throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml"); - String outputFileName = testDir.getAbsolutePath() + outputFile; + Path outputFilePath = Paths.get(testDir.getAbsolutePath() + outputFile); TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom); + setVariableValueToObject(mojo, "outputEncoding", "UTF-8"); setVariableValueToObject(mojo, "outputType", format); - setVariableValueToObject(mojo, "outputFile", new File(outputFileName)); + setVariableValueToObject(mojo, "outputFile", outputFilePath.toFile()); assertNotNull(mojo); assertNotNull(mojo.getProject()); @@ -244,14 +246,7 @@ private List runTreeMojo(String outputFile, String format) throws Except mojo.execute(); - BufferedReader fp1 = new BufferedReader(new FileReader(outputFileName)); - List contents = new ArrayList<>(); - - String line; - while ((line = fp1.readLine()) != null) { - contents.add(line); - } - fp1.close(); + List contents = Files.readAllLines(outputFilePath); return contents; } From cbac4a785843953cb8408b0eb75b16ad38d5574d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:02:09 +0000 Subject: [PATCH 160/283] Bump commons-io:commons-io from 2.16.1 to 2.17.0 Bumps commons-io:commons-io from 2.16.1 to 2.17.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b3e4ef6c..3e7de22d8 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,7 @@ under the License. commons-io commons-io - 2.16.1 + 2.17.0 test From 38ab10076724a01ed7e51d1a665019b1e0b67fff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:04:35 +0000 Subject: [PATCH 161/283] Bump org.codehaus.plexus:plexus-io from 3.5.0 to 3.5.1 Bumps [org.codehaus.plexus:plexus-io](https://github.com/codehaus-plexus/plexus-io) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/codehaus-plexus/plexus-io/releases) - [Commits](https://github.com/codehaus-plexus/plexus-io/compare/plexus-io-3.5.0...plexus-io-3.5.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e7de22d8..beb72c5a8 100644 --- a/pom.xml +++ b/pom.xml @@ -192,7 +192,7 @@ under the License. org.codehaus.plexus plexus-io - 3.5.0 + 3.5.1 org.codehaus.plexus From 361058e3c235f0524d91efa006b1b2f2d59efbe8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:09:29 +0000 Subject: [PATCH 162/283] Bump jettyVersion from 9.4.55.v20240627 to 9.4.56.v20240826 Bumps `jettyVersion` from 9.4.55.v20240627 to 9.4.56.v20240826. Updates `org.eclipse.jetty:jetty-server` from 9.4.55.v20240627 to 9.4.56.v20240826 Updates `org.eclipse.jetty:jetty-util` from 9.4.55.v20240627 to 9.4.56.v20240826 Updates `org.eclipse.jetty:jetty-security` from 9.4.55.v20240627 to 9.4.56.v20240826 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index beb72c5a8..da7c9d420 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ under the License. 3.6.3 1.4.1 1.7.36 - 9.4.55.v20240627 + 9.4.56.v20240826 4.11.0 4.10.0 3.3.0 From 188531ca74cbb80225d4d470c99039ee2dbc8911 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 19:57:02 +0200 Subject: [PATCH 163/283] Fix SCM tag --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index da7c9d420..bc9ad9a5b 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.5.0 + HEAD https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} From 7e1aadcd74bc9b48b96d3c3f9e450d69f7552894 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:07:39 +0000 Subject: [PATCH 164/283] Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0 Bumps org.apache.commons:commons-lang3 from 3.14.0 to 3.17.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc9ad9a5b..3a904b483 100644 --- a/pom.xml +++ b/pom.xml @@ -178,7 +178,7 @@ under the License. org.apache.commons commons-lang3 - 3.14.0 + 3.17.0 runtime From 842075d72d371459450db3a854b013a0a946c23d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:09:02 +0000 Subject: [PATCH 165/283] Bump org.apache.maven.reporting:maven-reporting-impl Bumps [org.apache.maven.reporting:maven-reporting-impl](https://github.com/apache/maven-reporting-impl) from 4.0.0-M15 to 4.0.0. - [Commits](https://github.com/apache/maven-reporting-impl/compare/maven-reporting-impl-4.0.0-M15...maven-reporting-impl-4.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-impl dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a904b483..d265b12b0 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ under the License. org.apache.maven.reporting maven-reporting-impl - 4.0.0-M15 + 4.0.0 commons-io From 954e44a6f6bdb9f827cef95cff8a9509f86a7ed2 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 20:16:04 +0200 Subject: [PATCH 166/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.8.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d265b12b0..39e579814 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.8.1-SNAPSHOT + 3.8.1 maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - HEAD + maven-dependency-plugin-3.8.1 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -95,7 +95,7 @@ under the License. 4.11.0 4.10.0 3.3.0 - 2024-08-18T19:02:23Z + 2024-10-18T18:14:36Z From cc3ed0fd316b526b0d00ef64e944c3e6614b861d Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 20:16:14 +0200 Subject: [PATCH 167/283] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 39e579814..48ef57070 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.8.1 + 3.8.2-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -68,7 +68,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - maven-dependency-plugin-3.8.1 + HEAD https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -95,7 +95,7 @@ under the License. 4.11.0 4.10.0 3.3.0 - 2024-10-18T18:14:36Z + 2024-10-18T18:16:14Z From 6da7a1d3540a4785f8d7268763da3445830bc63b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 18 Oct 2024 21:42:34 +0000 Subject: [PATCH 168/283] [MDEP-957] By default, don't report slf4j-simple as unused (#433) * [MDEP-957] By default, don't report slf4j-simple as unused --- src/it/projects/analyze/pom.xml | 6 ++++++ .../dependency/analyze/AbstractAnalyzeMojo.java | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/it/projects/analyze/pom.xml b/src/it/projects/analyze/pom.xml index 013a97988..e3072ae88 100644 --- a/src/it/projects/analyze/pom.xml +++ b/src/it/projects/analyze/pom.xml @@ -52,6 +52,12 @@ maven-model 2.0.6 + + + org.slf4j + slf4j-simple + 2.0.16 +
diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index b6eed99ce..00d3135ea 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -216,7 +216,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { private String[] ignoredUsedUndeclaredDependencies = new String[0]; /** - * List of dependencies that will be ignored if they are declared but unused. The filter syntax is: + * List of dependencies that are ignored if they are declared but unused. The filter syntax is: * *
      * [groupId]:[artifactId]:[type]:[version]
@@ -225,17 +225,17 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo {
      * where each pattern segment is optional and supports full and partial * wildcards. An empty pattern
      * segment is treated as an implicit wildcard. *
      * 

- * For example, org.apache.* will match all artifacts whose group id starts with + * For example, org.apache.* matches all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

* * @since 2.10 */ - @Parameter - private String[] ignoredUnusedDeclaredDependencies = new String[0]; + @Parameter(defaultValue = "org.slf4j:slf4j-simple::") + private String[] ignoredUnusedDeclaredDependencies; /** - * List of dependencies that will be ignored if they are in not test scope but are only used in test classes. + * List of dependencies that are ignored if they are in not test scope but are only used in test classes. * The filter syntax is: * *
@@ -245,14 +245,14 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo {
      * where each pattern segment is optional and supports full and partial * wildcards. An empty pattern
      * segment is treated as an implicit wildcard. *
      * 

- * For example, org.apache.* will match all artifacts whose group id starts with + * For example, org.apache.* matched all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

* * @since 3.3.0 */ - @Parameter - private String[] ignoredNonTestScopedDependencies = new String[0]; + @Parameter(defaultValue = "org.slf4j:slf4j-simple::") + private String[] ignoredNonTestScopedDependencies; /** * List of project packaging that will be ignored. From 15a3f52e010a7dcd7861b1460e58a7c1a49e5523 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 19 Oct 2024 15:53:17 +0000 Subject: [PATCH 169/283] [MNG-2961] Remove workaround for fixed bug (#441) * Remove workaround for fixed bug --- .../plugins/dependency/analyze/AbstractAnalyzeMojo.java | 3 --- .../maven/plugins/dependency/analyze/AnalyzeDepMgt.java | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 00d3135ea..ebff3dcea 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -502,9 +502,6 @@ private void writeDependencyXML(Set artifacts) { PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter(out); for (Artifact artifact : artifacts) { - // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961 - artifact.isSnapshot(); - writer.startElement("dependency"); writer.startElement("groupId"); writer.writeText(artifact.getGroupId()); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index 079c95d9c..b118183e2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -212,9 +212,9 @@ public String getExclusionKey(Exclusion ex) { /** * Calculate the mismatches between the DependencyManagement and resolved artifacts * - * @param depMgtMap contains the Dependency.GetManagementKey as the keyset for quick lookup. - * @param allDependencyArtifacts contains the set of all artifacts to compare. - * @return a map containing the resolved artifact as the key and the listed dependency as the value. + * @param depMgtMap a keyset of the Dependency.GetManagementKey for quick lookup + * @param allDependencyArtifacts the set of all artifacts to compare + * @return a map containing the resolved artifact as the key and the listed dependency as the value */ public Map getMismatch( Map depMgtMap, Set allDependencyArtifacts) { @@ -223,9 +223,6 @@ public Map getMismatch( for (Artifact dependencyArtifact : allDependencyArtifacts) { Dependency depFromDepMgt = depMgtMap.get(getArtifactManagementKey(dependencyArtifact)); if (depFromDepMgt != null) { - // workaround for MNG-2961 - dependencyArtifact.isSnapshot(); - if (depFromDepMgt.getVersion() != null && !depFromDepMgt.getVersion().equals(dependencyArtifact.getBaseVersion())) { mismatchMap.put(dependencyArtifact, depFromDepMgt); From 5e4927707de3499d97d48272e0c60bcfc8fcf0ff Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 19 Oct 2024 15:56:23 +0000 Subject: [PATCH 170/283] Clean up parameters docs (#439) * Clean up parameters docs --- .../analyze/AbstractAnalyzeMojo.java | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index ebff3dcea..ba3fb677c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -74,8 +74,6 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * maven-dependency-analyzer is used. To use this, you must declare * a dependency for this plugin that contains the code for the analyzer. The analyzer must have a declared Plexus * role name, and you specify the role name here. - * - * @since 2.2 */ @Parameter(property = "analyzer", defaultValue = "default") private String analyzer; @@ -114,47 +112,37 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * the Non-test scoped test only dependencies found warning to the * <ignoredNonTestScopedDependencies> configuration. * - * @since 3.3.1-SNAPSHOT + * @since 3.3.1 */ @Parameter(property = "ignoreAllNonTestScoped", defaultValue = "false") private boolean ignoreAllNonTestScoped; /** - * Output the xml for the missing dependencies (used but not declared). - * - * @since 2.0-alpha-5 + * Output XML for the missing dependencies (used but not declared). */ @Parameter(property = "outputXML", defaultValue = "false") private boolean outputXML; /** * Output scriptable values for the missing dependencies (used but not declared). - * - * @since 2.0-alpha-5 */ @Parameter(property = "scriptableOutput", defaultValue = "false") private boolean scriptableOutput; /** * Flag to use for scriptable output. - * - * @since 2.0-alpha-5 */ @Parameter(property = "scriptableFlag", defaultValue = "$$$%%%") private String scriptableFlag; /** - * Flag to use for scriptable output - * - * @since 2.0-alpha-5 + * Base directory for output. */ @Parameter(defaultValue = "${basedir}", readonly = true) private File baseDir; /** - * Target folder - * - * @since 2.0-alpha-5 + * Target directory. */ @Parameter(defaultValue = "${project.build.directory}", readonly = true) private File outputDirectory; @@ -162,16 +150,12 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { /** * Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format is * groupId:artifactId. - * - * @since 2.6 */ @Parameter private String[] usedDependencies; /** * Skip plugin execution completely. - * - * @since 2.7 */ @Parameter(property = "mdep.analyze.skip", defaultValue = "false") private boolean skip; @@ -190,8 +174,6 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* will match all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

- * - * @since 2.10 */ @Parameter private String[] ignoredDependencies = new String[0]; @@ -209,8 +191,6 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* will match all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

- * - * @since 2.10 */ @Parameter private String[] ignoredUsedUndeclaredDependencies = new String[0]; @@ -228,8 +208,6 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* matches all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

- * - * @since 2.10 */ @Parameter(defaultValue = "org.slf4j:slf4j-simple::") private String[] ignoredUnusedDeclaredDependencies; From 1e20326392569ef587844b2fd8434ae7d255d639 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 22 Oct 2024 15:40:35 -0400 Subject: [PATCH 171/283] Deprecate slient parameter --- .../maven/plugins/dependency/AbstractDependencyMojo.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 114824996..bbf981af9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -86,8 +86,10 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * If the plugin should be silent. * + * @deprecated to be removed in 4.0; use -Q command line option instead * @since 2.0 */ + @Deprecated @Parameter(property = "silent", defaultValue = "false") private boolean silent; @@ -170,14 +172,18 @@ public void setSkip(boolean skip) { /** * @return {@link #silent} + * @deprecated to be removed in 4.0 */ + @Deprecated protected final boolean isSilent() { return silent; } /** * @param silent {@link #silent} + * @deprecated to be removed in 4.0; no API replacement, use -Q command line option instead */ + @Deprecated public void setSilent(boolean silent) { this.silent = silent; if (silent) { From e2d23838c31e7f404227fd1f24b30efc285baf2b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 22 Oct 2024 15:43:22 -0400 Subject: [PATCH 172/283] Revert "Clean up parameters docs (#439)" This reverts commit 5e4927707de3499d97d48272e0c60bcfc8fcf0ff. --- .../analyze/AbstractAnalyzeMojo.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index ba3fb677c..ebff3dcea 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -74,6 +74,8 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * maven-dependency-analyzer is used. To use this, you must declare * a dependency for this plugin that contains the code for the analyzer. The analyzer must have a declared Plexus * role name, and you specify the role name here. + * + * @since 2.2 */ @Parameter(property = "analyzer", defaultValue = "default") private String analyzer; @@ -112,37 +114,47 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * the Non-test scoped test only dependencies found warning to the * <ignoredNonTestScopedDependencies> configuration. * - * @since 3.3.1 + * @since 3.3.1-SNAPSHOT */ @Parameter(property = "ignoreAllNonTestScoped", defaultValue = "false") private boolean ignoreAllNonTestScoped; /** - * Output XML for the missing dependencies (used but not declared). + * Output the xml for the missing dependencies (used but not declared). + * + * @since 2.0-alpha-5 */ @Parameter(property = "outputXML", defaultValue = "false") private boolean outputXML; /** * Output scriptable values for the missing dependencies (used but not declared). + * + * @since 2.0-alpha-5 */ @Parameter(property = "scriptableOutput", defaultValue = "false") private boolean scriptableOutput; /** * Flag to use for scriptable output. + * + * @since 2.0-alpha-5 */ @Parameter(property = "scriptableFlag", defaultValue = "$$$%%%") private String scriptableFlag; /** - * Base directory for output. + * Flag to use for scriptable output + * + * @since 2.0-alpha-5 */ @Parameter(defaultValue = "${basedir}", readonly = true) private File baseDir; /** - * Target directory. + * Target folder + * + * @since 2.0-alpha-5 */ @Parameter(defaultValue = "${project.build.directory}", readonly = true) private File outputDirectory; @@ -150,12 +162,16 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { /** * Force dependencies as used, to override incomplete result caused by bytecode-level analysis. Dependency format is * groupId:artifactId. + * + * @since 2.6 */ @Parameter private String[] usedDependencies; /** * Skip plugin execution completely. + * + * @since 2.7 */ @Parameter(property = "mdep.analyze.skip", defaultValue = "false") private boolean skip; @@ -174,6 +190,8 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* will match all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

+ * + * @since 2.10 */ @Parameter private String[] ignoredDependencies = new String[0]; @@ -191,6 +209,8 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* will match all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

+ * + * @since 2.10 */ @Parameter private String[] ignoredUsedUndeclaredDependencies = new String[0]; @@ -208,6 +228,8 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * For example, org.apache.* matches all artifacts whose group id starts with * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. *

+ * + * @since 2.10 */ @Parameter(defaultValue = "org.slf4j:slf4j-simple::") private String[] ignoredUnusedDeclaredDependencies; From c98c851aec9a0309756b2de089c8d8fa5876e99c Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 23 Oct 2024 13:10:59 +0000 Subject: [PATCH 173/283] Elaborate on DependencyUtil.log in doc comment (#449) * Elaborate on DependencyUtil.log in doc comment * typo --- .../maven/plugins/dependency/utils/DependencyUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index 2de653dc4..bdccfee92 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -242,7 +242,11 @@ public static synchronized void write(String string, File file, boolean append, } /** - * Writes the specified string to the log at info level. + * Writes each line in the specified string to the log at info level. + * The difference between calling + * {@code DependencyUtil.log(s, log)} and {@code log.info(s)} is that the latter + * will put "[INFO]" in front of each line in the string whereas the former only + * outputs it once at the front of the string. * * @param string the string to write * @param log where to log information From a1bb14fad9c3cda503e436605fc2b3f457a5f847 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 7 Nov 2024 13:45:36 -0500 Subject: [PATCH 174/283] Convert to JUnit 5 (#445) * Convert to JUnit 5 * Convert to JUnit 5 * Convert to JUnit 5 * Convert to JUnit 5 * Convert to JUnit 5 * Convert to JUnit 5 * rebase --- pom.xml | 6 --- .../AbstractDependencyMojoTestCase.java | 7 +++- .../utils/filters/TestDestFileFilter.java | 36 +++++++++--------- .../utils/filters/TestMarkerFileFilter.java | 38 +++++++------------ .../filters/TestResolveMarkerFileFilter.java | 36 +++++++----------- .../markers/TestDefaultMarkerFileHandler.java | 35 ++++++++--------- .../markers/TestUnpackMarkerFileHandler.java | 37 ++++++++---------- 7 files changed, 84 insertions(+), 111 deletions(-) diff --git a/pom.xml b/pom.xml index 48ef57070..b75c3dee6 100644 --- a/pom.xml +++ b/pom.xml @@ -161,12 +161,6 @@ under the License. maven-reporting-impl 4.0.0 - - commons-io - commons-io - 2.17.0 - test - diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index cde5ea883..fc8eacc05 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; @@ -49,15 +50,17 @@ protected void setUp(String testDirStr, boolean createFiles) throws Exception { protected void setUp(String testDirStr, boolean createFiles, boolean flattenedPath) throws Exception { // required for mojo lookups to work super.setUp(); + testDir = new File( getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + testDirStr + File.separatorChar); - FileUtils.deleteDirectory(testDir); - assertFalse(testDir.exists()); + testDir = Files.createTempDirectory("testDirStr").toFile(); + testDir.deleteOnExit(); stubFactory = new DependencyArtifactStubFactory(this.testDir, createFiles, flattenedPath); } + @Override protected void tearDown() { if (testDir != null) { try { diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java index 2c52f5f3e..b97f83fa0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestDestFileFilter.java @@ -23,43 +23,37 @@ import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; -import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author brianf */ -public class TestDestFileFilter extends TestCase { +public class TestDestFileFilter { Set artifacts = new HashSet<>(); - Log log = new SilentLog(); - + @TempDir File outputFolder; DependencyArtifactStubFactory fact; + @BeforeEach protected void setUp() throws Exception { - super.setUp(); - - outputFolder = new File("target/markers/"); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); - this.fact = new DependencyArtifactStubFactory(outputFolder, false); artifacts = fact.getReleaseAndSnapshotArtifacts(); } - protected void tearDown() throws IOException { - FileUtils.deleteDirectory(outputFolder); - } - public void createFile(Artifact artifact) throws IOException { createFile(artifact, false, false, false); } @@ -91,6 +85,7 @@ public File createFile( return destFile; } + @Test public void testDestFileRelease() throws IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getReleaseArtifact(); @@ -103,6 +98,7 @@ public void testDestFileRelease() throws IOException, ArtifactFilterException { assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileSnapshot() throws IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getSnapshotArtifact(); @@ -115,6 +111,7 @@ public void testDestFileSnapshot() throws IOException, ArtifactFilterException { assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileStripVersion() throws IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getSnapshotArtifact(); @@ -128,6 +125,7 @@ public void testDestFileStripVersion() throws IOException, ArtifactFilterExcepti assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileStripClassifier() throws IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getSnapshotArtifact(); @@ -141,6 +139,7 @@ public void testDestFileStripClassifier() throws IOException, ArtifactFilterExce assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileSubPerArtifact() throws IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getSnapshotArtifact(); @@ -154,6 +153,7 @@ public void testDestFileSubPerArtifact() throws IOException, ArtifactFilterExcep assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileSubPerType() throws MojoExecutionException, IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); Artifact artifact = fact.getSnapshotArtifact(); @@ -167,6 +167,7 @@ public void testDestFileSubPerType() throws MojoExecutionException, IOException, assertTrue(filter.isArtifactIncluded(artifact)); } + @Test public void testDestFileOverwriteIfNewer() throws MojoExecutionException, IOException, ArtifactFilterException { DestFileFilter filter = new DestFileFilter(outputFolder); @@ -192,6 +193,7 @@ public void testDestFileOverwriteIfNewer() throws MojoExecutionException, IOExce assertFalse(filter.isArtifactIncluded(artifact)); } + @Test public void testGettersSetters() { DestFileFilter filter = new DestFileFilter(null); assertNull(filter.getOutputFileDirectory()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java index 717b19421..beec00806 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java @@ -23,45 +23,38 @@ import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; -import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author brianf */ -public class TestMarkerFileFilter extends TestCase { +public class TestMarkerFileFilter { Set artifacts = new HashSet<>(); - Log log = new SilentLog(); - + @TempDir File outputFolder; DependencyArtifactStubFactory fact; + @BeforeEach protected void setUp() throws Exception { - super.setUp(); - - outputFolder = new File("target/markers/"); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); - this.fact = new DependencyArtifactStubFactory(outputFolder, false); artifacts = fact.getReleaseAndSnapshotArtifacts(); } - protected void tearDown() throws IOException { - FileUtils.deleteDirectory(outputFolder); - } - + @Test public void testMarkerFile() throws ArtifactFilterException { - MarkerFileFilter filter = new MarkerFileFilter(true, true, false, new DefaultFileMarkerHandler(outputFolder)); Set result = filter.filter(artifacts); assertEquals(2, result.size()); @@ -73,7 +66,6 @@ public void testMarkerFile() throws ArtifactFilterException { } public void testMarkerSnapshots() throws ArtifactFilterException, MojoExecutionException, IOException { - DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(fact.getSnapshotArtifact(), outputFolder); handler.setMarker(); @@ -85,8 +77,6 @@ public void testMarkerSnapshots() throws ArtifactFilterException, MojoExecutionE result = filter.filter(artifacts); assertEquals(2, result.size()); assertTrue(handler.clearMarker()); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); } public void testMarkerRelease() throws IOException, ArtifactFilterException, MojoExecutionException { @@ -102,10 +92,9 @@ public void testMarkerRelease() throws IOException, ArtifactFilterException, Moj assertEquals(2, result.size()); assertTrue(handler.clearMarker()); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); } + @Test public void testMarkerTimestamp() throws IOException, MojoExecutionException, ArtifactFilterException { // filter includes release artifact because no marker present // filter includes snapshot artifact because it is newer than marker @@ -137,10 +126,9 @@ public void testMarkerTimestamp() throws IOException, MojoExecutionException, Ar assertFalse(handler.isMarkerSet()); snap.getFile().delete(); release.getFile().delete(); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); } + @Test public void testGettersSetters() { MarkerFileFilter filter = new MarkerFileFilter(true, false, true, new DefaultFileMarkerHandler(outputFolder)); assertTrue(filter.isOverWriteReleases()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java index 25e629355..10bce1a31 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestResolveMarkerFileFilter.java @@ -20,46 +20,36 @@ import java.io.File; import java.io.IOException; -import java.util.HashSet; -import java.util.Set; -import junit.framework.TestCase; -import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author brianf */ -public class TestResolveMarkerFileFilter extends TestCase { - Set artifacts = new HashSet<>(); - - Log log = new SilentLog(); +public class TestResolveMarkerFileFilter { + @TempDir File outputFolder; DependencyArtifactStubFactory fact; - protected void setUp() throws Exception { - super.setUp(); - - outputFolder = new File("target/markers/"); - FileUtils.deleteDirectory(outputFolder); - assertFalse(outputFolder.exists()); - - this.fact = new DependencyArtifactStubFactory(outputFolder, false); - artifacts = fact.getReleaseAndSnapshotArtifacts(); - } - - protected void tearDown() throws IOException { - FileUtils.deleteDirectory(outputFolder); + @BeforeEach + protected void setUp() throws IOException { + fact = new DependencyArtifactStubFactory(outputFolder, false); + fact.getReleaseAndSnapshotArtifacts(); } + @Test public void testResolveFile() throws IOException, ArtifactFilterException, MojoExecutionException { SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler(outputFolder); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java index c9eb2d4a3..7828759e5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestDefaultMarkerFileHandler.java @@ -23,31 +23,34 @@ import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; -import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.testUtils.stubs.StubDefaultFileMarkerHandler; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author brianf */ -public class TestDefaultMarkerFileHandler extends TestCase { +public class TestDefaultMarkerFileHandler { List artifacts = new ArrayList<>(); - Log log = new SilentLog(); - + @TempDir File outputFolder; + @BeforeEach protected void setUp() throws Exception { - super.setUp(); - ArtifactHandler ah = new DefaultArtifactHandler(); VersionRange vr = VersionRange.createFromVersion("1.1"); Artifact artifact = new DefaultArtifact("test", "1", vr, Artifact.SCOPE_COMPILE, "jar", "", ah, false); @@ -58,16 +61,9 @@ protected void setUp() throws Exception { artifacts.add(artifact); artifact = new DefaultArtifact("test", "4", vr, Artifact.SCOPE_RUNTIME, "zip", "", ah, false); artifacts.add(artifact); - - outputFolder = new File("target/markers/"); - FileUtils.deleteDirectory(this.outputFolder); - assertFalse(outputFolder.exists()); - } - - protected void tearDown() throws IOException { - FileUtils.deleteDirectory(this.outputFolder); } + @Test public void testSetMarker() throws MojoExecutionException { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(artifacts.get(0), this.outputFolder); assertFalse(handler.isMarkerSet()); @@ -87,6 +83,7 @@ public void testSetMarker() throws MojoExecutionException { assertFalse(handler.isMarkerSet()); } + @Test public void testMarkerFile() throws MojoExecutionException, IOException { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(artifacts.get(0), this.outputFolder); @@ -108,6 +105,7 @@ public void testMarkerFile() throws MojoExecutionException, IOException { assertFalse(handle.exists()); } + @Test public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException { File theFile = new File(outputFolder, "theFile.jar"); outputFolder.mkdirs(); @@ -130,6 +128,7 @@ public void testMarkerTimeStamp() throws MojoExecutionException, IOException, In assertFalse(handler.isMarkerSet()); } + @Test public void testMarkerFileException() { // this stub wraps the file with an object to throw exceptions StubDefaultFileMarkerHandler handler = new StubDefaultFileMarkerHandler(artifacts.get(0), this.outputFolder); @@ -141,6 +140,7 @@ public void testMarkerFileException() { } } + @Test public void testGetterSetter() { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(null, null); assertNull(handler.getArtifact()); @@ -152,6 +152,7 @@ public void testGetterSetter() { assertSame(outputFolder, handler.getMarkerFilesDirectory()); } + @Test public void testNullParent() throws MojoExecutionException { // the parent isn't set so this will create the marker in the local // folder. We must clear the diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java index 7be795fb5..af165728f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/markers/TestUnpackMarkerFileHandler.java @@ -23,37 +23,32 @@ import java.util.ArrayList; import java.util.List; -import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; import org.apache.maven.plugins.dependency.testUtils.stubs.StubUnpackFileMarkerHandler; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class TestUnpackMarkerFileHandler extends AbstractMojoTestCase { List artifactItems = new ArrayList<>(); - Log log = new SilentLog(); - + @TempDir File outputFolder; + @TempDir protected File testDir; protected DependencyArtifactStubFactory stubFactory; + @Override + @BeforeEach protected void setUp() throws Exception { super.setUp(); - testDir = new File( - getBasedir(), - "target" + File.separatorChar + "unit-tests" + File.separatorChar + "unpack-markers" - + File.separatorChar); - FileUtils.deleteDirectory(testDir); - assertFalse(testDir.exists()); - stubFactory = new DependencyArtifactStubFactory(this.testDir, false); Artifact artifact = stubFactory.createArtifact("test", "test", "1"); ArtifactItem artifactItem; @@ -72,14 +67,6 @@ protected void setUp() throws Exception { artifactItem.setIncludes("**/*.xml"); artifactItem.setExcludes("**/*.class"); artifactItems.add(artifactItem); - - outputFolder = new File("target/markers/"); - FileUtils.deleteDirectory(this.outputFolder); - assertFalse(outputFolder.exists()); - } - - protected void tearDown() throws IOException { - FileUtils.deleteDirectory(this.outputFolder); } /** @@ -87,6 +74,7 @@ protected void tearDown() throws IOException { * * @throws MojoExecutionException in case of an error. */ + @Test public void testSetMarker() throws MojoExecutionException { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(artifactItems.get(0), this.outputFolder); assertFalse(handler.isMarkerSet()); @@ -106,6 +94,7 @@ public void testSetMarker() throws MojoExecutionException { assertFalse(handler.isMarkerSet()); } + @Test public void testMarkerFile() throws MojoExecutionException, IOException { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(artifactItems.get(0), this.outputFolder); @@ -127,9 +116,9 @@ public void testMarkerFile() throws MojoExecutionException, IOException { assertFalse(handle.exists()); } + @Test public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException { File theFile = new File(outputFolder, "theFile.jar"); - outputFolder.mkdirs(); theFile.createNewFile(); ArtifactItem theArtifactItem = artifactItems.get(0); Artifact theArtifact = theArtifactItem.getArtifact(); @@ -150,6 +139,7 @@ public void testMarkerTimeStamp() throws MojoExecutionException, IOException, In assertFalse(handler.isMarkerSet()); } + @Test public void testMarkerFileException() { // this stub wraps the file with an object to throw exceptions StubUnpackFileMarkerHandler handler = new StubUnpackFileMarkerHandler(artifactItems.get(0), this.outputFolder); @@ -161,6 +151,7 @@ public void testMarkerFileException() { } } + @Test public void testGetterSetter() { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(null, null); assertNull(handler.getArtifactItem()); @@ -174,6 +165,7 @@ public void testGetterSetter() { assertSame(outputFolder, handler.getMarkerFilesDirectory()); } + @Test public void testNullParent() throws MojoExecutionException { // the parent isn't set so this will create the marker in the local // folder. We must clear the @@ -186,6 +178,7 @@ public void testNullParent() throws MojoExecutionException { assertFalse(handler.isMarkerSet()); } + @Test public void testIncludesMarker() throws MojoExecutionException, IOException { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(artifactItems.get(1), outputFolder); File handle = handler.getMarkerFile(); @@ -208,6 +201,7 @@ public void testIncludesMarker() throws MojoExecutionException, IOException { assertFalse(handle.exists()); } + @Test public void testExcludesMarker() throws MojoExecutionException, IOException { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(artifactItems.get(2), outputFolder); File handle = handler.getMarkerFile(); @@ -230,6 +224,7 @@ public void testExcludesMarker() throws MojoExecutionException, IOException { assertFalse(handle.exists()); } + @Test public void testIncludesExcludesMarker() throws MojoExecutionException, IOException { UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(artifactItems.get(3), outputFolder); File handle = handler.getMarkerFile(); From 1d9261293f44cc1918bae0fb3e4db9abe452f8c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:23:33 -0500 Subject: [PATCH 175/283] Bump org.apache.maven.shared:maven-dependency-analyzer (#450) Bumps [org.apache.maven.shared:maven-dependency-analyzer](https://github.com/apache/maven-dependency-analyzer) from 1.15.0 to 1.15.1. - [Release notes](https://github.com/apache/maven-dependency-analyzer/releases) - [Commits](https://github.com/apache/maven-dependency-analyzer/compare/maven-dependency-analyzer-1.15.0...maven-dependency-analyzer-1.15.1) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-dependency-analyzer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b75c3dee6..11f478b6c 100644 --- a/pom.xml +++ b/pom.xml @@ -204,7 +204,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.15.0 + 1.15.1 org.apache.maven.shared From 6004f4fc1bb7e728aaf7d7efe2c46c56d9ce6758 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 9 Nov 2024 09:26:29 -0500 Subject: [PATCH 176/283] Add missing dependency on commons-io (#452) --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 11f478b6c..5845b6785 100644 --- a/pom.xml +++ b/pom.xml @@ -175,6 +175,12 @@ under the License. 3.17.0 runtime + + commons-io + commons-io + 2.16.1 + test + org.codehaus.plexus plexus-utils From 192b2c07777a106970bf44211678d19173c1cba8 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 9 Nov 2024 10:12:18 -0500 Subject: [PATCH 177/283] [MDEP-960] Repair silent logging (#447) * Fix assertion * Repair silnt logging * More asserts * deprecate * -q --- .../dependency/AbstractDependencyMojo.java | 7 +++++-- .../plugins/dependency/TestCollectMojo.java | 17 ++++++++++++----- .../dependency/resolvers/TestResolveMojo.java | 14 ++++++++++---- .../plugins/dependency/utils/TestSilentLog.java | 9 +++++---- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index bbf981af9..45e43be16 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -25,6 +25,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencySilentLog; @@ -86,7 +87,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * If the plugin should be silent. * - * @deprecated to be removed in 4.0; use -Q command line option instead + * @deprecated to be removed in 4.0; use -q command line option instead * @since 2.0 */ @Deprecated @@ -181,13 +182,15 @@ protected final boolean isSilent() { /** * @param silent {@link #silent} - * @deprecated to be removed in 4.0; no API replacement, use -Q command line option instead + * @deprecated to be removed in 4.0; no API replacement, use -q command line option instead */ @Deprecated public void setSilent(boolean silent) { this.silent = silent; if (silent) { setLog(new DependencySilentLog()); + } else if (getLog() instanceof DependencySilentLog) { + setLog(new SystemStreamLog()); } } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 070cbb69c..265bb17a2 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -23,14 +23,16 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo; +import org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.plugins.dependency.utils.DependencySilentLog; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; public class TestCollectMojo extends AbstractDependencyMojoTestCase { + @Override protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); @@ -98,10 +100,15 @@ public void testCollectTestEnvironment_excludeTransitive() throws Exception { } public void testSilent() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml"); - CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom); - mojo.setSilent(false); + File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml"); + ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom); + + assertFalse(mojo.getLog() instanceof DependencySilentLog); - assertFalse(mojo.getLog() instanceof SilentLog); + mojo.setSilent(true); + assertTrue(mojo.getLog() instanceof DependencySilentLog); + + mojo.setSilent(false); + assertFalse(mojo.getLog() instanceof DependencySilentLog); } // TODO: Test skipping artifacts. } diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 9c1d6a56f..720d13f7b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -23,14 +23,15 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.plugins.dependency.utils.DependencySilentLog; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; public class TestResolveMojo extends AbstractDependencyMojoTestCase { + @Override protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); @@ -47,7 +48,7 @@ protected void setUp() throws Exception { * * @throws Exception in case of errors. */ - public void testresolveTestEnvironment() throws Exception { + public void testResolveTestEnvironment() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml"); ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom); @@ -79,8 +80,13 @@ public void testresolveTestEnvironment() throws Exception { public void testSilent() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml"); ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom); - mojo.setSilent(false); - assertFalse(mojo.getLog() instanceof SilentLog); + assertFalse(mojo.getLog() instanceof DependencySilentLog); + + mojo.setSilent(true); + assertTrue(mojo.getLog() instanceof DependencySilentLog); + + mojo.setSilent(false); + assertFalse(mojo.getLog() instanceof DependencySilentLog); } // TODO: Test skipping artifacts. } diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java index b6cd7e435..025e42338 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestSilentLog.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.dependency.utils; import org.apache.maven.plugin.logging.Log; +import org.junit.Assert; import org.junit.Test; public class TestSilentLog { @@ -40,9 +41,9 @@ public void testLog() { log.error(text); log.error(text, e); log.error(e); - log.isDebugEnabled(); - log.isErrorEnabled(); - log.isWarnEnabled(); - log.isInfoEnabled(); + Assert.assertFalse(log.isDebugEnabled()); + Assert.assertFalse(log.isErrorEnabled()); + Assert.assertFalse(log.isWarnEnabled()); + Assert.assertFalse(log.isInfoEnabled()); } } From 8738c47fce6510040e5aae908416a66e5af3aceb Mon Sep 17 00:00:00 2001 From: Mihir Gune Date: Sat, 9 Nov 2024 17:07:31 -0600 Subject: [PATCH 178/283] Fixing flaky tests in TestTreeMojo (#451) * Fixing flaky tests in TestTreeMojo.java * Refactor imports: replace wildcards with specific class imports --- .../plugins/dependency/tree/TestTreeMojo.java | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index b1c756786..344bbccc1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -32,8 +32,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; @@ -101,8 +104,15 @@ public void testTreeTestEnvironment() throws Exception { DependencyNode rootNode = mojo.getDependencyGraph(); assertNodeEquals("testGroupId:project:jar:1.0:compile", rootNode); assertEquals(2, rootNode.getChildren().size()); - assertChildNodeEquals("testGroupId:release:jar:1.0:compile", rootNode, 0); - assertChildNodeEquals("testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 1); + + List actualNodes = Arrays.asList( + createArtifactCoordinateString(rootNode.getChildren().get(0)), + createArtifactCoordinateString(rootNode.getChildren().get(1))); + List expectedNodes = + Arrays.asList("testGroupId:release:jar:1.0:compile", "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile"); + + assertTrue(expectedNodes.containsAll(actualNodes)); + ; } /** @@ -194,8 +204,13 @@ public void testTreeJsonParsing() throws Exception { JsonArray children = root.getJsonArray("children"); assertEquals(children.size(), 2); - JsonObject child0 = children.getJsonObject(0); + List sortedChildren = children.stream() + .map(JsonObject.class::cast) + .sorted(Comparator.comparing(child -> child.getString("artifactId"))) + .collect(Collectors.toList()); + // Now that children are sorted, we can assert their values in a fixed order + JsonObject child0 = sortedChildren.get(0); assertEquals(child0.getString("groupId"), "testGroupId"); assertEquals(child0.getString("artifactId"), "release"); assertEquals(child0.getString("version"), "1.0"); @@ -204,8 +219,7 @@ public void testTreeJsonParsing() throws Exception { assertEquals(child0.getString("classifier"), ""); assertEquals(child0.getString("optional"), "false"); - JsonObject child1 = children.getJsonObject(1); - + JsonObject child1 = sortedChildren.get(1); assertEquals(child1.getString("groupId"), "testGroupId"); assertEquals(child1.getString("artifactId"), "snapshot"); assertEquals(child1.getString("version"), "2.0-SNAPSHOT"); @@ -271,12 +285,6 @@ private boolean findString(List contents, String str) { // private methods -------------------------------------------------------- - private void assertChildNodeEquals(String expectedNode, DependencyNode actualParentNode, int actualChildIndex) { - DependencyNode actualNode = actualParentNode.getChildren().get(actualChildIndex); - - assertNodeEquals(expectedNode, actualNode); - } - private void assertNodeEquals(String expectedNode, DependencyNode actualNode) { String[] tokens = expectedNode.split(":"); @@ -298,4 +306,12 @@ private void assertNodeEquals( assertEquals("version", expectedVersion, actualArtifact.getVersion()); assertEquals("scope", expectedScope, actualArtifact.getScope()); } + + private String createArtifactCoordinateString(DependencyNode actualNode) { + return actualNode.getArtifact().getGroupId() + ":" + + actualNode.getArtifact().getArtifactId() + ":" + + actualNode.getArtifact().getType() + ":" + + actualNode.getArtifact().getVersion() + ":" + + actualNode.getArtifact().getScope(); + } } From 263f65b32d3676f0fcdfad51cae1674a150a200c Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 10 Nov 2024 06:01:24 -0500 Subject: [PATCH 179/283] Remove unused code (#453) --- .../plugins/dependency/ListRepositoriesMojo.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index fa067ded4..d86c38653 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -44,8 +44,8 @@ import org.eclipse.aether.util.graph.visitor.TreeDependencyVisitor; /** - * Goal that collect all project dependencies and then lists the repositories used by the build and by the transitive - * dependencies + * Goal that collects all project dependencies and then lists the repositories used by the build and by the transitive + * dependencies. * * @author Brian Fox * @since 2.2 @@ -143,14 +143,4 @@ private void prepareRemoteRepositoriesList( remoteProjectRepositories.forEach( repo -> message.append(" * ").append(repo).append(System.lineSeparator())); } - - private Map getMirroredRepo(Set repositories) { - Map mirrorMap = new HashMap<>(); - - repositories.stream() - .filter(repo -> !repo.getMirroredRepositories().isEmpty()) - .forEach(repo -> repo.getMirroredRepositories().forEach(mrepo -> mirrorMap.put(mrepo, repo))); - - return mirrorMap; - } } From 7ae0aba59c3243cffd0f9407b919fd4e413dbd57 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 10 Nov 2024 07:54:25 -0500 Subject: [PATCH 180/283] Remove invocations of now deprecated methods we want to delete (#456) --- .../org/apache/maven/plugins/dependency/TestCollectMojo.java | 2 -- .../plugins/dependency/fromConfiguration/TestCopyMojo.java | 1 - .../plugins/dependency/fromConfiguration/TestUnpackMojo.java | 2 -- .../maven/plugins/dependency/resolvers/TestResolveMojo.java | 1 - 4 files changed, 6 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 265bb17a2..9e86c813a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -56,7 +56,6 @@ public void testCollectTestEnvironment() throws Exception { assertNotNull(mojo.getProject()); MavenProject project = mojo.getProject(); - mojo.setSilent(true); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll(directArtifacts); @@ -83,7 +82,6 @@ public void testCollectTestEnvironment_excludeTransitive() throws Exception { assertNotNull(mojo.getProject()); MavenProject project = mojo.getProject(); - mojo.setSilent(true); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll(directArtifacts); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index 4390f9bf7..3af9f1fce 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -49,7 +49,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/copy-test/plugin-config.xml"); mojo = (CopyMojo) lookupMojo("copy", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); - mojo.setSilent(true); assertNotNull(mojo); assertNotNull(mojo.getProject()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 66614da7c..f18776fb0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -58,7 +58,6 @@ protected void setUp() throws Exception { mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); mojo.setMarkersDirectory(new File(this.testDir, "markers")); - mojo.setSilent(true); assertNotNull(mojo); assertNotNull(mojo.getProject()); @@ -477,7 +476,6 @@ public void testUnpackOverWriteSnapshot() throws Exception { public void testUnpackOverWriteIfNewer() throws Exception { final long now = System.currentTimeMillis(); - mojo.setSilent(false); stubFactory.setCreateFiles(true); Artifact artifact = stubFactory.getSnapshotArtifact(); assertTrue(artifact.getFile().setLastModified(now - 20000)); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 720d13f7b..2bdcb6fc8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -56,7 +56,6 @@ public void testResolveTestEnvironment() throws Exception { assertNotNull(mojo.getProject()); MavenProject project = mojo.getProject(); - mojo.setSilent(true); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll(directArtifacts); From 74a956b5de92702bc63a0b101f46add3523b7aa5 Mon Sep 17 00:00:00 2001 From: Mihir Gune Date: Sun, 10 Nov 2024 07:04:57 -0600 Subject: [PATCH 181/283] Fixing flaky test in TestCopyDependenciesMojo (#455) --- .../fromDependencies/TestCopyDependenciesMojo.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index e1ec92823..724d30fb1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -564,9 +564,8 @@ public void testOverWriteSnap() throws MojoExecutionException, IOException, Mojo } public void testGetDependencies() throws MojoExecutionException { - assertEquals( - mojo.getResolvedDependencies(true).toString(), - mojo.getDependencySets(true).getResolvedDependencies().toString()); + assertTrue(mojo.getResolvedDependencies(true) + .containsAll(mojo.getDependencySets(true).getResolvedDependencies())); } public void testExcludeProvidedScope() throws Exception { From d77623dbe1a8b5e1e5f7579164b6b82a00f1bf7f Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 10 Nov 2024 12:15:31 -0500 Subject: [PATCH 182/283] Remove obsolete commented out code --- .../fromConfiguration/TestIncludeExcludeUnpackMojo.java | 1 - .../dependency/fromDependencies/TestBuildClasspathMojo.java | 1 - .../dependency/fromDependencies/TestCopyDependenciesMojo.java | 3 --- .../dependency/fromDependencies/TestCopyDependenciesMojo2.java | 1 - .../TestIncludeExcludeUnpackDependenciesMojo.java | 1 - .../fromDependencies/TestUnpackDependenciesMojo.java | 3 --- .../fromDependencies/TestUnpackDependenciesMojo2.java | 1 - 7 files changed, 11 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 5778f0e29..02c3644c8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -56,7 +56,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); - // mojo.silent = true; // i'm using one file repeatedly to archive so I can test the name // programmatically. diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index 74d80b5bf..f310ec0df 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -56,7 +56,6 @@ protected void setUp() throws Exception { public void testEnvironment() throws Exception { MavenProject project = mojo.getProject(); - // mojo.silent = true; Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll(directArtifacts); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index 724d30fb1..91ebbd46e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -61,7 +61,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - // mojo.silent = true; assertNotNull(mojo); assertNotNull(mojo.getProject()); @@ -572,7 +571,6 @@ public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "provided"; - // mojo.silent = false; mojo.execute(); @@ -590,7 +588,6 @@ public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "system"; - // mojo.silent = false; mojo.execute(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index 5a2998375..f3a1f8b4f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -69,7 +69,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - // mojo.silent = true; assertNotNull(mojo); assertNotNull(mojo.getProject()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 8195ae16c..0617b8755 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -51,7 +51,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - // mojo.silent = true; // it needs to get the archivermanager // stubFactory.setUnpackableFile( mojo.getArchiverManager() ); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 463f8f9b6..ef795a2e7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -67,7 +67,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - // mojo.silent = true; // it needs to get the archivermanager stubFactory.setUnpackableFile(lookup(ArchiverManager.class)); @@ -161,7 +160,6 @@ public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "provided"; - // mojo.silent = false; mojo.execute(); @@ -174,7 +172,6 @@ public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "system"; - // mojo.silent = false; mojo.execute(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 70941f9c8..cba5392fb 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -55,7 +55,6 @@ protected void setUp() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); - // mojo.silent = true; // it needs to get the archivermanager stubFactory.setUnpackableFile(lookup(ArchiverManager.class)); From cf3c45c0e1bef58fda1a34ae090f3f737a9b573e Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 12 Nov 2024 16:24:00 +0000 Subject: [PATCH 183/283] [MDEP-965] javax.json --> jakarta.json (#461) * javax.json --> jakarta.json --- pom.xml | 10 +++++----- .../maven/plugins/dependency/tree/TestTreeMojo.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 5845b6785..d02c01811 100644 --- a/pom.xml +++ b/pom.xml @@ -311,15 +311,15 @@ under the License. test - javax.json - javax.json-api - 1.1.4 + jakarta.json + jakarta.json-api + 2.0.2 test org.glassfish - javax.json - 1.1.4 + jakarta.json + 2.0.1 test diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index 344bbccc1..edbceb879 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -18,11 +18,6 @@ */ package org.apache.maven.plugins.dependency.tree; -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -38,6 +33,10 @@ import java.util.Set; import java.util.stream.Collectors; +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; @@ -190,6 +189,7 @@ public void testTreeJsonCircularDependency() throws IOException { public void testTreeJsonParsing() throws Exception { List contents = runTreeMojo("tree2.json", "json"); + System.setProperty("jakarta.json.provider", "org.glassfish.json.JsonProviderImpl"); try (JsonReader reader = Json.createReader(new StringReader(String.join("\n", contents)))) { JsonObject root = reader.readObject(); From d9ad8ee1116e4ba713ca280fc80e3107d42acff1 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 12 Nov 2024 17:47:42 +0000 Subject: [PATCH 184/283] [MDEP-957] Test org.slf4j:slf4j-simple is ignored (#460) * Expand test --- src/it/projects/analyze/verify.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/it/projects/analyze/verify.groovy b/src/it/projects/analyze/verify.groovy index 085cf324b..4b430120a 100644 --- a/src/it/projects/analyze/verify.groovy +++ b/src/it/projects/analyze/verify.groovy @@ -36,6 +36,8 @@ assert buildLog.contains( '[WARNING] org.apache.maven:maven-repository-metada assert buildLog.contains( '[WARNING] class org.apache.maven.artifact.repository.metadata.Metadata') assert buildLog.contains( '[WARNING] Unused declared dependencies found:') assert buildLog.contains( '[WARNING] org.apache.maven:maven-project:jar:2.0.6:compile') - +assert buildLog.contains( '[INFO] Ignored unused declared dependencies:') +assert buildLog.contains( '[INFO] org.slf4j:slf4j-simple:jar:2.0.16:compile') +assert !buildLog.contains( '[WARNING] org.slf4j:slf4j-simple:jar:2.0.16:compile') return true From c8a22b6b5623e0f9964176563ff00b1a36670063 Mon Sep 17 00:00:00 2001 From: Lisa Hardy <116385169+ldhardy@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:08:13 -0500 Subject: [PATCH 185/283] [MDEP-689] Fixes ignored dependency filtering in go-offline goal (#417) --- pom.xml | 3 + .../invoker.properties | 18 + .../pom.xml | 109 +++++ .../verify.groovy | 50 +++ .../AbstractDependencyFilterMojo.java | 4 +- .../resolvers/AbstractResolveMojo.java | 41 ++ .../dependency/resolvers/GoOfflineMojo.java | 61 ++- .../resolvers/ResolvePluginsMojo.java | 39 -- .../resolvers/GoOfflineMojoTest.java | 405 ++++++++++++++++++ .../go-offline-test/exclude-plugin-config.xml | 35 ++ .../include-aid-plugin-config.xml | 25 ++ .../include-gid-plugin-config.xml | 24 ++ .../include-scope-plugin-config.xml | 24 ++ .../include-types-plugin-config.xml | 24 ++ 14 files changed, 819 insertions(+), 43 deletions(-) create mode 100644 src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties create mode 100644 src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml create mode 100644 src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy create mode 100644 src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java create mode 100644 src/test/resources/unit/go-offline-test/exclude-plugin-config.xml create mode 100644 src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml create mode 100644 src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml create mode 100644 src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml create mode 100644 src/test/resources/unit/go-offline-test/include-types-plugin-config.xml diff --git a/pom.xml b/pom.xml index d02c01811..5cdf2565d 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,9 @@ under the License. Maarten Mulders + + Lisa Hardy + diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties new file mode 100644 index 000000000..4623ccd63 --- /dev/null +++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = clean ${project.groupId}:${project.artifactId}:${project.version}:go-offline diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml new file mode 100644 index 000000000..a41847d9e --- /dev/null +++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml @@ -0,0 +1,109 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.dependency + mdep-739-go-offline-respect-classifiers + 1.0.0-SNAPSHOT + Test that dependency:go-offline applies exclude filters + + + skip.this.groupid + dummy-artifact + 1.0 + + + skip.this.groupid.too + dummy-artifact + 1.0 + + + org.junit.jupiter + skip-this-artifact + 1.0 + + + org.junit.jupiter + skip-this-artifact-too + 1.0-SNAPSHOT + + + ch.qos.logback + logback-access + 1.4.7 + skipThisClassifier + + + ch.qos.logback + logback-core + 1.5.6 + skipThisClassifierToo + + + org.slf4j + slf4j-api + 2.0.13 + compile + + + ch.qos.logback + logback-classic + 1.5.4 + system + + ${project.build.directory}/local-repo/junit/junit/4.13.2/junit-4.13.2.jar + + + org.slf4j + slf4j-simple + 2.0.13 + + + ch.qos.logback + logback-examples + 1.4.7 + ear + + + + + + + maven-dependency-plugin + @project.version@ + + skip.this.groupid,skip.this.groupid.too + skip-this-artifact,skip-this-artifact-too + + + system + ear + skipThisClassifier,skipThisClassifierToo + + + + + + diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy new file mode 100644 index 000000000..1bc9464f7 --- /dev/null +++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/verify.groovy @@ -0,0 +1,50 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ) +assert file.exists() + +String buildLog = file.getText( "UTF-8" ) + +// Make sure non-exluded explicit dependencies are resolved +assert buildLog.contains( 'Resolved dependency: slf4j-simple-2.0.13.jar' ) +assert buildLog.contains( 'Resolved dependency: slf4j-api-2.0.13.jar' ) + +// Did group excludes work? +assert !buildLog.contains( 'Resolving artifact skip.this.groupid' ) + +// Did artifact excludes work? +assert !buildLog.contains( 'Resolving artifact org.junit.jupiter:skip-this-artifact' ) + +// Did scope exludes work? +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-classic' ) + +// Did type excludes work? +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-examples' ) + +// Did classifier excludes work? +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-core:jar:skipThisClassifierToo' ) +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-core' ) + +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-access:jar:skipThisClassifier' ) +assert !buildLog.contains( 'Resolving artifact ch.qos.logback:logback-access' ) + + + +return true diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 655458b5d..63a1cfa1b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -136,7 +136,9 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj /** * Scope threshold to exclude, if no value is defined for include. - * An empty string indicates no dependencies (default).
+ * An empty string indicates no dependencies (default). Unlike the other + * exclusion parameters, this property does not support a comma-delimited + * list of scope exclusions. Just one scope may be excluded at a time.
* The scope threshold value being interpreted is the scope as * Maven filters for creating a classpath, not as specified in the pom. In summary: *
    diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index a452968ee..bf03a003f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -22,6 +22,13 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; +import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; +import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; +import org.apache.maven.shared.artifact.filter.collection.TypeFilter; /** * @author Brian Fox @@ -52,4 +59,38 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { */ @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; + + /** + * @return {@link FilterArtifacts} + */ + protected FilterArtifacts getArtifactsFilter() { + final FilterArtifacts filter = new FilterArtifacts(); + + if (excludeReactor) { + + filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); + } + + filter.addFilter(new ScopeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeScope), + DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); + + filter.addFilter(new TypeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeTypes), + DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); + + filter.addFilter(new ClassifierFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), + DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); + + filter.addFilter(new GroupIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); + + filter.addFilter(new ArtifactIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); + + return filter; + } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index 1bc3e4d7a..6ca1c3968 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -25,13 +25,17 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; @@ -43,6 +47,7 @@ * * @author Brian Fox * @author Maarten Mulders + * @author Lisa Hardy * @since 2.0 */ @Mojo(name = "go-offline", threadSafe = true) @@ -71,7 +76,7 @@ protected void doExecute() throws MojoExecutionException { } } - } catch (DependencyResolverException e) { + } catch (DependencyResolverException | ArtifactFilterException e) { throw new MojoExecutionException(e.getMessage(), e); } } @@ -81,10 +86,13 @@ protected void doExecute() throws MojoExecutionException { * * @return set of resolved dependency artifacts. * @throws DependencyResolverException in case of an error while resolving the artifacts. + * @throws ArtifactFilterException */ - protected Set resolveDependencyArtifacts() throws DependencyResolverException { + protected Set resolveDependencyArtifacts() throws DependencyResolverException, ArtifactFilterException { Collection dependencies = getProject().getDependencies(); + dependencies = filterDependencies(dependencies); + Set dependableCoordinates = dependencies.stream() .map(this::createDependendableCoordinateFromDependency) .collect(Collectors.toSet()); @@ -133,8 +141,9 @@ private TransformableFilter getTransformableFilter() { * * @return set of resolved plugin artifacts. * @throws DependencyResolverException in case of an error while resolving the artifacts. + * @throws ArtifactFilterException */ - protected Set resolvePluginArtifacts() throws DependencyResolverException { + protected Set resolvePluginArtifacts() throws DependencyResolverException, ArtifactFilterException { Set plugins = getProject().getPluginArtifacts(); Set reports = getProject().getReportArtifacts(); @@ -143,6 +152,9 @@ protected Set resolvePluginArtifacts() throws DependencyResolverExcept artifacts.addAll(reports); artifacts.addAll(plugins); + final FilterArtifacts filter = getArtifactsFilter(); + artifacts = filter.filter(artifacts); + Set dependableCoordinates = artifacts.stream() .map(this::createDependendableCoordinateFromArtifact) .collect(Collectors.toSet()); @@ -152,6 +164,16 @@ protected Set resolvePluginArtifacts() throws DependencyResolverExcept return resolveDependableCoordinate(buildingRequest, dependableCoordinates, "plugins"); } + private Collection filterDependencies(Collection deps) throws ArtifactFilterException { + + Set artifacts = createArtifactSetFromDependencies(deps); + + final FilterArtifacts filter = getArtifactsFilter(); + artifacts = filter.filter(artifacts); + + return createDependencySetFromArtifacts(artifacts); + } + private DependableCoordinate createDependendableCoordinateFromArtifact(final Artifact artifact) { final DefaultDependableCoordinate result = new DefaultDependableCoordinate(); result.setGroupId(artifact.getGroupId()); @@ -174,6 +196,39 @@ private DependableCoordinate createDependendableCoordinateFromDependency(final D return result; } + private Set createArtifactSetFromDependencies(Collection deps) { + Set artifacts = new HashSet<>(); + for (Dependency dep : deps) { + DefaultArtifactHandler handler = new DefaultArtifactHandler(dep.getType()); + artifacts.add(new DefaultArtifact( + dep.getGroupId(), + dep.getArtifactId(), + dep.getVersion(), + dep.getScope(), + dep.getType(), + dep.getClassifier(), + handler)); + } + return artifacts; + } + + private Collection createDependencySetFromArtifacts(Set artifacts) { + Set dependencies = new HashSet<>(); + + for (Artifact artifact : artifacts) { + Dependency d = new Dependency(); + d.setGroupId(artifact.getGroupId()); + d.setArtifactId(artifact.getArtifactId()); + d.setVersion(artifact.getVersion()); + d.setType(artifact.getType()); + d.setClassifier(artifact.getClassifier()); + d.setScope(artifact.getScope()); + dependencies.add(d); + } + + return dependencies; + } + @Override protected ArtifactsFilter getMarkedArtifactFilter() { return null; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 4c6e91ac3..4a6a23782 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -33,13 +33,8 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; -import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; -import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; -import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; @@ -174,40 +169,6 @@ private Set resolveArtifactDependencies(final DependableCoordinate art return artifacts; } - /** - * @return {@link FilterArtifacts} - */ - private FilterArtifacts getArtifactsFilter() { - final FilterArtifacts filter = new FilterArtifacts(); - - if (excludeReactor) { - - filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); - } - - filter.addFilter(new ScopeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeScope), - DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); - - filter.addFilter(new TypeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeTypes), - DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); - - filter.addFilter(new ClassifierFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), - DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); - - filter.addFilter(new GroupIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); - - filter.addFilter(new ArtifactIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); - - return filter; - } - /** * This method resolves the plugin artifacts from the project. * diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java new file mode 100644 index 000000000..caa00f160 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java @@ -0,0 +1,405 @@ +/* + * 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.dependency.resolvers; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.testing.stubs.ArtifactStub; +import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; +import org.junit.jupiter.api.Disabled; + +public class GoOfflineMojoTest extends AbstractDependencyMojoTestCase { + private GoOfflineMojo subject; + + protected void setUp() throws Exception { + // required for mojo lookups to work + super.setUp("go-offline", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + } + + String GROUP_EXCLUDE_PREFIX = "skip.this.groupid"; + + String ARTIFACT_EXCLUDE_PREFIX = "skip-this-artifact"; + + String CLASSIFIER_EXCLUDE_PREFIX = "skipThisClassifier"; + + String DUMMY_ARTIFACT_NAME = "dummy-artifact"; + + String STUB_ARTIFACT_VERSION = "3.14"; + + String VALID_GROUP = "org.junit.jupiter"; + + public void test_excludeGroupIds() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(GROUP_EXCLUDE_PREFIX); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(GROUP_EXCLUDE_PREFIX + ".too"); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId("dont.skip.me"); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion("1.0"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(1, artifacts.size()); + assertTrue(artifacts.contains(artifact3)); + assertFalse(artifacts.contains(artifact1)); + assertFalse(artifacts.contains(artifact2)); + } + + public void test_excludeArtifactIds() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(ARTIFACT_EXCLUDE_PREFIX); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(ARTIFACT_EXCLUDE_PREFIX + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId("dont.skip.me"); + artifact3.setArtifactId("dummy-artifact"); + artifact3.setVersion("1.0"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(1, artifacts.size()); + assertTrue(artifacts.contains(artifact3)); + assertFalse(artifacts.contains(artifact1)); + assertFalse(artifacts.contains(artifact2)); + } + + public void test_excludeScope() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + artifact2.setScope("system"); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion(STUB_ARTIFACT_VERSION); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(2, artifacts.size()); + assertTrue(artifacts.contains(artifact3)); + assertTrue(artifacts.contains(artifact1)); + assertFalse(artifacts.contains(artifact2)); + } + + public void test_excludeTypes() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + ArtifactStub artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + artifact1.setType("ear"); + + ArtifactStub artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + artifact2.setType("war"); + + ArtifactStub artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion(STUB_ARTIFACT_VERSION); + artifact3.setType("pom"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(1, artifacts.size()); + assertFalse(artifacts.contains(artifact3)); + assertTrue(artifacts.contains(artifact2)); + assertFalse(artifacts.contains(artifact1)); + } + + /** + * Can't set a classifier on the ArtifactStub as of maven-plugin-testing-harness-3.3.0, there is a getter but no + * setter. If that ever gets implemented, comment in these two lines to support unit testing for this case, rename + * xtest to test and remove the Junit 5 Disabled annotation + * + * @throws Exception + */ + @Disabled("Requires update to maven-plugin-test-harness to support this test") + public void xtest_excludeClassifiers() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + ArtifactStub artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + // artifact1.setClassifier(CLASSIFIER_EXCLUDE_PREFIX); + + ArtifactStub artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + // artifact2.setClassifier(CLASSIFIER_EXCLUDE_PREFIX + "Too"); + + ArtifactStub artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion(STUB_ARTIFACT_VERSION); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(1, artifacts.size()); + assertFalse(artifacts.contains(artifact1)); + assertFalse(artifacts.contains(artifact2)); + assertTrue(artifacts.contains(artifact3)); + } + + String GROUP_INCLUDE_PREFIX = "include.this.groupid"; + + String ARTIFACT_INCLUDE_PREFIX = "include-this-artifact"; + + String CLASSIFIER_INCLUDE_PREFIX = "includeThisClassifier"; + + public void test_includeGroupIds() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-gid-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(GROUP_INCLUDE_PREFIX); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(GROUP_INCLUDE_PREFIX + ".too"); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId("skip.me"); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion("1.0"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + + assertEquals(2, artifacts.size()); + assertFalse(artifacts.contains(artifact3)); + assertTrue(artifacts.contains(artifact1)); + assertTrue(artifacts.contains(artifact2)); + } + + public void test_includeArtifactIds() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-aid-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(ARTIFACT_INCLUDE_PREFIX); + artifact1.setVersion(STUB_ARTIFACT_VERSION); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(ARTIFACT_INCLUDE_PREFIX + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion("1.0"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + + assertEquals(2, artifacts.size()); + assertFalse(artifacts.contains(artifact3)); + assertTrue(artifacts.contains(artifact1)); + assertTrue(artifacts.contains(artifact2)); + } + + public void test_includeScope() throws Exception { + File testPom = + new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-scope-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + Artifact artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + artifact1.setScope("provided"); + + Artifact artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + artifact2.setScope("system"); + + Artifact artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion(STUB_ARTIFACT_VERSION); + artifact3.setScope("test"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(1, artifacts.size()); + + assertTrue(artifacts.contains(artifact1)); + assertFalse(artifacts.contains(artifact2)); + assertFalse(artifacts.contains(artifact3)); + } + + public void test_includeTypes() throws Exception { + File testPom = + new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-types-plugin-config.xml"); + + subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); + assertNotNull(subject); + + ArtifactStub artifact1 = new ArtifactStub(); + artifact1.setGroupId(VALID_GROUP); + artifact1.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact1.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + artifact1.setType("ear"); + + ArtifactStub artifact2 = new ArtifactStub(); + artifact2.setGroupId(VALID_GROUP); + artifact2.setArtifactId(DUMMY_ARTIFACT_NAME + "-too"); + artifact2.setVersion(STUB_ARTIFACT_VERSION); + artifact2.setType("pom"); + + ArtifactStub artifact3 = new ArtifactStub(); + artifact3.setGroupId(VALID_GROUP); + artifact3.setArtifactId(DUMMY_ARTIFACT_NAME); + artifact3.setVersion(STUB_ARTIFACT_VERSION + "-SNAPSHOT"); + artifact3.setType("war"); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact1); + artifacts.add(artifact2); + artifacts.add(artifact3); + + assertEquals(3, artifacts.size()); + FilterArtifacts filter = subject.getArtifactsFilter(); + artifacts = filter.filter(artifacts); + assertEquals(2, artifacts.size()); + + assertTrue(artifacts.contains(artifact1)); + assertTrue(artifacts.contains(artifact2)); + assertFalse(artifacts.contains(artifact3)); + } +} diff --git a/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml b/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml new file mode 100644 index 000000000..c80cf3433 --- /dev/null +++ b/src/test/resources/unit/go-offline-test/exclude-plugin-config.xml @@ -0,0 +1,35 @@ + + + + + + maven-dependency-plugin + @project.version@ + + skip.this.groupid,skip.this.groupid.too + + skip-this-artifact,skip-this-artifact-too + + + + system + ear,pom + skipThisClassifier,skipThisClassifierToo + + + + + + diff --git a/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml new file mode 100644 index 000000000..cd792ec85 --- /dev/null +++ b/src/test/resources/unit/go-offline-test/include-aid-plugin-config.xml @@ -0,0 +1,25 @@ + + + + + + maven-dependency-plugin + @project.version@ + + include-this-artifact,include-this-artifact-too + + + + + + \ No newline at end of file diff --git a/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml new file mode 100644 index 000000000..8d2c425a0 --- /dev/null +++ b/src/test/resources/unit/go-offline-test/include-gid-plugin-config.xml @@ -0,0 +1,24 @@ + + + + + + maven-dependency-plugin + @project.version@ + + include.this.groupid,include.this.groupid.too + + + + + \ No newline at end of file diff --git a/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml new file mode 100644 index 000000000..2230d2a8b --- /dev/null +++ b/src/test/resources/unit/go-offline-test/include-scope-plugin-config.xml @@ -0,0 +1,24 @@ + + + + + + maven-dependency-plugin + @project.version@ + + provided + + + + + \ No newline at end of file diff --git a/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml b/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml new file mode 100644 index 000000000..e7e2365ff --- /dev/null +++ b/src/test/resources/unit/go-offline-test/include-types-plugin-config.xml @@ -0,0 +1,24 @@ + + + + + + maven-dependency-plugin + @project.version@ + + pom,ear + + + + + \ No newline at end of file From 73ca5f9f2319e93c56f31b74e8591dd86906885a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 16 Nov 2024 17:11:43 +0000 Subject: [PATCH 186/283] Remove deprecated setup code test doesn't need (#468) --- .../utils/translators/TestClassifierTypeTranslator.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index 93fd632c9..86b35142e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -24,8 +24,6 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.factory.DefaultArtifactFactory; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -44,8 +42,6 @@ public class TestClassifierTypeTranslator extends AbstractDependencyMojoTestCase { Set artifacts = new HashSet<>(); - ArtifactFactory artifactFactory; - ArtifactRepository artifactRepository; Log log = new SilentLog(); @@ -59,9 +55,6 @@ protected void setUp() throws Exception { artifactHandlerManager = new DefaultArtifactHandlerManager(); this.setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap<>()); - artifactFactory = new DefaultArtifactFactory(); - this.setVariableValueToObject(artifactFactory, "artifactHandlerManager", artifactHandlerManager); - artifactRepository = new StubArtifactRepository(null); DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory(null, false); From c04f2236410cfaacf78f7800b66acd36f4a2e7c9 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 17 Nov 2024 12:21:16 +0000 Subject: [PATCH 187/283] Cleanup a few obsolete TODOs (#467) --- .../AbstractDependencyFilterMojo.java | 6 +++--- .../fromDependencies/BuildClasspathMojo.java | 1 - .../analyze/TestAnalyzeDuplicateMojo.java | 17 ++++++++++++++++- .../exclusion/AnalyzeExclusionsMojoTest.java | 17 ++++++++++++++++- .../resolvers/ResolveDependenciesMojoTest.java | 4 ++-- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 63a1cfa1b..c6a4633e8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -480,7 +480,7 @@ public File getMarkersDirectory() { } /** - * @param theMarkersDirectory The markersDirectory to set. + * @param theMarkersDirectory the markersDirectory to set */ public void setMarkersDirectory(File theMarkersDirectory) { this.markersDirectory = theMarkersDirectory; @@ -489,14 +489,14 @@ public void setMarkersDirectory(File theMarkersDirectory) { // TODO: Set marker files. /** - * @return true, if the groupId should be prepended to the filename. + * @return true, if the groupId should be prepended to the filename */ public boolean isPrependGroupId() { return prependGroupId; } /** - * @param prependGroupId - true if the groupId must be prepended during the copy. + * @param prependGroupId true if the groupId must be prepended during the copy */ public void setPrependGroupId(boolean prependGroupId) { this.prependGroupId = prependGroupId; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 698c2739e..5604ece9e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -270,7 +270,6 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { } sb.append(file); } else { - // TODO: add param for prepending groupId and version. sb.append(prefix); sb.append(File.separator); sb.append(DependencyUtil.getFormattedFileName( diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java index 339d2b646..b0b758092 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java @@ -76,56 +76,67 @@ static class DuplicateLog implements Log { StringBuilder sb = new StringBuilder(); /** {@inheritDoc} */ + @Override public void debug(CharSequence content) { print("debug", content); } /** {@inheritDoc} */ + @Override public void debug(CharSequence content, Throwable error) { print("debug", content, error); } /** {@inheritDoc} */ + @Override public void debug(Throwable error) { print("debug", error); } /** {@inheritDoc} */ + @Override public void info(CharSequence content) { print("info", content); } /** {@inheritDoc} */ + @Override public void info(CharSequence content, Throwable error) { print("info", content, error); } /** {@inheritDoc} */ + @Override public void info(Throwable error) { print("info", error); } /** {@inheritDoc} */ + @Override public void warn(CharSequence content) { print("warn", content); } /** {@inheritDoc} */ + @Override public void warn(CharSequence content, Throwable error) { print("warn", content, error); } /** {@inheritDoc} */ + @Override public void warn(Throwable error) { print("warn", error); } /** {@inheritDoc} */ + @Override public void error(CharSequence content) { System.err.println("[error] " + content.toString()); } /** {@inheritDoc} */ + @Override public void error(CharSequence content, Throwable error) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); @@ -139,6 +150,7 @@ public void error(CharSequence content, Throwable error) { /** * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) */ + @Override public void error(Throwable error) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); @@ -151,14 +163,15 @@ public void error(Throwable error) { /** * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() */ + @Override public boolean isDebugEnabled() { - // TODO: Not sure how best to set these for this implementation... return false; } /** * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() */ + @Override public boolean isInfoEnabled() { return true; } @@ -166,6 +179,7 @@ public boolean isInfoEnabled() { /** * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() */ + @Override public boolean isWarnEnabled() { return true; } @@ -173,6 +187,7 @@ public boolean isWarnEnabled() { /** * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() */ + @Override public boolean isErrorEnabled() { return true; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index bbcc74857..f4e37d424 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -230,6 +230,7 @@ static class TestLog implements Log { /** * {@inheritDoc} */ + @Override public void debug(CharSequence content) { print("debug", content); } @@ -237,6 +238,7 @@ public void debug(CharSequence content) { /** * {@inheritDoc} */ + @Override public void debug(CharSequence content, Throwable error) { print("debug", content, error); } @@ -244,6 +246,7 @@ public void debug(CharSequence content, Throwable error) { /** * {@inheritDoc} */ + @Override public void debug(Throwable error) { print("debug", error); } @@ -251,6 +254,7 @@ public void debug(Throwable error) { /** * {@inheritDoc} */ + @Override public void info(CharSequence content) { print("info", content); } @@ -258,6 +262,7 @@ public void info(CharSequence content) { /** * {@inheritDoc} */ + @Override public void info(CharSequence content, Throwable error) { print("info", content, error); } @@ -265,6 +270,7 @@ public void info(CharSequence content, Throwable error) { /** * {@inheritDoc} */ + @Override public void info(Throwable error) { print("info", error); } @@ -272,6 +278,7 @@ public void info(Throwable error) { /** * {@inheritDoc} */ + @Override public void warn(CharSequence content) { print("warn", content); } @@ -279,6 +286,7 @@ public void warn(CharSequence content) { /** * {@inheritDoc} */ + @Override public void warn(CharSequence content, Throwable error) { print("warn", content, error); } @@ -286,6 +294,7 @@ public void warn(CharSequence content, Throwable error) { /** * {@inheritDoc} */ + @Override public void warn(Throwable error) { print("warn", error); } @@ -293,6 +302,7 @@ public void warn(Throwable error) { /** * {@inheritDoc} */ + @Override public void error(CharSequence content) { print("error", content); } @@ -300,6 +310,7 @@ public void error(CharSequence content) { /** * {@inheritDoc} */ + @Override public void error(CharSequence content, Throwable error) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); @@ -313,6 +324,7 @@ public void error(CharSequence content, Throwable error) { /** * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) */ + @Override public void error(Throwable error) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); @@ -325,14 +337,15 @@ public void error(Throwable error) { /** * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() */ + @Override public boolean isDebugEnabled() { - // TODO: Not sure how best to set these for this implementation... return false; } /** * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() */ + @Override public boolean isInfoEnabled() { return true; } @@ -340,6 +353,7 @@ public boolean isInfoEnabled() { /** * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() */ + @Override public boolean isWarnEnabled() { return true; } @@ -347,6 +361,7 @@ public boolean isWarnEnabled() { /** * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() */ + @Override public boolean isErrorEnabled() { return true; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index a9d3c6077..ff9197973 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -28,6 +28,7 @@ import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; public class ResolveDependenciesMojoTest extends AbstractDependencyMojoTestCase { + @Override protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("dss", true); @@ -60,8 +61,7 @@ public void testOptionalDependencyFormatting() throws IOException { assertTrue(output.contains("g:a:jar:1.0:test (optional)" + System.lineSeparator())); } - public void doTestDependencyStatusLog(Set artifacts) { - // TODO: implement logger to check correct output + private void doTestDependencyStatusLog(Set artifacts) { // this test is just looking for unexpected exceptions. ResolveDependenciesMojo mojo = newMojo(new DependencyStatusSets()); From c6528a9250b24d72ddb3377db8fcbbc54cfb6e25 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 17 Nov 2024 15:46:15 +0000 Subject: [PATCH 188/283] Reduce noise from passing integration tests (#470) --- .../copy-and-unpack-with-alternate-local-repo/verify.bsh | 3 --- src/it/projects/copy-cli/verify.bsh | 1 - src/it/projects/copy-dependencies/verify.bsh | 2 -- src/it/projects/copy-from-reactor/verify.bsh | 1 - src/it/projects/copy-from-remote-repository/verify.bsh | 1 - src/it/projects/copy-with-prependGroupId/verify.bsh | 1 - src/it/projects/copy/verify.bsh | 1 - src/it/projects/get-artifact-maven-plugin/verify.bsh | 1 - src/it/projects/get-artifact-no-transitive/verify.bsh | 2 -- src/it/projects/get-artifact/verify.bsh | 1 - src/it/projects/get-gav/verify.bsh | 1 - src/it/projects/purge-local-repository-bad-pom/verify.bsh | 2 -- .../purge-local-repository-multi-module-execution/setup.bsh | 2 -- .../purge-local-repository-multi-module-execution/verify.bsh | 4 +--- .../projects/purge-local-repository-multi-module/setup.bsh | 2 -- .../purge-local-repository-non-transitive/verify.bsh | 2 -- src/it/projects/purge-local-repository-reresolve/verify.bsh | 2 -- .../projects/purge-local-repository-snapshots-only/setup.bsh | 5 ----- .../purge-local-repository-snapshots-only/verify.bsh | 4 ---- .../projects/purge-local-repository-version-range/verify.bsh | 2 -- src/it/projects/purge-local-repository-without-pom/setup.bsh | 2 -- src/it/projects/purge-local-repository/setup.bsh | 2 -- src/it/projects/purge-local-repository/verify.groovy | 1 - src/it/projects/unpack-cli/verify.bsh | 4 ---- src/it/projects/unpack-dependencies/verify.groovy | 4 ++-- src/it/projects/unpack-from-remote-repository/verify.bsh | 1 - src/it/projects/unpack/verify.bsh | 4 ---- 27 files changed, 3 insertions(+), 55 deletions(-) diff --git a/src/it/projects/copy-and-unpack-with-alternate-local-repo/verify.bsh b/src/it/projects/copy-and-unpack-with-alternate-local-repo/verify.bsh index e4046ae62..9bfa43941 100644 --- a/src/it/projects/copy-and-unpack-with-alternate-local-repo/verify.bsh +++ b/src/it/projects/copy-and-unpack-with-alternate-local-repo/verify.bsh @@ -22,21 +22,18 @@ import java.io.*; File file = new File( basedir, "target/dependency/junit-3.8.1.jar" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing " + file ); } file = new File( basedir, "target/dependency/junit" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); } file = new File( basedir, "target/repo/junit/junit/3.8.1/junit-3.8.1.jar" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing " + file ); diff --git a/src/it/projects/copy-cli/verify.bsh b/src/it/projects/copy-cli/verify.bsh index 93fad1551..da93772de 100644 --- a/src/it/projects/copy-cli/verify.bsh +++ b/src/it/projects/copy-cli/verify.bsh @@ -28,7 +28,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( libDir, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/copy-dependencies/verify.bsh b/src/it/projects/copy-dependencies/verify.bsh index 80031daf5..7a3ce8606 100644 --- a/src/it/projects/copy-dependencies/verify.bsh +++ b/src/it/projects/copy-dependencies/verify.bsh @@ -24,7 +24,6 @@ void checkExpected( File dir, String[] expectedFiles ) for ( String expectedFile : expectedFiles ) { File file = new File( dir, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); @@ -39,7 +38,6 @@ void checkExpected( File dir, String[] expectedFiles, String[] unexpectedFiles ) for ( String unexpectedFile : unexpectedFiles ) { File file = new File( dir, unexpectedFile ); - System.out.println( "Checking for inexistence of " + file ); if ( file.isFile() ) { throw new Exception( "Unexpected file " + file + " found" ); diff --git a/src/it/projects/copy-from-reactor/verify.bsh b/src/it/projects/copy-from-reactor/verify.bsh index d4c63a651..9367fb019 100644 --- a/src/it/projects/copy-from-reactor/verify.bsh +++ b/src/it/projects/copy-from-reactor/verify.bsh @@ -28,7 +28,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( libDir, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/copy-from-remote-repository/verify.bsh b/src/it/projects/copy-from-remote-repository/verify.bsh index 1e390870f..6edc839fd 100644 --- a/src/it/projects/copy-from-remote-repository/verify.bsh +++ b/src/it/projects/copy-from-remote-repository/verify.bsh @@ -26,7 +26,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/copy-with-prependGroupId/verify.bsh b/src/it/projects/copy-with-prependGroupId/verify.bsh index 8018ef236..38018ab5d 100644 --- a/src/it/projects/copy-with-prependGroupId/verify.bsh +++ b/src/it/projects/copy-with-prependGroupId/verify.bsh @@ -28,7 +28,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( libDir, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/copy/verify.bsh b/src/it/projects/copy/verify.bsh index 93fad1551..da93772de 100644 --- a/src/it/projects/copy/verify.bsh +++ b/src/it/projects/copy/verify.bsh @@ -28,7 +28,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( libDir, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/get-artifact-maven-plugin/verify.bsh b/src/it/projects/get-artifact-maven-plugin/verify.bsh index 2f8cad07a..e75bdf475 100644 --- a/src/it/projects/get-artifact-maven-plugin/verify.bsh +++ b/src/it/projects/get-artifact-maven-plugin/verify.bsh @@ -27,7 +27,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/get-artifact-no-transitive/verify.bsh b/src/it/projects/get-artifact-no-transitive/verify.bsh index dfa7d2981..3c53da8d7 100644 --- a/src/it/projects/get-artifact-no-transitive/verify.bsh +++ b/src/it/projects/get-artifact-no-transitive/verify.bsh @@ -27,7 +27,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); @@ -42,7 +41,6 @@ String[] notExpectedFiles = { for ( String notExpectedFile : notExpectedFiles ) { File file = new File( localRepositoryPath, notExpectedFile ); - System.out.println( "Checking for absence of " + file ); if ( file.isFile() ) { throw new Exception( "Existing file " + file ); diff --git a/src/it/projects/get-artifact/verify.bsh b/src/it/projects/get-artifact/verify.bsh index a586d5653..25120f4fb 100644 --- a/src/it/projects/get-artifact/verify.bsh +++ b/src/it/projects/get-artifact/verify.bsh @@ -29,7 +29,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/get-gav/verify.bsh b/src/it/projects/get-gav/verify.bsh index a586d5653..25120f4fb 100644 --- a/src/it/projects/get-gav/verify.bsh +++ b/src/it/projects/get-gav/verify.bsh @@ -29,7 +29,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/purge-local-repository-bad-pom/verify.bsh b/src/it/projects/purge-local-repository-bad-pom/verify.bsh index 45b5cc9a6..0ecebd67a 100644 --- a/src/it/projects/purge-local-repository-bad-pom/verify.bsh +++ b/src/it/projects/purge-local-repository-bad-pom/verify.bsh @@ -19,8 +19,6 @@ import java.io.*; -System.out.println( "Checking for presence of purged dependency directories" ); - File depJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); if ( !depJar.exists() ) diff --git a/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh b/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh index 27051f6c3..f55d12dd2 100644 --- a/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh +++ b/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh @@ -25,8 +25,6 @@ void createJar( String artifactId ) purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); - - System.out.println( "Created dummy JAR " + purgedJar ); } createJar( "purged-a" ); diff --git a/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh b/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh index fde1a2bf7..c5f00b8a1 100644 --- a/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh +++ b/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh @@ -22,9 +22,7 @@ import java.io.File; void checkFilePurged( String artifactId ) { File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/" + artifactId + "/1.0/" + artifactId + "-1.0.jar" ); - - System.out.println( "Checking for absence of dummy JAR " + purgedJar ); - + if ( purgedJar.exists() ) { throw new Exception( "JAR was not purged: " + purgedJar ); diff --git a/src/it/projects/purge-local-repository-multi-module/setup.bsh b/src/it/projects/purge-local-repository-multi-module/setup.bsh index 27051f6c3..f55d12dd2 100644 --- a/src/it/projects/purge-local-repository-multi-module/setup.bsh +++ b/src/it/projects/purge-local-repository-multi-module/setup.bsh @@ -25,8 +25,6 @@ void createJar( String artifactId ) purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); - - System.out.println( "Created dummy JAR " + purgedJar ); } createJar( "purged-a" ); diff --git a/src/it/projects/purge-local-repository-non-transitive/verify.bsh b/src/it/projects/purge-local-repository-non-transitive/verify.bsh index e913c82ad..2766ec78a 100644 --- a/src/it/projects/purge-local-repository-non-transitive/verify.bsh +++ b/src/it/projects/purge-local-repository-non-transitive/verify.bsh @@ -21,8 +21,6 @@ import java.io.*; File depDir = new File( localRepositoryPath, "org/apache/maven/its/dependency/purge-local-repository/1.0" ); -System.out.println( "Checking for absence of purged dependency directory " + depDir ); - if ( depDir.exists() ) { throw new Exception( "Directory was not deleted: " + depDir ); diff --git a/src/it/projects/purge-local-repository-reresolve/verify.bsh b/src/it/projects/purge-local-repository-reresolve/verify.bsh index 45b5cc9a6..0ecebd67a 100644 --- a/src/it/projects/purge-local-repository-reresolve/verify.bsh +++ b/src/it/projects/purge-local-repository-reresolve/verify.bsh @@ -19,8 +19,6 @@ import java.io.*; -System.out.println( "Checking for presence of purged dependency directories" ); - File depJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); if ( !depJar.exists() ) diff --git a/src/it/projects/purge-local-repository-snapshots-only/setup.bsh b/src/it/projects/purge-local-repository-snapshots-only/setup.bsh index 00eacb5dc..4552c8f9e 100644 --- a/src/it/projects/purge-local-repository-snapshots-only/setup.bsh +++ b/src/it/projects/purge-local-repository-snapshots-only/setup.bsh @@ -24,14 +24,9 @@ File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); -System.out.println( "Created dummy JAR " + purgedJar ); - purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/snap-purged/1.0-SNAPSHOT/snap-purged-1.0-SNAPSHOT.jar" ); purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); -System.out.println( "Created dummy JAR " + purgedJar ); - - return true; diff --git a/src/it/projects/purge-local-repository-snapshots-only/verify.bsh b/src/it/projects/purge-local-repository-snapshots-only/verify.bsh index 60d0c7f6e..fad0644da 100644 --- a/src/it/projects/purge-local-repository-snapshots-only/verify.bsh +++ b/src/it/projects/purge-local-repository-snapshots-only/verify.bsh @@ -21,8 +21,6 @@ import java.io.*; File nonPurgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); -System.out.println( "Checking for presence of dummy JAR " + nonPurgedJar ); - if ( !nonPurgedJar.exists() ) { throw new Exception( "JAR was purged: " + nonPurgedJar ); @@ -31,8 +29,6 @@ if ( !nonPurgedJar.exists() ) File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/snap-purged/1.0-SNAPSHOT/snap-purged-1.0-SNAPSHOT.jar" ); -System.out.println( "Checking for absence of dummy JAR " + purgedJar ); - if ( purgedJar.exists() ) { throw new Exception( "JAR was not purged: " + purgedJar ); diff --git a/src/it/projects/purge-local-repository-version-range/verify.bsh b/src/it/projects/purge-local-repository-version-range/verify.bsh index 45b5cc9a6..0ecebd67a 100644 --- a/src/it/projects/purge-local-repository-version-range/verify.bsh +++ b/src/it/projects/purge-local-repository-version-range/verify.bsh @@ -19,8 +19,6 @@ import java.io.*; -System.out.println( "Checking for presence of purged dependency directories" ); - File depJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); if ( !depJar.exists() ) diff --git a/src/it/projects/purge-local-repository-without-pom/setup.bsh b/src/it/projects/purge-local-repository-without-pom/setup.bsh index 026446997..dba9cfb39 100644 --- a/src/it/projects/purge-local-repository-without-pom/setup.bsh +++ b/src/it/projects/purge-local-repository-without-pom/setup.bsh @@ -24,6 +24,4 @@ File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); -System.out.println( "Created dummy JAR " + purgedJar ); - return true; diff --git a/src/it/projects/purge-local-repository/setup.bsh b/src/it/projects/purge-local-repository/setup.bsh index cfb579166..92b835d1a 100644 --- a/src/it/projects/purge-local-repository/setup.bsh +++ b/src/it/projects/purge-local-repository/setup.bsh @@ -24,6 +24,4 @@ File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency purgedJar.getParentFile().mkdirs(); purgedJar.createNewFile(); -System.out.println( "Created dummy JAR " + purgedJar ); - return true; diff --git a/src/it/projects/purge-local-repository/verify.groovy b/src/it/projects/purge-local-repository/verify.groovy index 1ee8ed0de..7c97d11a0 100644 --- a/src/it/projects/purge-local-repository/verify.groovy +++ b/src/it/projects/purge-local-repository/verify.groovy @@ -20,7 +20,6 @@ void checkFileAbsence( String path ) { File depJar = new File( localRepositoryPath, path ) - System.out.println( "Checking for absence of dummy JAR " + depJar ) if ( depJar.exists() ) { throw new Exception( "Dependency jar was not purged: " + depJar ) diff --git a/src/it/projects/unpack-cli/verify.bsh b/src/it/projects/unpack-cli/verify.bsh index fc16bb2f9..4b93d0726 100644 --- a/src/it/projects/unpack-cli/verify.bsh +++ b/src/it/projects/unpack-cli/verify.bsh @@ -21,21 +21,18 @@ import java.io.*; File file = new File( basedir, "target/output spaces directory" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); } file = new File( file, "qdox-1.5" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); } file = new File( file, "build.xml" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing " + file ); @@ -43,7 +40,6 @@ if ( !file.isFile() ) //until MDEP-242 is fixed, the next test will passed file = new File( file.getParent(), "src" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); diff --git a/src/it/projects/unpack-dependencies/verify.groovy b/src/it/projects/unpack-dependencies/verify.groovy index dcd8104ba..70757222c 100644 --- a/src/it/projects/unpack-dependencies/verify.groovy +++ b/src/it/projects/unpack-dependencies/verify.groovy @@ -24,7 +24,7 @@ for (item in expected) def file = new File(basedir, 'target/dependency/' + item) if (!file.exists()) { - throw new RuntimeException("Missing "+file.name) + throw new RuntimeException("Missing " + file.name) } } @@ -35,7 +35,7 @@ for (item in notExpected) def file = new File(basedir, 'target/dependency/' + item) if (file.exists()) { - throw new RuntimeException("This file shouldn't be here: "+file.name) + throw new RuntimeException("This file shouldn't be here: " + file.name) } } diff --git a/src/it/projects/unpack-from-remote-repository/verify.bsh b/src/it/projects/unpack-from-remote-repository/verify.bsh index 23f034522..3e4efdfed 100644 --- a/src/it/projects/unpack-from-remote-repository/verify.bsh +++ b/src/it/projects/unpack-from-remote-repository/verify.bsh @@ -26,7 +26,6 @@ String[] expectedFiles = { for ( String expectedFile : expectedFiles ) { File file = new File( localRepositoryPath, expectedFile ); - System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing file " + file ); diff --git a/src/it/projects/unpack/verify.bsh b/src/it/projects/unpack/verify.bsh index fc16bb2f9..4b93d0726 100644 --- a/src/it/projects/unpack/verify.bsh +++ b/src/it/projects/unpack/verify.bsh @@ -21,21 +21,18 @@ import java.io.*; File file = new File( basedir, "target/output spaces directory" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); } file = new File( file, "qdox-1.5" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); } file = new File( file, "build.xml" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isFile() ) { throw new Exception( "Missing " + file ); @@ -43,7 +40,6 @@ if ( !file.isFile() ) //until MDEP-242 is fixed, the next test will passed file = new File( file.getParent(), "src" ); -System.out.println( "Checking for existence of " + file ); if ( !file.isDirectory() ) { throw new Exception( "Missing " + file ); From a9dd079a70d3aeb5229f90b3287863e26209a55f Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 21:59:10 +0000 Subject: [PATCH 189/283] @Component --> @Inject for DisplayAncestorsMojo (#474) --- .../plugins/dependency/DisplayAncestorsMojo.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java index 4a52c0150..06f7f5a1b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/DisplayAncestorsMojo.java @@ -18,13 +18,14 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.util.ArrayList; import java.util.List; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; @@ -39,12 +40,13 @@ @Mojo(name = "display-ancestors", threadSafe = true, requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE) public class DisplayAncestorsMojo extends AbstractMojo { - /** - * POM - */ - @Component private MavenProject project; + @Inject + public DisplayAncestorsMojo(MavenProject project) { + this.project = project; + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { final List ancestors = collectAncestors(); From f51ec18ffabdb2f9258559dd71d453a6f0c8fd05 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 22:02:21 +0000 Subject: [PATCH 190/283] [MDEP-952] Rollback bad commit (#469) * Rollback bad commit --- pom.xml | 6 ++++ .../maven/plugins/dependency/GetMojo.java | 7 ++-- .../analyze/AbstractAnalyzeMojo.java | 6 ++-- .../dependency/analyze/AnalyzeDepMgt.java | 7 ++-- .../AbstractFromConfigurationMojo.java | 17 +++++----- .../fromConfiguration/UnpackMojo.java | 2 +- .../fromDependencies/BuildClasspathMojo.java | 3 +- .../dependency/utils/DependencyUtil.java | 7 ++-- .../plugins/dependency/utils/StringUtils.java | 33 ------------------- .../utils/filters/DestFileFilter.java | 6 ++-- .../markers/UnpackFileMarkerHandler.java | 2 +- .../TestCopyDependenciesMojo2.java | 3 +- .../stubs/StubUnpackFileMarkerHandler.java | 2 +- 13 files changed, 35 insertions(+), 66 deletions(-) delete mode 100644 src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java diff --git a/pom.xml b/pom.xml index 5cdf2565d..b901e38d4 100644 --- a/pom.xml +++ b/pom.xml @@ -246,6 +246,12 @@ under the License. 3.4.2 + + org.apache.commons + commons-lang3 + 3.13.0 + + org.apache.maven.plugin-tools diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 73b3eb312..61fb05fd7 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -24,6 +24,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -37,7 +38,6 @@ 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.plugins.dependency.utils.StringUtils; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; @@ -130,7 +130,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0"); } if (artifact != null) { - String[] tokens = artifact.split("\\s*:+\\s*"); + String[] tokens = StringUtils.split(artifact, ":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, you must specify " + "groupId:artifactId:version[:packaging[:classifier]] " + artifact); @@ -157,7 +157,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (remoteRepositories != null) { // Use the same format as in the deploy plugin id::layout::url - String[] repos = remoteRepositories.split("\\s*,+\\s*"); + String[] repos = StringUtils.split(remoteRepositories, ","); for (String repo : repos) { repoList.add(parseRepository(repo, always)); } @@ -214,7 +214,6 @@ ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) } id = matcher.group(1).trim(); - if (!StringUtils.isEmpty(matcher.group(2))) { layout = getLayout(matcher.group(2).trim()); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index ebff3dcea..1d5d2553d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.plugin.AbstractMojo; @@ -36,7 +37,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; @@ -512,9 +512,9 @@ private void writeDependencyXML(Set artifacts) { writer.startElement("version"); writer.writeText(artifact.getBaseVersion()); String classifier = artifact.getClassifier(); - if (!StringUtils.isEmpty(classifier)) { + if (StringUtils.isNotBlank(classifier)) { writer.startElement("classifier"); - writer.writeText(classifier); + writer.writeText(artifact.getClassifier()); writer.endElement(); } writer.endElement(); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index b118183e2..a96b4f041 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -143,8 +144,7 @@ private boolean checkDependencyManagement() throws MojoExecutionException { // log exclusion errors List exclusionErrors = getExclusionErrors(exclusions, allDependencyArtifacts); for (Artifact exclusion : exclusionErrors) { - String artifactManagementKey = getArtifactManagementKey(exclusion); - getLog().info(artifactManagementKey.substring(artifactManagementKey.lastIndexOf(":")) + getLog().info(StringUtils.stripEnd(getArtifactManagementKey(exclusion), ":") + " was excluded in DepMgt, but version " + exclusion.getVersion() + " has been found in the dependency tree."); foundError = true; @@ -247,8 +247,7 @@ public void logMismatch(Artifact dependencyArtifact, Dependency dependencyFromDe "Invalid params: Artifact: " + dependencyArtifact + " Dependency: " + dependencyFromDepMgt); } - String managementKey = dependencyFromDepMgt.getManagementKey(); - getLog().info("\tDependency: " + managementKey.substring(managementKey.lastIndexOf(":"))); + getLog().info("\tDependency: " + StringUtils.stripEnd(dependencyFromDepMgt.getManagementKey(), ":")); getLog().info("\t\tDepMgt : " + dependencyFromDepMgt.getVersion()); getLog().info("\t\tResolved: " + dependencyArtifact.getBaseVersion()); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 7fbedc4ad..770f86c22 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -33,7 +34,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; -import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; @@ -145,12 +145,13 @@ protected void verifyRequirements() throws MojoFailureException { protected List getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) throws MojoExecutionException { - boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(); - boolean prependGroupId = processArtifactItemsRequest.isPrependGroupId(); - boolean useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); + boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(), + prependGroupId = processArtifactItemsRequest.isPrependGroupId(), + useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); + boolean removeClassifier = processArtifactItemsRequest.isRemoveClassifier(); - if (artifactItems == null || artifactItems.isEmpty()) { + if (artifactItems == null || artifactItems.size() < 1) { throw new MojoExecutionException("There are no artifactItems configured."); } @@ -183,8 +184,8 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque return artifactItems; } - private boolean checkIfProcessingNeeded(ArtifactItem item) throws ArtifactFilterException { - return Boolean.parseBoolean(item.getOverWrite()) + private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException, ArtifactFilterException { + return StringUtils.equalsIgnoreCase(item.getOverWrite(), "true") || getMarkedArtifactFilter(item).isArtifactIncluded(item); } @@ -366,7 +367,7 @@ public void setArtifact(String artifact) throws MojoFailureException { if (artifact != null) { String packaging = "jar"; String classifier; - String[] tokens = artifact.split(":"); + String[] tokens = StringUtils.split(artifact, ":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, " + "you must specify groupId:artifactId:version[:packaging[:classifier]] " + artifact); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 60c4f2972..979ed507a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -21,13 +21,13 @@ import java.io.File; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 5604ece9e..5d689e1f8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; @@ -266,7 +267,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); File localBasedir = repositoryManager.getLocalRepositoryBasedir(projectBuildingRequest); - file = file.replace(localBasedir.getAbsolutePath(), localRepoProperty); + file = StringUtils.replace(file, localBasedir.getAbsolutePath(), localRepoProperty); } sb.append(file); } else { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index bdccfee92..6dad61eb4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -29,6 +29,7 @@ import java.nio.file.StandardOpenOption; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.logging.Log; @@ -265,11 +266,7 @@ public static synchronized void log(String string, Log log) throws IOException { * @return the result items */ public static String[] tokenizer(String str) { - String s = cleanToBeTokenizedString(str); - if (s.isEmpty()) { - return new String[0]; - } - return cleanToBeTokenizedString(str).split(","); + return StringUtils.split(cleanToBeTokenizedString(str), ","); } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java b/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java deleted file mode 100644 index e238a6692..000000000 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/StringUtils.java +++ /dev/null @@ -1,33 +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.dependency.utils; - -import static java.util.Objects.isNull; - -public final class StringUtils { - private StringUtils() {} - - public static boolean isEmpty(String s) { - return isNull(s) || s.isEmpty(); - } - - public static boolean isNotEmpty(String s) { - return !isEmpty(s); - } -} diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 46909a98f..be52f1f5d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -24,14 +24,13 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; -import static org.apache.maven.plugins.dependency.utils.StringUtils.isEmpty; - /** * @author Brian Fox */ @@ -285,8 +284,7 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept } File destFile; - - if (isEmpty(item.getDestFileName())) { + if (StringUtils.isEmpty(item.getDestFileName())) { String formattedFileName = DependencyUtil.getFormattedFileName( artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier); destFile = new File(destFolder, formattedFileName); diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 95684a3c4..00c7be06e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -20,8 +20,8 @@ import java.io.File; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; -import org.apache.maven.plugins.dependency.utils.StringUtils; /** * @author Damian Bradicich diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index f3a1f8b4f..aaf076858 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -282,7 +283,7 @@ private Artifact createExpandedVersionArtifact( snapshot.setBuildNumber(1); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata(expandedSnapshot, snapshot); String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - expandedSnapshot.setResolvedVersion(baseVersion.replace(Artifact.SNAPSHOT_VERSION, newVersion)); + expandedSnapshot.setResolvedVersion(StringUtils.replace(baseVersion, Artifact.SNAPSHOT_VERSION, newVersion)); expandedSnapshot.addMetadata(metadata); return expandedSnapshot; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java index 9262470da..411aa048e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java @@ -20,8 +20,8 @@ import java.io.File; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; -import org.apache.maven.plugins.dependency.utils.StringUtils; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; public class StubUnpackFileMarkerHandler extends UnpackFileMarkerHandler { From 4eca443b3b10197554d3c5f1c58b8abc832c57eb Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 22:03:03 +0000 Subject: [PATCH 191/283] Stop setting deprecated dependency artifacts (#457) * Stop using deprecated dependency artifacts --- .../dependency/TestPropertiesMojo.java | 2 -- .../TestCopyDependenciesMojo.java | 32 +++++++------------ .../TestCopyDependenciesMojo2.java | 13 -------- .../TestUnpackDependenciesMojo.java | 23 +------------ .../TestUnpackDependenciesMojo2.java | 6 ---- .../plugins/dependency/tree/TestTreeMojo.java | 1 - 6 files changed, 13 insertions(+), 64 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java index ede675d2d..75ae7cab0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java @@ -56,9 +56,7 @@ public void testSetProperties() throws Exception { artifacts.addAll(directArtifacts); project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); - // this.assertNull( project.getProperties().getProperty( "org.apacha ) ) mojo.execute(); for (Artifact artifact : artifacts) { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index 91ebbd46e..ff2d42619 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -74,7 +74,6 @@ protected void setUp() throws Exception { artifacts.addAll(directArtifacts); project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); mojo.markersDirectory = new File(this.testDir, "markers"); ArtifactHandlerManager manager = lookup(ArtifactHandlerManager.class); @@ -160,7 +159,7 @@ public void testNoTransitive() throws Exception { mojo.excludeTransitive = true; mojo.execute(); - Set artifacts = mojo.getProject().getDependencyArtifacts(); + Set artifacts = mojo.getProject().getArtifacts(); for (Artifact artifact : artifacts) { String fileName = DependencyUtil.getFormattedFileName(artifact, false); File file = new File(mojo.outputDirectory, fileName); @@ -170,7 +169,7 @@ public void testNoTransitive() throws Exception { public void testExcludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeTypes = "jar"; mojo.execute(); @@ -184,7 +183,6 @@ public void testExcludeType() throws Exception { public void testIncludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -212,7 +210,6 @@ public void testIncludeType() throws Exception { public void testExcludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeArtifactIds = "one"; mojo.execute(); @@ -226,7 +223,6 @@ public void testExcludeArtifactId() throws Exception { public void testIncludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; @@ -254,7 +250,7 @@ public void testIncludeArtifactId() throws Exception { public void testIncludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; // shouldn't get anything @@ -281,7 +277,7 @@ public void testIncludeGroupId() throws Exception { public void testExcludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeGroupIds = "one"; mojo.execute(); @@ -296,7 +292,7 @@ public void testExcludeGroupId() throws Exception { public void testExcludeMultipleGroupIds() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeGroupIds = "one,two"; mojo.execute(); @@ -312,7 +308,7 @@ public void testExcludeMultipleGroupIds() throws Exception { public void testExcludeClassifier() throws Exception { mojo.getProject().setArtifacts(stubFactory.getClassifiedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeClassifiers = "one"; mojo.execute(); @@ -326,7 +322,6 @@ public void testExcludeClassifier() throws Exception { public void testIncludeClassifier() throws Exception { mojo.getProject().setArtifacts(stubFactory.getClassifiedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeClassifiers = "one"; mojo.excludeClassifiers = "one"; @@ -354,7 +349,7 @@ public void testIncludeClassifier() throws Exception { public void testSubPerType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -455,7 +450,6 @@ public void testDontOverWriteRelease() artifacts.add(release); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteIfNewer = false; @@ -486,7 +480,6 @@ public void testOverWriteRelease() throws MojoExecutionException, IOException, M artifacts.add(release); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = true; mojo.overWriteIfNewer = false; @@ -514,7 +507,6 @@ public void testDontOverWriteSnap() throws MojoExecutionException, IOException, artifacts.add(snap); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = false; mojo.overWriteSnapshots = false; @@ -569,7 +561,7 @@ public void testGetDependencies() throws MojoExecutionException { public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeScope = "provided"; mojo.execute(); @@ -586,7 +578,7 @@ public void testExcludeProvidedScope() throws Exception { public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeScope = "system"; mojo.execute(); @@ -603,7 +595,7 @@ public void testExcludeSystemScope() throws Exception { public void testExcludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -619,7 +611,7 @@ public void testExcludeCompileScope() throws Exception { public void testExcludeTestScope() throws IOException, MojoFailureException { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeScope = "test"; try { @@ -632,7 +624,7 @@ public void testExcludeTestScope() throws IOException, MojoFailureException { public void testExcludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); + mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index aaf076858..f46370d28 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -24,7 +24,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; -import java.util.HashSet; import java.util.Set; import org.apache.commons.lang3.StringUtils; @@ -79,7 +78,6 @@ protected void setUp() throws Exception { artifacts.addAll(directArtifacts); project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); mojo.markersDirectory = new File(this.testDir, "markers"); LegacySupport legacySupport = lookup(LegacySupport.class); @@ -89,7 +87,6 @@ protected void setUp() throws Exception { public void testCopyDependenciesMojoIncludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "compile"; mojo.execute(); @@ -107,7 +104,6 @@ public void testCopyDependenciesMojoIncludeCompileScope() throws Exception { public void testCopyDependenciesMojoIncludeTestScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "test"; mojo.execute(); @@ -125,7 +121,6 @@ public void testCopyDependenciesMojoIncludeTestScope() throws Exception { public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "runtime"; mojo.execute(); @@ -143,7 +138,6 @@ public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception { public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "provided"; mojo.execute(); @@ -159,7 +153,6 @@ public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception { public void testCopyDependenciesMojoIncludesystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "system"; mojo.execute(); @@ -190,7 +183,6 @@ public void testSubPerArtifact() throws Exception { public void testSubPerArtifactAndType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; @@ -208,7 +200,6 @@ public void testSubPerArtifactAndType() throws Exception { public void testSubPerArtifactAndScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerScope = true; @@ -233,12 +224,10 @@ public void testRepositoryLayout() throws Exception { createExpandedVersionArtifact(baseVersion, groupId, artifactId, "compile", "jar", null); mojo.getProject().getArtifacts().add(expandedSnapshot); - mojo.getProject().getDependencyArtifacts().add(expandedSnapshot); Artifact pomExpandedSnapshot = createExpandedVersionArtifact(baseVersion, groupId, artifactId, "compile", "pom", null); mojo.getProject().getArtifacts().add(pomExpandedSnapshot); - mojo.getProject().getDependencyArtifacts().add(pomExpandedSnapshot); mojo.useRepositoryLayout = true; mojo.execute(); @@ -329,7 +318,6 @@ public void testSubPerArtifactRemoveVersion() throws Exception { public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; @@ -364,7 +352,6 @@ public void testSubPerArtifactRemoveType() throws Exception { public void testSubPerArtifactAndTypeRemoveType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripType = true; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index ef795a2e7..9c913e2ae 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.IOException; -import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -86,7 +85,6 @@ protected void setUp() throws Exception { artifacts.addAll(directArtifacts); project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); mojo.markersDirectory = new File(this.testDir, "markers"); ArtifactHandlerManager manager = lookup(ArtifactHandlerManager.class); @@ -140,14 +138,13 @@ public void testMojo() throws Exception { public void testNoTransitive() throws Exception { mojo.excludeTransitive = true; mojo.execute(); - for (Artifact artifact : mojo.getProject().getDependencyArtifacts()) { + for (Artifact artifact : mojo.getProject().getArtifacts()) { assertUnpacked(artifact); } } public void testExcludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeTypes = "jar"; mojo.execute(); @@ -158,7 +155,6 @@ public void testExcludeType() throws Exception { public void testExcludeProvidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "provided"; mojo.execute(); @@ -170,7 +166,6 @@ public void testExcludeProvidedScope() throws Exception { public void testExcludeSystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "system"; mojo.execute(); @@ -182,7 +177,6 @@ public void testExcludeSystemScope() throws Exception { public void testExcludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -194,7 +188,6 @@ public void testExcludeCompileScope() throws Exception { public void testExcludeTestScope() throws IOException, MojoFailureException { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "test"; try { @@ -207,7 +200,6 @@ public void testExcludeTestScope() throws IOException, MojoFailureException { public void testExcludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope); @@ -219,7 +211,6 @@ public void testExcludeRuntimeScope() throws Exception { public void testIncludeType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -247,7 +238,6 @@ public void testIncludeType() throws Exception { public void testSubPerType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -267,7 +257,6 @@ public void testSubPerArtifact() throws Exception { public void testSubPerArtifactAndType() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.execute(); @@ -289,7 +278,6 @@ public void testSubPerArtifactRemoveVersion() throws Exception { public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { mojo.getProject().setArtifacts(stubFactory.getTypedArchiveArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; @@ -302,7 +290,6 @@ public void testSubPerArtifactAndTypeRemoveVersion() throws Exception { public void testIncludeCompileScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); @@ -314,7 +301,6 @@ public void testIncludeCompileScope() throws Exception { public void testIncludeTestScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "test"; mojo.execute(); @@ -327,7 +313,6 @@ public void testIncludeTestScope() throws Exception { public void testIncludeRuntimeScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope); @@ -339,7 +324,6 @@ public void testIncludeRuntimeScope() throws Exception { public void testIncludeprovidedScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "provided"; mojo.execute(); @@ -350,7 +334,6 @@ public void testIncludeprovidedScope() throws Exception { public void testIncludesystemScope() throws Exception { mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeScope = "system"; mojo.execute(); @@ -362,7 +345,6 @@ public void testIncludesystemScope() throws Exception { public void testIncludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; @@ -386,7 +368,6 @@ public void testIncludeArtifactId() throws Exception { public void testExcludeArtifactId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getArtifactArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeArtifactIds = "one"; mojo.execute(); @@ -400,7 +381,6 @@ public void testExcludeArtifactId() throws Exception { public void testExcludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.excludeGroupIds = "one"; mojo.execute(); @@ -411,7 +391,6 @@ public void testExcludeGroupId() throws Exception { public void testIncludeGroupId() throws Exception { mojo.getProject().setArtifacts(stubFactory.getGroupIdArtifacts()); - mojo.getProject().setDependencyArtifacts(new HashSet<>()); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; // shouldn't get anything diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index cba5392fb..27e43c9fc 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -70,7 +70,6 @@ protected void setUp() throws Exception { artifacts.addAll(directArtifacts); project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); mojo.markersDirectory = new File(this.testDir, "markers"); } @@ -106,7 +105,6 @@ public void testDontOverWriteRelease() artifacts.add(release); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteIfNewer = false; @@ -125,7 +123,6 @@ public void testOverWriteRelease() artifacts.add(release); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = true; mojo.overWriteIfNewer = false; @@ -145,7 +142,6 @@ public void testDontOverWriteSnap() artifacts.add(snap); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = false; mojo.overWriteSnapshots = false; @@ -166,7 +162,6 @@ public void testOverWriteSnap() artifacts.add(snap); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = false; mojo.overWriteSnapshots = true; @@ -187,7 +182,6 @@ public void testOverWriteIfNewer() artifacts.add(snap); mojo.getProject().setArtifacts(artifacts); - mojo.getProject().setDependencyArtifacts(artifacts); mojo.overWriteReleases = false; mojo.overWriteSnapshots = false; diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index edbceb879..ad096f036 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -111,7 +111,6 @@ public void testTreeTestEnvironment() throws Exception { Arrays.asList("testGroupId:release:jar:1.0:compile", "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile"); assertTrue(expectedNodes.containsAll(actualNodes)); - ; } /** From 1011ebe9acfe755dd8a9d1ec95740235ea1c19fc Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 22:53:27 +0000 Subject: [PATCH 192/283] [MDEP-966] Migrate AnalyzeDepMgt to Sisu (#473) * Migrate AnalyzeDepMgt to Sisu --- pom.xml | 7 ++++ .../dependency/analyze/AnalyzeDepMgt.java | 41 ++++++++----------- .../dependency/analyze/TestAnalyzeDepMgt.java | 11 ++--- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index b901e38d4..f72428a26 100644 --- a/pom.xml +++ b/pom.xml @@ -146,6 +146,13 @@ under the License. provided + + org.eclipse.sisu + org.eclipse.sisu.plexus + 0.9.0.M3 + provided + + org.apache.maven.doxia diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index a96b4f041..9cb79ece6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.analyze; +import javax.inject.Inject; + import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashSet; @@ -34,7 +36,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.plugins.annotations.ResolutionScope; @@ -52,10 +53,6 @@ public class AnalyzeDepMgt extends AbstractMojo { // fields ----------------------------------------------------------------- - /** - * - */ - @Component private MavenProject project; /** @@ -78,6 +75,11 @@ public class AnalyzeDepMgt extends AbstractMojo { @Parameter(property = "mdep.analyze.skip", defaultValue = "false") private boolean skip; + @Inject + public AnalyzeDepMgt(MavenProject project) { + this.project = project; + } + // Mojo methods ----------------------------------------------------------- /* @@ -104,7 +106,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { /** * Does the work of checking the DependencyManagement Section. * - * @return true if errors are found. + * @return true if errors are found * @throws MojoExecutionException */ private boolean checkDependencyManagement() throws MojoExecutionException { @@ -169,8 +171,8 @@ private boolean checkDependencyManagement() throws MojoExecutionException { /** * Returns a map of the exclusions using the Dependency ManagementKey as the keyset. * - * @param exclusionList to be added to the map. - * @return a map of the exclusions using the Dependency ManagementKey as the keyset. + * @param exclusionList to be added to the map + * @return a map of the exclusions using the Dependency ManagementKey as the keyset */ public Map addExclusions(List exclusionList) { if (exclusionList != null) { @@ -183,9 +185,9 @@ public Map addExclusions(List exclusionList) { * Returns a List of the artifacts that should have been excluded, but were found in the dependency tree. * * @param exclusions a map of the DependencyManagement exclusions, with the ManagementKey as the key and Dependency - * as the value. - * @param allDependencyArtifacts resolved artifacts to be compared. - * @return list of artifacts that should have been excluded. + * as the value + * @param allDependencyArtifacts resolved artifacts to be compared + * @return list of artifacts that should have been excluded */ public List getExclusionErrors(Map exclusions, Set allDependencyArtifacts) { return allDependencyArtifacts.stream() @@ -195,7 +197,7 @@ public List getExclusionErrors(Map exclusions, Set< /** * @param artifact {@link Artifact} - * @return The resulting GA. + * @return the resulting GA */ public String getExclusionKey(Artifact artifact) { return artifact.getGroupId() + ":" + artifact.getArtifactId(); @@ -203,7 +205,7 @@ public String getExclusionKey(Artifact artifact) { /** * @param ex The exclusion key. - * @return The resulting combination of groupId+artifactId. + * @return the resulting combination of groupId+artifactId */ public String getExclusionKey(Exclusion ex) { return ex.getGroupId() + ":" + ex.getArtifactId(); @@ -236,9 +238,9 @@ public Map getMismatch( * This function displays the log to the screen showing the versions and information about the artifacts that don't * match. * - * @param dependencyArtifact the artifact that was resolved. - * @param dependencyFromDepMgt the dependency listed in the DependencyManagement section. - * @throws MojoExecutionException in case of errors. + * @param dependencyArtifact the artifact that was resolved + * @param dependencyFromDepMgt the dependency listed in the DependencyManagement section + * @throws MojoExecutionException in case of errors */ public void logMismatch(Artifact dependencyArtifact, Dependency dependencyFromDepMgt) throws MojoExecutionException { @@ -284,13 +286,6 @@ protected final MavenProject getProject() { return this.project; } - /** - * @param theProject the project to set - */ - public void setProject(MavenProject theProject) { - this.project = theProject; - } - /** * @return the ignoreDirect */ diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java index 44e32cbbe..32c0919c6 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java @@ -49,23 +49,20 @@ public class TestAnalyzeDepMgt extends TestCase { Exclusion ex; - Artifact exclusionArtifact; - DependencyManagement depMgt; - DependencyManagement depMgtNoExclusions; - + @Override protected void setUp() throws Exception { - mojo = new AnalyzeDepMgt(); MavenProject project = new DependencyProjectStub(); + mojo = new AnalyzeDepMgt(project); stubFactory = new DependencyArtifactStubFactory(new File(""), false); Set allArtifacts = stubFactory.getMixedArtifacts(); Set directArtifacts = stubFactory.getClassifiedArtifacts(); - exclusionArtifact = stubFactory.getReleaseArtifact(); + Artifact exclusionArtifact = stubFactory.getReleaseArtifact(); directArtifacts.add(exclusionArtifact); ex = new Exclusion(); ex.setArtifactId(exclusionArtifact.getArtifactId()); @@ -87,8 +84,6 @@ protected void setUp() throws Exception { project.setArtifacts(allArtifacts); project.setDependencyArtifacts(directArtifacts); - - mojo.setProject(project); } public void testGetManagementKey() throws IOException { From e681d70c84b9fd803eb8c42f74502b891823449f Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 22:53:56 +0000 Subject: [PATCH 193/283] [MDEP-966] Add previously undeclared but used sisu dependency (#471) * Add previously undeclared but used sisu dependency --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index f72428a26..f23a6d61d 100644 --- a/pom.xml +++ b/pom.xml @@ -178,6 +178,11 @@ under the License. plexus-archiver ${plexus-archiver.version} + + org.eclipse.sisu + org.eclipse.sisu.plexus + provided + org.apache.commons From 41391f2db2db61ac758430efd72b909aa7aa0359 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 23:41:34 +0000 Subject: [PATCH 194/283] [MDEP-966] @Component to @Inject for ListClassesMojo and ListRepositoriesMojo (#475) * @Component to @Inject for ListClassesMojo * ListRepositoriesMojo * PropertiesMojo * AnalyzeReport * AnalyzeDuplicateMojo --- .../maven/plugins/dependency/ListClassesMojo.java | 9 +++++++-- .../plugins/dependency/ListRepositoriesMojo.java | 9 +++++++-- .../dependency/analyze/AnalyzeDuplicateMojo.java | 9 +++++++-- .../plugins/dependency/analyze/AnalyzeReport.java | 13 ++++++++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index 1cd29ba21..0f20be959 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.Enumeration; @@ -28,7 +30,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.plugins.dependency.utils.ParamArtifact; @@ -45,11 +46,15 @@ @Mojo(name = "list-classes", requiresProject = false, threadSafe = true) public class ListClassesMojo extends AbstractMojo { - @Component private ResolverUtil resolverUtil; private ParamArtifact paramArtifact = new ParamArtifact(); + @Inject + public ListClassesMojo(ResolverUtil resolverUtil) { + this.resolverUtil = resolverUtil; + } + /** * The group ID of the artifact to download. Ignored if {@code artifact} is used. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index d86c38653..5c3eb6116 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -31,7 +33,6 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.artifact.ArtifactTypeRegistry; @@ -53,9 +54,13 @@ @Mojo(name = "list-repositories", threadSafe = true) public class ListRepositoriesMojo extends AbstractDependencyMojo { - @Component private RepositorySystem repositorySystem; + @Inject + public ListRepositoriesMojo(RepositorySystem repositorySystem) { + this.repositorySystem = repositorySystem; + } + /** * Displays a list of the repositories used by this build. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index f5f6c6ea1..9ad7de2c6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.analyze; +import javax.inject.Inject; + import java.io.IOException; import java.io.Reader; import java.util.Collections; @@ -34,7 +36,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.project.MavenProject; @@ -66,9 +67,13 @@ public class AnalyzeDuplicateMojo extends AbstractMojo { /** * The Maven project to analyze. */ - @Component private MavenProject project; + @Inject + public AnalyzeDuplicateMojo(MavenProject project) { + this.project = project; + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java index 239bc825c..96ffe077c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java @@ -18,10 +18,11 @@ */ package org.apache.maven.plugins.dependency.analyze; +import javax.inject.Inject; + import java.util.Locale; import java.util.Set; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -48,7 +49,6 @@ public class AnalyzeReport extends AbstractMavenReport { /** * The Maven project dependency analyzer to use. */ - @Component private ProjectDependencyAnalyzer analyzer; /** @@ -87,9 +87,14 @@ public class AnalyzeReport extends AbstractMavenReport { /** * Internationalization component */ - @Component private I18N i18n; + @Inject + public AnalyzeReport(ProjectDependencyAnalyzer analyzer, I18N i18n) { + this.analyzer = analyzer; + this.i18n = i18n; + } + // Mojo methods ----------------------------------------------------------- /* @@ -142,11 +147,13 @@ public String getOutputName() { } /** {@inheritDoc} */ + @Override public String getName(Locale locale) { return getI18nString(locale, "name"); } /** {@inheritDoc} */ + @Override public String getDescription(Locale locale) { return getI18nString(locale, "description"); } From dd1b5b93da0d9b34db9831ad937fd510bbfe4a2d Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 18 Nov 2024 23:49:54 +0000 Subject: [PATCH 195/283] [MDEP-952] integration test (#477) * [MDEP-952] integration test --- .../invoker.properties | 18 +++++++++++++ .../pom.xml | 25 +++++++++++++++++ .../verify.groovy | 27 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/invoker.properties create mode 100644 src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/pom.xml create mode 100644 src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/verify.groovy diff --git a/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/invoker.properties b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/invoker.properties new file mode 100644 index 000000000..df09c584b --- /dev/null +++ b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:unpack -Dartifact=org.apache.commons:commons-lang3:3.17.0::jar -DoutputDirectory=. diff --git a/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/pom.xml b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/pom.xml new file mode 100644 index 000000000..6c3ae6a1e --- /dev/null +++ b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + com.mycompany.app + my-app + 1 + \ No newline at end of file diff --git a/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/verify.groovy b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/verify.groovy new file mode 100644 index 000000000..e5eae39a5 --- /dev/null +++ b/src/it/projects/mdep-952-unpack-fails-if-extension-of-artifact-is-used/verify.groovy @@ -0,0 +1,27 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ) +assert file.exists() + +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( 'BUILD SUCCESS' ) +assert !buildLog.contains( 'BUILD FAILURE' ) + +return true From 728a1c1c1be4c17659891dd546a18724aaa99fa6 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 11:32:32 +0000 Subject: [PATCH 196/283] Break dependency on commons-lang3 (#478) --- .../testUtils/stubs/StubUnpackFileMarkerHandler.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java index 411aa048e..cbb49f8f7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java +++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java @@ -20,7 +20,6 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; @@ -29,21 +28,22 @@ public StubUnpackFileMarkerHandler(ArtifactItem artifactItem, File markerFilesDi super(artifactItem, markerFilesDirectory); } + @Override protected File getMarkerFile() { File markerFile; if (this.artifactItem == null - || (StringUtils.isEmpty(this.artifactItem.getIncludes()) - && StringUtils.isEmpty(this.artifactItem.getExcludes()))) { + || this.artifactItem.getIncludes().isEmpty() + && this.artifactItem.getExcludes().isEmpty()) { markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace(':', '-') + ".marker"); } else { int includeExcludeHash = 0; - if (StringUtils.isNotEmpty(this.artifactItem.getIncludes())) { + if (!this.artifactItem.getIncludes().isEmpty()) { includeExcludeHash += this.artifactItem.getIncludes().hashCode(); } - if (StringUtils.isNotEmpty(this.artifactItem.getExcludes())) { + if (!this.artifactItem.getExcludes().isEmpty()) { includeExcludeHash += this.artifactItem.getExcludes().hashCode(); } From da6d4c7a41dadc15781792fe66ac0ec62558405e Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 12:34:18 +0000 Subject: [PATCH 197/283] Cut another dependency on commons-lang3 (#481) --- .../fromDependencies/TestCopyDependenciesMojo2.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index f46370d28..cb852a1ec 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -26,7 +26,6 @@ import java.util.Collection; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -53,6 +52,7 @@ public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { private CopyDependenciesMojo mojo; + @Override protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("copy-dependencies", true); @@ -272,7 +272,7 @@ private Artifact createExpandedVersionArtifact( snapshot.setBuildNumber(1); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata(expandedSnapshot, snapshot); String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - expandedSnapshot.setResolvedVersion(StringUtils.replace(baseVersion, Artifact.SNAPSHOT_VERSION, newVersion)); + expandedSnapshot.setResolvedVersion(baseVersion.replace(Artifact.SNAPSHOT_VERSION, newVersion)); expandedSnapshot.addMetadata(metadata); return expandedSnapshot; } From fb1ef15bfb7d16b33189f2d27ab46ddb2dbd3d39 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 12:34:51 +0000 Subject: [PATCH 198/283] Remove duplicate dependency definition (#482) * Remove duplicate dependency definition --- pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pom.xml b/pom.xml index f23a6d61d..a6491f101 100644 --- a/pom.xml +++ b/pom.xml @@ -188,7 +188,6 @@ under the License. org.apache.commons commons-lang3 3.17.0 - runtime commons-io @@ -258,12 +257,6 @@ under the License. 3.4.2 - - org.apache.commons - commons-lang3 - 3.13.0 - - org.apache.maven.plugin-tools From e2671baaca2b0132b35f7432264b108399096cec Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 12:35:34 +0000 Subject: [PATCH 199/283] [MDEP-952] Cut another dependency on commons-lang3 (#479) * Cut another dependency on commons-lang3 --- pom.xml | 2 +- .../java/org/apache/maven/plugins/dependency/GetMojo.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index a6491f101..5ed9255b6 100644 --- a/pom.xml +++ b/pom.xml @@ -183,7 +183,7 @@ under the License. org.eclipse.sisu.plexus provided - + org.apache.commons commons-lang3 diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 61fb05fd7..85e0cd105 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -24,7 +24,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -130,7 +129,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0"); } if (artifact != null) { - String[] tokens = StringUtils.split(artifact, ":"); + String[] tokens = artifact.split(":"); if (tokens.length < 3 || tokens.length > 5) { throw new MojoFailureException("Invalid artifact, you must specify " + "groupId:artifactId:version[:packaging[:classifier]] " + artifact); @@ -157,7 +156,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (remoteRepositories != null) { // Use the same format as in the deploy plugin id::layout::url - String[] repos = StringUtils.split(remoteRepositories, ","); + String[] repos = remoteRepositories.split(","); for (String repo : repos) { repoList.add(parseRepository(repo, always)); } @@ -214,7 +213,7 @@ ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) } id = matcher.group(1).trim(); - if (!StringUtils.isEmpty(matcher.group(2))) { + if (matcher.group(2) != null && !matcher.group(2).isEmpty()) { layout = getLayout(matcher.group(2).trim()); } url = matcher.group(3).trim(); From f14438f888266c7f543cc144a5bfb12b2208bc9b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 12:36:25 +0000 Subject: [PATCH 200/283] Convert more Mojos from Plexus to Guice (#480) * [MDEP-966] Convert more Mojos from PLexus to Guice --- .../maven/plugins/dependency/GetMojo.java | 28 +++++--- .../plugins/dependency/PropertiesMojo.java | 9 ++- .../dependency/PurgeLocalRepositoryMojo.java | 64 +++++++++++-------- 3 files changed, 62 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 85e0cd105..889f86471 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,7 +36,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.project.DefaultProjectBuildingRequest; @@ -58,28 +59,22 @@ public class GetMojo extends AbstractMojo { private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.*)::(.+)"); - @Component private MavenSession session; - @Component private ArtifactResolver artifactResolver; - @Component private DependencyResolver dependencyResolver; - @Component private ArtifactHandlerManager artifactHandlerManager; /** * Map that contains the layouts. */ - @Component(role = ArtifactRepositoryLayout.class) private Map repositoryLayouts; /** * The repository system. */ - @Component private RepositorySystem repositorySystem; private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); @@ -97,9 +92,6 @@ public class GetMojo extends AbstractMojo { @Parameter(property = "artifact") private String artifact; - /** - * - */ @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) private List pomRemoteRepositories; @@ -117,6 +109,22 @@ public class GetMojo extends AbstractMojo { @Parameter(property = "mdep.skip", defaultValue = "false") private boolean skip; + @Inject + public GetMojo( + MavenSession session, + ArtifactResolver artifactResolver, + DependencyResolver dependencyResolver, + ArtifactHandlerManager artifactHandlerManager, + Map repositoryLayouts, + RepositorySystem repositorySystem) { + this.session = session; + this.artifactResolver = artifactResolver; + this.dependencyResolver = dependencyResolver; + this.artifactHandlerManager = artifactHandlerManager; + this.repositoryLayouts = repositoryLayouts; + this.repositorySystem = repositorySystem; + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (isSkip()) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java index 4eed301de..1e12505a8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java @@ -18,12 +18,13 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -50,9 +51,13 @@ public class PropertiesMojo extends AbstractMojo { /** * The current Maven project */ - @Component private MavenProject project; + @Inject + public PropertiesMojo(MavenProject project) { + this.project = project; + } + /** * Skip plugin execution completely. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index c678faf40..827a0e8a9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -40,7 +42,6 @@ import org.apache.maven.plugin.MojoExecution.Source; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.project.MavenProject; @@ -79,32 +80,39 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo { private static final String GROUP_ID_FUZZINESS = "groupId"; - /** - * The Maven projects in the reactor. - */ - @Parameter(defaultValue = "${reactorProjects}", readonly = true, required = true) - private List reactorProjects; - /** * The current Maven project. */ - @Component private MavenProject project; - @Component private MavenSession session; /** - * This mojo execution, used to determine if it was launched from the lifecycle or the command-line. + * Artifact handler manager. */ - @Parameter(defaultValue = "${mojo}", required = true, readonly = true) - private MojoExecution mojoExecution; + private ArtifactHandlerManager artifactHandlerManager; /** - * Artifact handler manager. + * The dependency resolver */ - @Component - private ArtifactHandlerManager artifactHandlerManager; + private DependencyResolver dependencyResolver; + + /** + * The artifact resolver used to re-resolve dependencies, if that option is enabled. + */ + private ArtifactResolver artifactResolver; + + /** + * The Maven projects in the reactor. + */ + @Parameter(defaultValue = "${reactorProjects}", readonly = true, required = true) + private List reactorProjects; + + /** + * This mojo execution, used to determine if it was launched from the lifecycle or the command-line. + */ + @Parameter(defaultValue = "${mojo}", required = true, readonly = true) + private MojoExecution mojoExecution; /** * The list of dependencies in the form of groupId:artifactId which should BE deleted/purged from the local @@ -172,18 +180,6 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo { @Parameter(defaultValue = "${localRepository}", readonly = true, required = true) private ArtifactRepository localRepository; - /** - * The dependency resolver - */ - @Component - private DependencyResolver dependencyResolver; - - /** - * The artifact resolver used to re-resolve dependencies, if that option is enabled. - */ - @Component - private ArtifactResolver artifactResolver; - /** * Determines how liberally the plugin will delete an artifact from the local repository. Values are:
    *
      @@ -224,6 +220,20 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo { @Parameter(property = "skip", defaultValue = "false") private boolean skip; + @Inject + public PurgeLocalRepositoryMojo( + MavenProject project, + MavenSession session, + ArtifactHandlerManager artifactHandlerManager, + DependencyResolver dependencyResolver, + ArtifactResolver artifactResolver) { + this.session = session; + this.project = project; + this.artifactHandlerManager = artifactHandlerManager; + this.dependencyResolver = dependencyResolver; + this.artifactResolver = artifactResolver; + } + /** * Includes only direct project dependencies. */ From ec0b15c2708037d141ceef2ff4267f17df800704 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 20 Nov 2024 11:02:32 -0500 Subject: [PATCH 201/283] replace another StringUtils call (#486) --- .../maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 1d5d2553d..05b9cb3c4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.plugin.AbstractMojo; @@ -512,7 +511,7 @@ private void writeDependencyXML(Set artifacts) { writer.startElement("version"); writer.writeText(artifact.getBaseVersion()); String classifier = artifact.getClassifier(); - if (StringUtils.isNotBlank(classifier)) { + if (classifier != null && !classifier.trim().isEmpty()) { writer.startElement("classifier"); writer.writeText(artifact.getClassifier()); writer.endElement(); From 5b3be555ff565177ef9813674c3bc24b2d45d137 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 24 Nov 2024 13:06:46 +0000 Subject: [PATCH 202/283] Remove StringUtils from UnpackMojo (#488) --- .../plugins/dependency/fromConfiguration/UnpackMojo.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 979ed507a..ac3369b47 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -21,7 +21,6 @@ import java.io.File; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -165,10 +164,10 @@ protected List getProcessedArtifactItems(boolean removeVersion) th List items = super.getProcessedArtifactItems(new ProcessArtifactItemsRequest(removeVersion, false, false, false)); for (ArtifactItem artifactItem : items) { - if (StringUtils.isEmpty(artifactItem.getIncludes())) { + if (artifactItem.getIncludes().isEmpty()) { artifactItem.setIncludes(getIncludes()); } - if (StringUtils.isEmpty(artifactItem.getExcludes())) { + if (artifactItem.getExcludes().isEmpty()) { artifactItem.setExcludes(getExcludes()); } } From a35afe6ba0a299e7545fd50d22428ece72f2f718 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 24 Nov 2024 14:43:12 +0000 Subject: [PATCH 203/283] PLexus version is managed (#490) --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ed9255b6..0ad9784e4 100644 --- a/pom.xml +++ b/pom.xml @@ -149,7 +149,6 @@ under the License. org.eclipse.sisu org.eclipse.sisu.plexus - 0.9.0.M3 provided From 8853304bfbaf5811a5439ecbdaad27a4463f8bb1 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 24 Nov 2024 14:57:02 +0000 Subject: [PATCH 204/283] avoid StringUtils.stripEnd (#485) --- .../maven/plugins/dependency/analyze/AnalyzeDepMgt.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index 9cb79ece6..4dac8dd64 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -28,7 +28,6 @@ import java.util.Set; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -146,7 +145,7 @@ private boolean checkDependencyManagement() throws MojoExecutionException { // log exclusion errors List exclusionErrors = getExclusionErrors(exclusions, allDependencyArtifacts); for (Artifact exclusion : exclusionErrors) { - getLog().info(StringUtils.stripEnd(getArtifactManagementKey(exclusion), ":") + getLog().info(getArtifactManagementKey(exclusion) + " was excluded in DepMgt, but version " + exclusion.getVersion() + " has been found in the dependency tree."); foundError = true; @@ -249,7 +248,7 @@ public void logMismatch(Artifact dependencyArtifact, Dependency dependencyFromDe "Invalid params: Artifact: " + dependencyArtifact + " Dependency: " + dependencyFromDepMgt); } - getLog().info("\tDependency: " + StringUtils.stripEnd(dependencyFromDepMgt.getManagementKey(), ":")); + getLog().info("\tDependency: " + dependencyFromDepMgt.getManagementKey()); getLog().info("\t\tDepMgt : " + dependencyFromDepMgt.getVersion()); getLog().info("\t\tResolved: " + dependencyArtifact.getBaseVersion()); } From eceab09fa0616bf8500e70c4d7726de7319670e6 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 24 Nov 2024 14:57:46 +0000 Subject: [PATCH 205/283] [MDEP-952] Partially decouple AbstractFromConfigurationMojo from StringUtils (#487) * somewhat Decouple AbstractFromConfigurationMojo from StringUtils --- .../fromConfiguration/AbstractFromConfigurationMojo.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 770f86c22..90ba8818b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -164,13 +164,14 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque artifactItem.getOutputDirectory().mkdirs(); // make sure we have a version. - if (StringUtils.isEmpty(artifactItem.getVersion())) { + if (artifactItem.getVersion() == null || artifactItem.getVersion().isEmpty()) { fillMissingArtifactVersion(artifactItem); } artifactItem.setArtifact(this.getArtifact(artifactItem)); - if (StringUtils.isEmpty(artifactItem.getDestFileName())) { + if (artifactItem.getDestFileName() == null + || artifactItem.getDestFileName().length() == 0) { artifactItem.setDestFileName(DependencyUtil.getFormattedFileName( artifactItem.getArtifact(), removeVersion, prependGroupId, useBaseVersion, removeClassifier)); } @@ -185,7 +186,7 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque } private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException, ArtifactFilterException { - return StringUtils.equalsIgnoreCase(item.getOverWrite(), "true") + return "true".equalsIgnoreCase(item.getOverWrite()) || getMarkedArtifactFilter(item).isArtifactIncluded(item); } @@ -216,6 +217,7 @@ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionEx coordinate.setClassifier(artifactItem.getClassifier()); final String extension; + ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(artifactItem.getType()); if (artifactHandler != null) { extension = artifactHandler.getExtension(); From 00790304ce8ad42c88f2d5b730d14ddc959bc553 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 28 Nov 2024 13:40:02 +0000 Subject: [PATCH 206/283] [MDEP-952] Decouple DependencyUtil from StringUtils (#491) * Decouple DependencyUtil from StringUtils --- .../dependency/utils/DependencyUtil.java | 17 ++++------------ .../dependency/utils/TestDependencyUtil.java | 20 ------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index 6dad61eb4..5ec05ccd6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -29,7 +29,6 @@ import java.nio.file.StandardOpenOption; import java.util.Objects; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.logging.Log; @@ -119,7 +118,9 @@ public static String getFormattedFileName( String classifierString = ""; - if (!removeClassifier && StringUtils.isNotEmpty(artifact.getClassifier())) { + if (!removeClassifier + && artifact.getClassifier() != null + && !artifact.getClassifier().isEmpty()) { classifierString = "-" + artifact.getClassifier(); } destFileName.append(artifact.getArtifactId()).append(versionString); @@ -186,7 +187,7 @@ private static String getDependencyId(Artifact artifact, boolean removeVersion, sb.append(artifact.getVersion()); } - if (StringUtils.isNotEmpty(artifact.getClassifier())) { + if (artifact.getClassifier() != null && !artifact.getClassifier().isEmpty()) { sb.append("-"); sb.append(artifact.getClassifier()); } @@ -259,16 +260,6 @@ public static synchronized void log(String string, Log log) throws IOException { } } - /** - * Mainly used to parse excludes, includes configuration. - * - * @param str the string to split - * @return the result items - */ - public static String[] tokenizer(String str) { - return StringUtils.split(cleanToBeTokenizedString(str), ","); - } - /** * Clean up configuration string before it can be tokenized. * diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java index ceaa05a76..8de8ce0d4 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyUtil.java @@ -320,26 +320,6 @@ void testFileNameClassifierWithFile() { assertEquals(expectedResult, name); } - @Test - void testTokenizer() { - String[] tokens = DependencyUtil.tokenizer(" alpha,bravo, charlie , delta kappa, theta"); - String[] expected = new String[] {"alpha", "bravo", "charlie", "delta kappa", "theta"}; - // easier to see in the JUnit reports - assertEquals(String.join(", ", expected), String.join(", ", tokens)); - assertEquals(expected.length, tokens.length); - - tokens = DependencyUtil.tokenizer(" \r\n a, \t \n \r b \t \n \r"); - assertEquals(2, tokens.length); - assertEquals("a", tokens[0]); - assertEquals("b", tokens[1]); - - tokens = DependencyUtil.tokenizer(null); - assertEquals(0, tokens.length); - - tokens = DependencyUtil.tokenizer(" "); - assertEquals(0, tokens.length); - } - @Test void outputFileShouldBeOverridden() throws IOException { File file = new File(temDir, "file1.out"); From 969ed96b7acda4b947559fe34f116264381e8643 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 28 Nov 2024 15:42:23 +0000 Subject: [PATCH 207/283] [MDEP-966] Migrate TreeMojo/CopyMojo/AnalyzeExclusionsMojo/UnpackMojo/CopyDependenciesMojo from Plexus to Sisu Guice (#483) * [MDEP-966] Migrate TreeMojo from Plexus to Sisu Guice * [MDEP-966] Migrate AnalyzeExclusionMojo from Plexus to Sisu Guice * [MDEP-966] Migrate CopyMojo from Plexus to Sisu Guice * [MDEP-966] Migrate UnpackMojo from Plexus to Sisu Guice * BuildClasspathMojo * CopyDependenciesMojo --- .../maven/plugins/dependency/GetMojo.java | 14 ++++---- .../plugins/dependency/ListClassesMojo.java | 2 +- .../dependency/ListRepositoriesMojo.java | 2 +- .../plugins/dependency/PropertiesMojo.java | 2 +- .../dependency/PurgeLocalRepositoryMojo.java | 10 +++--- .../dependency/analyze/AnalyzeDepMgt.java | 2 +- .../dependency/analyze/AnalyzeReport.java | 12 +++---- .../exclusion/AnalyzeExclusionsMojo.java | 19 +++++++---- .../fromConfiguration/CopyMojo.java | 12 +++++-- .../fromConfiguration/UnpackMojo.java | 11 ++++-- .../fromDependencies/BuildClasspathMojo.java | 13 ++++--- .../CopyDependenciesMojo.java | 24 +++++-------- .../UnpackDependenciesMojo.java | 11 ++++-- .../plugins/dependency/tree/TreeMojo.java | 34 ++++++++++++------- .../fromConfiguration/TestCopyMojo.java | 3 +- 15 files changed, 101 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java index 889f86471..0c03e313f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/GetMojo.java @@ -59,25 +59,25 @@ public class GetMojo extends AbstractMojo { private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.*)::(.+)"); - private MavenSession session; + private final MavenSession session; - private ArtifactResolver artifactResolver; + private final ArtifactResolver artifactResolver; - private DependencyResolver dependencyResolver; + private final DependencyResolver dependencyResolver; - private ArtifactHandlerManager artifactHandlerManager; + private final ArtifactHandlerManager artifactHandlerManager; /** * Map that contains the layouts. */ - private Map repositoryLayouts; + private final Map repositoryLayouts; /** * The repository system. */ - private RepositorySystem repositorySystem; + private final RepositorySystem repositorySystem; - private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); + private final DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); /** * Repositories in the format id::[layout]::url or just url, separated by comma. ie. diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java index 0f20be959..15866fd8e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java @@ -46,7 +46,7 @@ @Mojo(name = "list-classes", requiresProject = false, threadSafe = true) public class ListClassesMojo extends AbstractMojo { - private ResolverUtil resolverUtil; + private final ResolverUtil resolverUtil; private ParamArtifact paramArtifact = new ParamArtifact(); diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index 5c3eb6116..3a0debe9c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -54,7 +54,7 @@ @Mojo(name = "list-repositories", threadSafe = true) public class ListRepositoriesMojo extends AbstractDependencyMojo { - private RepositorySystem repositorySystem; + private final RepositorySystem repositorySystem; @Inject public ListRepositoriesMojo(RepositorySystem repositorySystem) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java index 1e12505a8..ef1f73b02 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PropertiesMojo.java @@ -51,7 +51,7 @@ public class PropertiesMojo extends AbstractMojo { /** * The current Maven project */ - private MavenProject project; + private final MavenProject project; @Inject public PropertiesMojo(MavenProject project) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java index 827a0e8a9..2255ae63d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java @@ -83,24 +83,24 @@ public class PurgeLocalRepositoryMojo extends AbstractMojo { /** * The current Maven project. */ - private MavenProject project; + private final MavenProject project; - private MavenSession session; + private final MavenSession session; /** * Artifact handler manager. */ - private ArtifactHandlerManager artifactHandlerManager; + private final ArtifactHandlerManager artifactHandlerManager; /** * The dependency resolver */ - private DependencyResolver dependencyResolver; + private final DependencyResolver dependencyResolver; /** * The artifact resolver used to re-resolve dependencies, if that option is enabled. */ - private ArtifactResolver artifactResolver; + private final ArtifactResolver artifactResolver; /** * The Maven projects in the reactor. diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index 4dac8dd64..6037ecff2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -52,7 +52,7 @@ public class AnalyzeDepMgt extends AbstractMojo { // fields ----------------------------------------------------------------- - private MavenProject project; + private final MavenProject project; /** * Fail the build if a problem is detected. diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java index 96ffe077c..ef08b0259 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java @@ -49,7 +49,12 @@ public class AnalyzeReport extends AbstractMavenReport { /** * The Maven project dependency analyzer to use. */ - private ProjectDependencyAnalyzer analyzer; + private final ProjectDependencyAnalyzer analyzer; + + /** + * Internationalization component + */ + private final I18N i18n; /** * Ignore Runtime/Provided/Test/System scopes for unused dependency analysis @@ -84,11 +89,6 @@ public class AnalyzeReport extends AbstractMavenReport { @Parameter(property = "mdep.analyze.excludedClasses") private Set excludedClasses; - /** - * Internationalization component - */ - private I18N i18n; - @Inject public AnalyzeReport(ProjectDependencyAnalyzer analyzer, I18N i18n) { this.analyzer = analyzer; diff --git a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java index e16410979..e45c76c4e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.exclusion; +import javax.inject.Inject; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -32,7 +34,6 @@ import org.apache.maven.model.Exclusion; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; -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.plugins.annotations.ResolutionScope; @@ -57,14 +58,18 @@ @Mojo(name = "analyze-exclusions", requiresDependencyCollection = ResolutionScope.TEST, threadSafe = true) public class AnalyzeExclusionsMojo extends AbstractMojo { - @Component - private MavenProject project; + private final MavenProject project; + + private final ResolverUtil resolverUtil; - @Component - private ResolverUtil resolverUtil; + private final MavenSession session; - @Component - private MavenSession session; + @Inject + public AnalyzeExclusionsMojo(MavenProject project, ResolverUtil resolverUtil, MavenSession session) { + this.project = project; + this.resolverUtil = resolverUtil; + this.session = session; + } /** * Whether to fail the build if invalid exclusions is found. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index a9de46fe0..a9b9ba88d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.fromConfiguration; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.List; @@ -25,7 +27,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -42,8 +43,8 @@ @Mojo(name = "copy", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresProject = false, threadSafe = true) public class CopyMojo extends AbstractFromConfigurationMojo { - @Component - private CopyUtil copyUtil; + private final CopyUtil copyUtil; + /** * Strip artifact version during copy */ @@ -80,6 +81,11 @@ public class CopyMojo extends AbstractFromConfigurationMojo { @Parameter(property = "artifact") private String artifact; + @Inject + public CopyMojo(CopyUtil copyUtil) { + this.copyUtil = copyUtil; + } + /** * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * copyArtifact. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index ac3369b47..4d7be1900 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -18,12 +18,13 @@ */ package org.apache.maven.plugins.dependency.fromConfiguration; +import javax.inject.Inject; + import java.io.File; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -43,8 +44,7 @@ @Mojo(name = "unpack", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresProject = false, threadSafe = true) public class UnpackMojo extends AbstractFromConfigurationMojo { - @Component - private UnpackUtil unpackUtil; + private final UnpackUtil unpackUtil; /** * Directory to store flag files after unpack @@ -97,6 +97,11 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { @Parameter(property = "artifact") private String artifact; + @Inject + public UnpackMojo(UnpackUtil unpackUtil) { + this.unpackUtil = unpackUtil; + } + /** * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * unpackArtifact. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 5d689e1f8..d65f6ae33 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.fromDependencies; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.io.Writer; @@ -38,7 +40,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -162,16 +163,20 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements /** * Maven ProjectHelper */ - @Component private MavenProjectHelper projectHelper; - @Component private RepositoryManager repositoryManager; + @Inject + public BuildClasspathMojo(MavenProjectHelper projectHelper, RepositoryManager repositoryManager) { + this.projectHelper = projectHelper; + this.repositoryManager = repositoryManager; + } + /** * Main entry into mojo. Gets the list of dependencies and iterates to create a classpath. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs * @see #getResolvedDependencies(boolean) */ @Override diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index dcf2e9141..01e15040b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -18,17 +18,16 @@ */ package org.apache.maven.plugins.dependency.fromDependencies; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.Collections; -import java.util.Map; import java.util.Set; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -66,20 +65,15 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.copyPom", defaultValue = "false") protected boolean copyPom; - @Component - private CopyUtil copyUtil; + private final CopyUtil copyUtil; - /** - * - */ - @Component - private ArtifactInstaller installer; + private final ArtifactInstaller installer; - /** - * - */ - @Component(role = ArtifactRepositoryLayout.class) - private Map repositoryLayouts; + @Inject + public CopyDependenciesMojo(CopyUtil copyUtil, ArtifactInstaller installer) { + this.copyUtil = copyUtil; + this.installer = installer; + } /** * Either append the artifact's baseVersion or uniqueVersion to the filename. Will only be used if diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index e1042b47c..aac398e0e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -18,11 +18,12 @@ */ package org.apache.maven.plugins.dependency.fromDependencies; +import javax.inject.Inject; + import java.io.File; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -50,8 +51,12 @@ // CHECKSTYLE_ON: LineLength public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { - @Component - private UnpackUtil unpackUtil; + private final UnpackUtil unpackUtil; + + @Inject + public UnpackDependenciesMojo(UnpackUtil unpackUtil) { + this.unpackUtil = unpackUtil; + } /** * A comma separated list of file patterns to include when unpacking the artifact. i.e. diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 59c05448f..3a49f6336 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.tree; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.io.StringWriter; @@ -32,7 +34,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -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.plugins.annotations.ResolutionScope; @@ -75,26 +76,22 @@ public class TreeMojo extends AbstractMojo { /** * The Maven project. */ - @Component - private MavenProject project; + private final MavenProject project; - @Component - private MavenSession session; - - @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") - private String outputEncoding; + private final MavenSession session; /** * The dependency collector builder to use. */ - @Component(hint = "default") - private DependencyCollectorBuilder dependencyCollectorBuilder; + private final DependencyCollectorBuilder dependencyCollectorBuilder; /** * The dependency graph builder to use. */ - @Component(hint = "default") - private DependencyGraphBuilder dependencyGraphBuilder; + private final DependencyGraphBuilder dependencyGraphBuilder; + + @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") + private String outputEncoding; /** * If specified, this parameter will cause the dependency tree to be written to the path specified, instead of @@ -205,6 +202,19 @@ public class TreeMojo extends AbstractMojo { */ @Parameter(property = "skip", defaultValue = "false") private boolean skip; + + @Inject + public TreeMojo( + MavenProject project, + MavenSession session, + DependencyCollectorBuilder dependencyCollectorBuilder, + DependencyGraphBuilder dependencyGraphBuilder) { + this.project = project; + this.session = session; + this.dependencyCollectorBuilder = dependencyCollectorBuilder; + this.dependencyGraphBuilder = dependencyGraphBuilder; + } + // Mojo methods ----------------------------------------------------------- /* diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index 3af9f1fce..e4831c917 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -38,6 +38,7 @@ public class TestCopyMojo extends AbstractDependencyMojoTestCase { private CopyMojo mojo; + @Override protected void setUp() throws Exception { super.setUp("copy", false, false); MavenProject project = new DependencyProjectStub(); @@ -129,7 +130,7 @@ public void assertFileExists(ArtifactItem item, boolean exist) { } public void testMojoDefaults() { - CopyMojo themojo = new CopyMojo(); + CopyMojo themojo = new CopyMojo(null); assertFalse(themojo.isStripVersion()); assertFalse(themojo.isSkip()); From 6fa66043341b83a4e2ae49366c7edc2279c5a044 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 6 Dec 2024 13:34:42 +0000 Subject: [PATCH 208/283] [MDEP-776] Warn when multiple dependencies have the same file name (#463) * Warn when overwriting file --- .../invoker.properties | 18 +++++ .../copy-dependencies-with-conflict/pom.xml | 77 +++++++++++++++++++ .../verify.groovy | 31 ++++++++ .../fromConfiguration/ArtifactItem.java | 12 +-- .../fromConfiguration/CopyMojo.java | 11 ++- .../CopyDependenciesMojo.java | 48 ++++++++---- .../plugins/dependency/utils/CopyUtil.java | 6 +- 7 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 src/it/projects/copy-dependencies-with-conflict/invoker.properties create mode 100644 src/it/projects/copy-dependencies-with-conflict/pom.xml create mode 100644 src/it/projects/copy-dependencies-with-conflict/verify.groovy diff --git a/src/it/projects/copy-dependencies-with-conflict/invoker.properties b/src/it/projects/copy-dependencies-with-conflict/invoker.properties new file mode 100644 index 000000000..f50e476fd --- /dev/null +++ b/src/it/projects/copy-dependencies-with-conflict/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = clean process-sources diff --git a/src/it/projects/copy-dependencies-with-conflict/pom.xml b/src/it/projects/copy-dependencies-with-conflict/pom.xml new file mode 100644 index 000000000..b7c6cf627 --- /dev/null +++ b/src/it/projects/copy-dependencies-with-conflict/pom.xml @@ -0,0 +1,77 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test with conflicts + + Test dependency:copy-dependencies with conflicting artifact IDs + + + + + + + org.jdom + jdom + 1.1.3 + + + org.lucee + jdom + 1.1.3 + + + + + UTF-8 + + + + + package + + + + maven-dependency-plugin + @project.version@ + + + test-2 + + copy-dependencies + + + true + ${project.build.directory}/it/copy-dep-test-2 + + + + + + + diff --git a/src/it/projects/copy-dependencies-with-conflict/verify.groovy b/src/it/projects/copy-dependencies-with-conflict/verify.groovy new file mode 100644 index 000000000..b66deb089 --- /dev/null +++ b/src/it/projects/copy-dependencies-with-conflict/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +File file = new File( basedir, "build.log" ) +assert file.exists() + +String buildLog = file.getText( "UTF-8" ) +assert buildLog.contains( '[WARNING] Overwriting ' ) +assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' ) +assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:pom:1.1.3\'' ) +assert buildLog.contains( '[DEBUG] Copying artifact \'org.jdom:jdom:jar:1.1.3\'' ) +assert buildLog.contains( '[DEBUG] Copying artifact \'org.lucee:jdom:jar:1.1.3\'' ) +assert buildLog.contains( '[WARNING] Multiple files with the name jdom-1.1.3.jar in the dependency tree.' ) + +return true diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java index ff9e5b39f..b98b4567c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java @@ -36,8 +36,7 @@ */ public class ArtifactItem implements DependableCoordinate { /** - * Group Id of Artifact - * + * Group ID of Artifact */ @Parameter(required = true) private String groupId; @@ -56,7 +55,6 @@ public class ArtifactItem implements DependableCoordinate { /** * Type of Artifact (War,Jar,etc) - * */ @Parameter(required = true) private String type = "jar"; @@ -90,9 +88,6 @@ public class ArtifactItem implements DependableCoordinate { @Parameter private String encoding; - /** - * - */ private boolean needsProcessing; /** @@ -147,6 +142,7 @@ private String filterEmptyString(String in) { /** * @return Returns the artifactId. */ + @Override public String getArtifactId() { return artifactId; } @@ -161,6 +157,7 @@ public void setArtifactId(String theArtifact) { /** * @return Returns the groupId. */ + @Override public String getGroupId() { return groupId; } @@ -175,6 +172,7 @@ public void setGroupId(String groupId) { /** * @return Returns the type. */ + @Override public String getType() { return type; } @@ -189,6 +187,7 @@ public void setType(String type) { /** * @return Returns the version. */ + @Override public String getVersion() { return version; } @@ -210,6 +209,7 @@ public String getBaseVersion() { /** * @return Classifier. */ + @Override public String getClassifier() { return classifier; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index a9b9ba88d..e9ad6d737 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -101,11 +101,12 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { List theArtifactItems = getProcessedArtifactItems( new ProcessArtifactItemsRequest(stripVersion, prependGroupId, useBaseVersion, stripClassifier)); + for (ArtifactItem artifactItem : theArtifactItems) { if (artifactItem.isNeedsProcessing()) { copyArtifact(artifactItem); } else { - this.getLog().info(artifactItem + " already exists in " + artifactItem.getOutputDirectory()); + getLog().info(artifactItem + " already exists in " + artifactItem.getOutputDirectory()); } } } @@ -113,13 +114,15 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { /** * Resolves the artifact from the repository and copies it to the specified location. * - * @param artifactItem containing the information about the Artifact to copy. - * @throws MojoExecutionException with a message if an error occurs. + * @param artifactItem containing the information about the artifact to copy + * @throws MojoExecutionException with a message if an error occurs * @see CopyUtil#copyArtifactFile(Artifact, File) */ protected void copyArtifact(ArtifactItem artifactItem) throws MojoExecutionException { File destFile = new File(artifactItem.getOutputDirectory(), artifactItem.getDestFileName()); - + if (destFile.exists()) { + getLog().warn("Overwriting " + destFile); + } try { copyUtil.copyArtifactFile(artifactItem.getArtifact(), destFile); } catch (IOException e) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 01e15040b..f8b180234 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import org.apache.maven.RepositoryUtils; @@ -44,7 +46,10 @@ import org.eclipse.aether.util.artifact.SubArtifact; /** - * Goal that copies the project dependencies from the repository to a defined location. + * Goal that copies the files for a project's dependencies from the repository to a directory. + * The default location to copy to is target/dependencies. + * Since all files are copied to the same directory by default, a dependency that + * has the same file name as another dependency will be overwritten. * * @author Brian Fox * @since 1.0 @@ -95,7 +100,7 @@ public CopyDependenciesMojo(CopyUtil copyUtil, ArtifactInstaller installer) { /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs * @see #getDependencySets(boolean, boolean) * @see #copyArtifact(Artifact, boolean, boolean, boolean, boolean) */ @@ -105,6 +110,21 @@ protected void doExecute() throws MojoExecutionException { Set artifacts = dss.getResolvedDependencies(); if (!useRepositoryLayout) { + Map copies = new HashMap<>(); + for (Artifact artifactItem : artifacts) { + String destFileName = DependencyUtil.getFormattedFileName( + artifactItem, stripVersion, prependGroupId, useBaseVersion, stripClassifier); + int numCopies = copies.getOrDefault(destFileName, 0); + copies.put(destFileName, numCopies + 1); + } + for (Map.Entry entry : copies.entrySet()) { + if (entry.getValue() > 1) { + getLog().warn("Multiple files with the name " + entry.getKey() + " in the dependency tree."); + getLog().warn( + "Not all JARs will be available. Consider using prependGroupId, useSubDirectoryPerArtifact, or useRepositoryLayout."); + } + } + for (Artifact artifact : artifacts) { copyArtifact( artifact, isStripVersion(), this.prependGroupId, this.useBaseVersion, this.stripClassifier); @@ -123,19 +143,13 @@ protected void doExecute() throws MojoExecutionException { if (isCopyPom() && !useRepositoryLayout) { copyPoms(getOutputDirectory(), artifacts, this.stripVersion); - copyPoms(getOutputDirectory(), skippedArtifacts, this.stripVersion, this.stripClassifier); // Artifacts - // that already - // exist may - // not yet have - // poms + copyPoms(getOutputDirectory(), skippedArtifacts, this.stripVersion, this.stripClassifier); + // Artifacts that already exist may not yet have poms } } /** - * install the artifact and the corresponding pom if copyPoms=true - * - * @param artifact - * @param buildingRequest + * Install the artifact and the corresponding pom if copyPoms=true. */ private void installArtifact(Artifact artifact, ProjectBuildingRequest buildingRequest) { try { @@ -193,7 +207,7 @@ protected void copyArtifact( * @param artifact representing the object to be copied. * @param removeVersion specifies if the version should be removed from the file name when copying. * @param prependGroupId specifies if the groupId should be prepend to the file while copying. - * @param theUseBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. + * @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. * @param removeClassifier specifies if the classifier should be removed from the file name when copying. * @throws MojoExecutionException with a message if an error occurs. * @see CopyUtil#copyArtifactFile(Artifact, File) @@ -203,12 +217,12 @@ protected void copyArtifact( Artifact artifact, boolean removeVersion, boolean prependGroupId, - boolean theUseBaseVersion, + boolean useBaseVersion, boolean removeClassifier) throws MojoExecutionException { String destFileName = DependencyUtil.getFormattedFileName( - artifact, removeVersion, prependGroupId, theUseBaseVersion, removeClassifier); + artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier); File destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, @@ -220,7 +234,9 @@ protected void copyArtifact( outputDirectory, artifact); File destFile = new File(destDir, destFileName); - + if (destFile.exists()) { + getLog().warn("Overwriting " + destFile); + } try { copyUtil.copyArtifactFile(artifact, destFile); } catch (IOException e) { @@ -323,7 +339,7 @@ public boolean isCopyPom() { } /** - * @param copyPom - true if the pom of each artifact must be copied + * @param copyPom true if the pom of each artifact must be copied */ public void setCopyPom(boolean copyPom) { this.copyPom = copyPom; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java index b175fb705..f83bb15cf 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -51,9 +51,9 @@ public CopyUtil(BuildContext buildContext) { } /** - * Copies the artifact (file). + * Copies the artifact (file) * - * @param sourceArtifact represents the artifact (file) to copy + * @param sourceArtifact the artifact (file) to copy * @param destination file name of destination file * @throws IOException if copy has failed * @throws MojoExecutionException if artifact file is a directory (which has not been packaged yet) @@ -68,7 +68,7 @@ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws I + "' has not been packaged yet (is a directory). When used on reactor artifact, " + "copy should be executed after packaging: see MDEP-187."); } - logger.debug("Copying artifact '{}' ({}) to {}", sourceArtifact, sourceArtifact.getFile(), destination); + logger.debug("Copying artifact '{}' ({}) to {}", sourceArtifact.getId(), sourceArtifact.getFile(), destination); FileUtils.copyFile(source, destination); buildContext.refresh(destination); } From ae19d893bb61a4b8414877721ca25b580c454dad Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 6 Dec 2024 16:05:43 +0000 Subject: [PATCH 209/283] [MDEP-952] Remove StringUtils dependency (#492) * Remove StringUtils dependency --- .../dependency/utils/filters/DestFileFilter.java | 7 +++---- .../utils/markers/UnpackFileMarkerHandler.java | 13 ++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index be52f1f5d..669c90c13 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -24,7 +24,6 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugins.dependency.utils.DependencyUtil; @@ -284,7 +283,7 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept } File destFile; - if (StringUtils.isEmpty(item.getDestFileName())) { + if (item.getDestFileName() == null || item.getDestFileName().isEmpty()) { String formattedFileName = DependencyUtil.getFormattedFileName( artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier); destFile = new File(destFolder, formattedFileName); @@ -298,13 +297,13 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept } /** - * Using simply {@code File.getLastModified} will return sometimes a wrong value see JDK bug for details. + * {@code File.getLastModified} sometimes returns a wrong value. See JDK bug for details. *

      * https://bugs.openjdk.java.net/browse/JDK-8177809 * * @param file {@link File} * @return the last modification time in milliseconds. - * @throws ArtifactFilterException in case of a IO Exception. + * @throws ArtifactFilterException in case of an IOException */ private long getLastModified(File file) throws ArtifactFilterException { try { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 00c7be06e..396f39fc5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -20,7 +20,6 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem; /** @@ -52,22 +51,22 @@ public UnpackFileMarkerHandler(ArtifactItem artifactItem, File markerFilesDirect protected File getMarkerFile() { /* * Build a hash of all include/exclude strings, to determine if an artifactItem has been unpacked using the - * include/exclude parameters, this will allow an artifact to be included multiple times with different - * include/exclude parameters + * include/exclude parameters. This allows an artifact to be included multiple times with different + * include/exclude parameters. */ File markerFile; if (this.artifactItem == null - || (StringUtils.isEmpty(this.artifactItem.getIncludes()) - && StringUtils.isEmpty(this.artifactItem.getExcludes()))) { + || this.artifactItem.getIncludes().isEmpty() + && this.artifactItem.getExcludes().isEmpty()) { markerFile = super.getMarkerFile(); } else { int includeExcludeHash = 0; - if (StringUtils.isNotEmpty(this.artifactItem.getIncludes())) { + if (!this.artifactItem.getIncludes().isEmpty()) { includeExcludeHash += this.artifactItem.getIncludes().hashCode(); } - if (StringUtils.isNotEmpty(this.artifactItem.getExcludes())) { + if (!this.artifactItem.getExcludes().isEmpty()) { includeExcludeHash += this.artifactItem.getExcludes().hashCode(); } From f7f2ab4236de28953e92f51c41fff1ec1a6b4b94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:55:34 +0000 Subject: [PATCH 210/283] Bump org.jsoup:jsoup from 1.18.1 to 1.18.3 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.18.1 to 1.18.3. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.18.1...jsoup-1.18.3) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0ad9784e4..dd72c878f 100644 --- a/pom.xml +++ b/pom.xml @@ -498,7 +498,7 @@ under the License. org.jsoup jsoup - 1.18.1 + 1.18.3 From 5901ecd85514d06e2b0c10ebc46a795d4ee68fe0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:48:32 +0000 Subject: [PATCH 211/283] Bump org.assertj:assertj-core from 3.26.3 to 3.27.0 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.26.3 to 3.27.0. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.26.3...assertj-build-3.27.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dd72c878f..5e2f2202f 100644 --- a/pom.xml +++ b/pom.xml @@ -375,7 +375,7 @@ under the License. org.assertj assertj-core - 3.26.3 + 3.27.0 test From 8b07cb3eb4eb3138099f52dde22de7e095d3f09c Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 30 Dec 2024 17:05:11 +0000 Subject: [PATCH 212/283] Prefer Guice injection (#498) --- pom.xml | 6 ---- .../AbstractDependencyFilterMojo.java | 35 +++++++++++-------- .../AbstractFromDependenciesMojo.java | 16 ++++++++- .../fromDependencies/BuildClasspathMojo.java | 29 ++++++++------- .../CopyDependenciesMojo.java | 25 +++++++++---- .../UnpackDependenciesMojo.java | 26 ++++++++++---- .../resolvers/AbstractResolveMojo.java | 14 ++++++++ .../resolvers/CollectDependenciesMojo.java | 20 ++++++++++- .../dependency/resolvers/GoOfflineMojo.java | 26 +++++++++++--- .../dependency/resolvers/ListMojo.java | 17 +++++++++ .../OldResolveDependencySourcesMojo.java | 20 ++++++++++- .../resolvers/ResolveDependenciesMojo.java | 17 +++++++++ .../ResolveDependencySourcesMojo.java | 17 +++++++++ .../resolvers/ResolvePluginsMojo.java | 17 +++++++++ .../ResolveDependenciesMojoTest.java | 2 +- 15 files changed, 234 insertions(+), 53 deletions(-) diff --git a/pom.xml b/pom.xml index 5e2f2202f..462166a0c 100644 --- a/pom.xml +++ b/pom.xml @@ -146,12 +146,6 @@ under the License. provided - - org.eclipse.sisu - org.eclipse.sisu.plexus - provided - - org.apache.maven.doxia diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index c6a4633e8..6818dfc01 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; @@ -60,15 +59,6 @@ */ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMojo { - @Component - private ResolverUtil resolverUtil; - - @Component - private DependencyResolver dependencyResolver; - - @Component - private RepositoryManager repositoryManager; - /** * Overwrite release artifacts * @@ -239,11 +229,28 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj @Parameter(property = "mdep.prependGroupId", defaultValue = "false") protected boolean prependGroupId = false; - @Component - private ProjectBuilder projectBuilder; + private final ResolverUtil resolverUtil; + + private final DependencyResolver dependencyResolver; - @Component - private ArtifactHandlerManager artifactHandlerManager; + private final RepositoryManager repositoryManager; + + private final ProjectBuilder projectBuilder; + + private final ArtifactHandlerManager artifactHandlerManager; + + protected AbstractDependencyFilterMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + this.resolverUtil = resolverUtil; + this.dependencyResolver = dependencyResolver; + this.repositoryManager = repositoryManager; + this.projectBuilder = projectBuilder; + this.artifactHandlerManager = artifactHandlerManager; + } /** * Return an {@link ArtifactsFilter} indicating which artifacts must be filtered out. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 1d03fde69..2e4f675fd 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -20,7 +20,12 @@ import java.io.File; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * Abstract Parent class used by mojos that get Artifact information from the project dependencies. @@ -106,8 +111,17 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil @Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false") protected boolean failOnMissingClassifierArtifact; + protected AbstractFromDependenciesMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + /** - * @return Returns the outputDirectory. + * @return returns the outputDirectory */ public File getOutputDirectory() { return this.outputDirectory; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index d65f6ae33..2c4ef03bf 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -39,15 +39,19 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; /** @@ -160,17 +164,18 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements @Parameter(property = "mdep.useBaseVersion", defaultValue = "true") private boolean useBaseVersion = true; - /** - * Maven ProjectHelper - */ - private MavenProjectHelper projectHelper; - - private RepositoryManager repositoryManager; + private final MavenProjectHelper projectHelper; @Inject - public BuildClasspathMojo(MavenProjectHelper projectHelper, RepositoryManager repositoryManager) { + protected BuildClasspathMojo( + MavenProjectHelper projectHelper, + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); this.projectHelper = projectHelper; - this.repositoryManager = repositoryManager; } /** @@ -248,8 +253,8 @@ protected void doExecute() throws MojoExecutionException { } /** - * @param cpString The classpath. - * @throws MojoExecutionException in case of an error. + * @param cpString the classpath + * @throws MojoExecutionException in case of an error */ protected void attachFile(String cpString) throws MojoExecutionException { File attachedFile = new File(getProject().getBuild().getDirectory(), "classpath"); @@ -259,7 +264,7 @@ protected void attachFile(String cpString) throws MojoExecutionException { } /** - * Appends the artifact path into the specified StringBuilder. + * Appends the artifact path to the specified StringBuilder. * * @param art {@link Artifact} * @param sb {@link StringBuilder} @@ -270,7 +275,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { // substitute the property for the local repo path to make the classpath file portable. if (localRepoProperty != null && !localRepoProperty.isEmpty()) { ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); - File localBasedir = repositoryManager.getLocalRepositoryBasedir(projectBuildingRequest); + File localBasedir = getRepositoryManager().getLocalRepositoryBasedir(projectBuildingRequest); file = StringUtils.replace(file, localBasedir.getAbsolutePath(), localRepoProperty); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index f8b180234..1029988be 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -29,6 +29,7 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -37,11 +38,15 @@ import org.apache.maven.plugins.dependency.utils.CopyUtil; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.util.artifact.SubArtifact; @@ -74,12 +79,6 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { private final ArtifactInstaller installer; - @Inject - public CopyDependenciesMojo(CopyUtil copyUtil, ArtifactInstaller installer) { - this.copyUtil = copyUtil; - this.installer = installer; - } - /** * Either append the artifact's baseVersion or uniqueVersion to the filename. Will only be used if * {@link #isStripVersion()} is {@code false}. @@ -97,6 +96,20 @@ public CopyDependenciesMojo(CopyUtil copyUtil, ArtifactInstaller installer) { @Parameter(property = "mdep.addParentPoms", defaultValue = "false") protected boolean addParentPoms; + @Inject + public CopyDependenciesMojo( + CopyUtil copyUtil, + ArtifactInstaller installer, + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + this.copyUtil = copyUtil; + this.installer = installer; + } + /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index aac398e0e..f10da2cf3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -23,6 +23,7 @@ import java.io.File; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -30,10 +31,14 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.codehaus.plexus.components.io.filemappers.FileMapper; /** @@ -51,13 +56,6 @@ // CHECKSTYLE_ON: LineLength public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { - private final UnpackUtil unpackUtil; - - @Inject - public UnpackDependenciesMojo(UnpackUtil unpackUtil) { - this.unpackUtil = unpackUtil; - } - /** * A comma separated list of file patterns to include when unpacking the artifact. i.e. * **/*.xml,**/*.properties NOTE: Excludes patterns override the includes. (component code = @@ -102,6 +100,20 @@ public UnpackDependenciesMojo(UnpackUtil unpackUtil) { @Parameter(property = "mdep.unpack.filemappers") private FileMapper[] fileMappers; + private final UnpackUtil unpackUtil; + + @Inject + public UnpackDependenciesMojo( + UnpackUtil unpackUtil, + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + this.unpackUtil = unpackUtil; + } + /** * Main entry into mojo. This method gets the dependencies and iterates through each one passing it to * DependencyUtil.unpackFile(). diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index bf03a003f..636f410d0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -20,15 +20,20 @@ import java.io.File; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * @author Brian Fox @@ -60,6 +65,15 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; + protected AbstractResolveMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + /** * @return {@link FilterArtifacts} */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java index 8b5fe8504..e99e9a471 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java @@ -18,9 +18,16 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** *

      @@ -45,4 +52,15 @@ requiresDependencyCollection = ResolutionScope.TEST, defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -public class CollectDependenciesMojo extends ResolveDependenciesMojo {} +public class CollectDependenciesMojo extends ResolveDependenciesMojo { + + @Inject + public CollectDependenciesMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index 6ca1c3968..acff067e4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; @@ -27,11 +29,14 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -40,7 +45,9 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * Goal that resolves all project dependencies, including plugins and reports and their dependencies. @@ -52,6 +59,17 @@ */ @Mojo(name = "go-offline", threadSafe = true) public class GoOfflineMojo extends AbstractResolveMojo { + + @Inject + public GoOfflineMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + /** * Main entry into mojo. Gets the list of dependencies, resolves all that are not in the Reactor, and iterates * through displaying the resolved versions. @@ -84,8 +102,8 @@ protected void doExecute() throws MojoExecutionException { /** * This method resolves the dependency artifacts from the project. * - * @return set of resolved dependency artifacts. - * @throws DependencyResolverException in case of an error while resolving the artifacts. + * @return set of resolved dependency artifacts + * @throws DependencyResolverException in case of an error while resolving the artifacts * @throws ArtifactFilterException */ protected Set resolveDependencyArtifacts() throws DependencyResolverException, ArtifactFilterException { @@ -139,8 +157,8 @@ private TransformableFilter getTransformableFilter() { /** * This method resolves the plugin artifacts from the project. * - * @return set of resolved plugin artifacts. - * @throws DependencyResolverException in case of an error while resolving the artifacts. + * @return set of resolved plugin artifacts + * @throws DependencyResolverException in case of an error while resolving the artifacts * @throws ArtifactFilterException */ protected Set resolvePluginArtifacts() throws DependencyResolverException, ArtifactFilterException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java index 54cb52c46..4d6e24cfd 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java @@ -18,8 +18,15 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * Displays the list of dependencies for this project. @@ -29,5 +36,15 @@ */ @Mojo(name = "list", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class ListMojo extends ResolveDependenciesMojo { + + @Inject + public ListMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } // alias for dependency:resolve } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java index 88f9ccfa8..caadd3ae9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java @@ -18,9 +18,16 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * Goal that resolves the project source dependencies from the repository. @@ -35,4 +42,15 @@ requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) @Deprecated -public class OldResolveDependencySourcesMojo extends ResolveDependencySourcesMojo {} +public class OldResolveDependencySourcesMojo extends ResolveDependencySourcesMojo { + + @Inject + public OldResolveDependencySourcesMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 6f49a4767..fbf0baaa0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -32,6 +34,7 @@ import java.util.jar.Manifest; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -39,9 +42,13 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.filters.ResolveFileFilter; import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; @@ -99,6 +106,16 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { @Parameter(property = "includeParents", defaultValue = "false") boolean includeParents; + @Inject + public ResolveDependenciesMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index adb87951e..3966258c0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -18,10 +18,17 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; /** * Goal that resolves the project source dependencies from the repository. @@ -38,6 +45,16 @@ public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { private static final String SOURCES_CLASSIFIER = "sources"; + @Inject + public ResolveDependencySourcesMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + @Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true) public void setClassifier(String classifier) { this.classifier = classifier; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 4a6a23782..b678b7230 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.resolvers; +import javax.inject.Inject; + import java.io.IOException; import java.util.HashSet; import java.util.LinkedHashSet; @@ -26,11 +28,14 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencyUtil; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -39,7 +44,9 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; /** @@ -62,6 +69,16 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") private boolean outputAbsoluteArtifactFilename; + @Inject + public ResolvePluginsMojo( + ResolverUtil resolverUtil, + DependencyResolver dependencyResolver, + RepositoryManager repositoryManager, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager) { + super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + } + /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. * diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index ff9197973..bb7c97d10 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -100,7 +100,7 @@ private void doTestDependencyStatusLog(Set artifacts) { } private ResolveDependenciesMojo newMojo(final DependencyStatusSets dss) { - ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(); + ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(null, null, null, null, null); mojo.results = dss; return mojo; } From 89744d06aff3b5d03d86d4f7fe5fd524304a5f2b Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 30 Dec 2024 21:10:10 +0000 Subject: [PATCH 213/283] Convert Analyze Mojos to Guice constructor injection (#499) --- .../analyze/AbstractAnalyzeMojo.java | 30 ++++++++++--------- .../dependency/analyze/AnalyzeMojo.java | 15 ++++++++-- .../dependency/analyze/AnalyzeOnlyMojo.java | 11 ++++++- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 05b9cb3c4..765b334b1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -34,7 +34,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; @@ -55,19 +54,6 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { // fields ----------------------------------------------------------------- - /** - * The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo - * configuration. - */ - @Component - private PlexusContainer plexusContainer; - - /** - * The Maven project to analyze. - */ - @Component - private MavenProject project; - /** * Specify the project dependency analyzer to use (plexus component role-hint). By default, * maven-dependency-analyzer is used. To use this, you must declare @@ -271,6 +257,22 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { @Parameter(property = "mdep.analyze.excludedClasses") private Set excludedClasses; + /** + * The plexusContainer to look up the {@link ProjectDependencyAnalyzer} implementation depending on the mojo + * configuration. + */ + private final PlexusContainer plexusContainer; + + /** + * The Maven project to analyze. + */ + private final MavenProject project; + + protected AbstractAnalyzeMojo(PlexusContainer plexusContainer, MavenProject project) { + this.plexusContainer = plexusContainer; + this.project = project; + } + // Mojo methods ----------------------------------------------------------- /* diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java index 84907bb60..1cab87532 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeMojo.java @@ -18,17 +18,21 @@ */ package org.apache.maven.plugins.dependency.analyze; +import javax.inject.Inject; + import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.PlexusContainer; /** * Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused - * and declared. This goal is intended to be used standalone, thus it always executes the test-compile - * phase - use the dependency:analyze-only goal instead when participating in the build lifecycle. + * and declared. This goal is intended to be used standalone. Thus, it always executes the test-compile + * phase. Use the dependency:analyze-only goal instead when participating in the build lifecycle. *

      - * By default, maven-dependency-analyzer is used + * By default, maven-dependency-analyzer is used * to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be * plugged in through analyzer parameter. *

      @@ -41,4 +45,9 @@ @Execute(phase = LifecyclePhase.TEST_COMPILE) public class AnalyzeMojo extends AbstractAnalyzeMojo { // subclassed to provide annotations + + @Inject + public AnalyzeMojo(PlexusContainer plexusContainer, MavenProject project) { + super(plexusContainer, project); + } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java index 43d1e3021..ba7d0ddd9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeOnlyMojo.java @@ -18,9 +18,13 @@ */ package org.apache.maven.plugins.dependency.analyze; +import javax.inject.Inject; + import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.PlexusContainer; /** * Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused @@ -28,7 +32,7 @@ * test-compile phase has been executed - use the dependency:analyze goal instead when running * standalone. *

      - * By default, maven-dependency-analyzer is used + * By default, maven-dependency-analyzer is used * to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be * plugged in through analyzer parameter. *

      @@ -46,4 +50,9 @@ // @formatter:on public class AnalyzeOnlyMojo extends AbstractAnalyzeMojo { // subclassed to provide annotations + + @Inject + public AnalyzeOnlyMojo(PlexusContainer plexusContainer, MavenProject project) { + super(plexusContainer, project); + } } From 8b74a2860e088d05132a1ec77060cbdd463afcb4 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 4 Jan 2025 22:26:09 +0000 Subject: [PATCH 214/283] [MDEP-966] Convert remaining Mojos to Guice injection (#500) * Convert Mojos to Guice constructor injection --- .../dependency/AbstractDependencyMojo.java | 50 ++++++++++--------- .../dependency/ListRepositoriesMojo.java | 9 +++- .../AbstractFromConfigurationMojo.java | 25 +++++++--- .../fromConfiguration/CopyMojo.java | 16 +++++- .../fromConfiguration/UnpackMojo.java | 16 +++++- .../AbstractDependencyFilterMojo.java | 13 ++++- .../AbstractFromDependenciesMojo.java | 20 +++++++- .../fromDependencies/BuildClasspathMojo.java | 24 +++++++-- .../CopyDependenciesMojo.java | 26 +++++++--- .../UnpackDependenciesMojo.java | 22 ++++++-- .../resolvers/AbstractResolveMojo.java | 19 ++++++- .../resolvers/CollectDependenciesMojo.java | 21 +++++++- .../dependency/resolvers/GoOfflineMojo.java | 18 ++++++- .../dependency/resolvers/ListMojo.java | 18 ++++++- .../OldResolveDependencySourcesMojo.java | 18 ++++++- .../resolvers/ResolveDependenciesMojo.java | 18 ++++++- .../ResolveDependencySourcesMojo.java | 18 ++++++- .../resolvers/ResolvePluginsMojo.java | 18 ++++++- .../AbstractDependencyMojoTest.java | 15 ++++-- .../fromConfiguration/TestCopyMojo.java | 8 +-- .../ResolveDependenciesMojoTest.java | 2 +- 21 files changed, 322 insertions(+), 72 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 45e43be16..b24e2ba6e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -26,7 +26,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.SystemStreamLog; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencySilentLog; import org.apache.maven.project.DefaultProjectBuildingRequest; @@ -39,27 +38,6 @@ */ public abstract class AbstractDependencyMojo extends AbstractMojo { - /** - * For IDE build support - */ - @Component - private BuildContext buildContext; - - /** - * Skip plugin execution only during incremental builds (e.g. triggered from M2E). - * - * @since 3.4.0 - * @see #skip - */ - @Parameter(defaultValue = "false") - private boolean skipDuringIncrementalBuild; - - /** - * POM - */ - @Component - private MavenProject project; - /** * Remote repositories which will be searched for artifacts. */ @@ -81,8 +59,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * The Maven session */ - @Component - protected MavenSession session; + protected final MavenSession session; /** * If the plugin should be silent. @@ -102,6 +79,31 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { @Parameter(property = "mdep.skip", defaultValue = "false") private boolean skip; + /** + * Skip plugin execution only during incremental builds (e.g. triggered from M2E). + * + * @since 3.4.0 + * @see #skip + */ + @Parameter(defaultValue = "false") + private boolean skipDuringIncrementalBuild; + + /** + * For IDE build support + */ + private final BuildContext buildContext; + + /** + * POM + */ + private final MavenProject project; + + protected AbstractDependencyMojo(MavenSession session, BuildContext buildContext, MavenProject project) { + this.session = session; + this.buildContext = buildContext; + this.project = project; + } + // Mojo methods ----------------------------------------------------------- /* diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index 3a0debe9c..07cd668c8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -31,9 +31,11 @@ import java.util.stream.Collectors; import org.apache.maven.RepositoryUtils; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.collection.CollectRequest; @@ -43,6 +45,7 @@ import org.eclipse.aether.graph.DependencyVisitor; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.util.graph.visitor.TreeDependencyVisitor; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that collects all project dependencies and then lists the repositories used by the build and by the transitive @@ -57,14 +60,16 @@ public class ListRepositoriesMojo extends AbstractDependencyMojo { private final RepositorySystem repositorySystem; @Inject - public ListRepositoriesMojo(RepositorySystem repositorySystem) { + public ListRepositoriesMojo( + MavenSession session, BuildContext buildContext, MavenProject project, RepositorySystem repositorySystem) { + super(session, buildContext, project); this.repositorySystem = repositorySystem; } /** * Displays a list of the repositories used by this build. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs */ @Override protected void doExecute() throws MojoExecutionException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 90ba8818b..57d6bb778 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -27,10 +27,10 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; @@ -42,6 +42,7 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of @@ -111,14 +112,24 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo @Parameter private File localRepositoryDirectory; - @Component - private ArtifactResolver artifactResolver; + private final ArtifactResolver artifactResolver; - @Component - private RepositoryManager repositoryManager; + private final RepositoryManager repositoryManager; - @Component - private ArtifactHandlerManager artifactHandlerManager; + private final ArtifactHandlerManager artifactHandlerManager; + + protected AbstractFromConfigurationMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, + ArtifactResolver artifactResolver, + RepositoryManager repositoryManager, + ArtifactHandlerManager artifactHandlerManager) { + super(session, buildContext, project); + this.artifactResolver = artifactResolver; + this.repositoryManager = repositoryManager; + this.artifactHandlerManager = artifactHandlerManager; + } abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index e9ad6d737..123e76825 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -25,6 +25,8 @@ import java.util.List; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -33,6 +35,10 @@ import org.apache.maven.plugins.dependency.utils.CopyUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that copies a list of artifacts from the repository to defined locations. @@ -82,7 +88,15 @@ public class CopyMojo extends AbstractFromConfigurationMojo { private String artifact; @Inject - public CopyMojo(CopyUtil copyUtil) { + public CopyMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, + ArtifactResolver artifactResolver, + RepositoryManager repositoryManager, + ArtifactHandlerManager artifactHandlerManager, + CopyUtil copyUtil) { + super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager); this.copyUtil = copyUtil; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 4d7be1900..9d2815cbb 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -23,6 +23,8 @@ import java.io.File; import java.util.List; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -33,7 +35,11 @@ import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugins.dependency.utils.markers.MarkerHandler; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.codehaus.plexus.components.io.filemappers.FileMapper; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location. @@ -98,7 +104,15 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { private String artifact; @Inject - public UnpackMojo(UnpackUtil unpackUtil) { + public UnpackMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, + ArtifactResolver artifactResolver, + RepositoryManager repositoryManager, + ArtifactHandlerManager artifactHandlerManager, + UnpackUtil unpackUtil) { + super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager); this.unpackUtil = unpackUtil; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 6818dfc01..99b4ca763 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.fromDependencies; +import javax.inject.Inject; + import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -27,6 +29,7 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.AbstractDependencyMojo; @@ -50,6 +53,7 @@ import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering @@ -239,23 +243,30 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj private final ArtifactHandlerManager artifactHandlerManager; + @Inject + // CHECKSTYLE_OFF: ParameterNumber protected AbstractDependencyFilterMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { + super(session, buildContext, project); this.resolverUtil = resolverUtil; this.dependencyResolver = dependencyResolver; this.repositoryManager = repositoryManager; this.projectBuilder = projectBuilder; this.artifactHandlerManager = artifactHandlerManager; } + // CHECKSTYLE_ON: ParameterNumber /** * Return an {@link ArtifactsFilter} indicating which artifacts must be filtered out. * - * @return an {@link ArtifactsFilter} indicating which artifacts must be filtered out. + * @return an {@link ArtifactsFilter} indicating which artifacts must be filtered out */ protected abstract ArtifactsFilter getMarkedArtifactFilter(); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 2e4f675fd..30516ee34 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -21,11 +21,14 @@ import java.io.File; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Abstract Parent class used by mojos that get Artifact information from the project dependencies. @@ -111,17 +114,30 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil @Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false") protected boolean failOnMissingClassifierArtifact; + // CHECKSTYLE_OFF: ParameterNumber protected AbstractFromDependenciesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber /** - * @return returns the outputDirectory + * @return returns the output directory */ public File getOutputDirectory() { return this.outputDirectory; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 2c4ef03bf..d108b1e34 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -40,6 +40,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -47,12 +48,14 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * This goal outputs a classpath string of dependencies from the local repository to a file or log. @@ -60,13 +63,11 @@ * @author ankostis * @since 2.0-alpha-2 */ -// CHECKSTYLE_OFF: LineLength @Mojo( name = "build-classpath", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -// CHECKSTYLE_ON: LineLength public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements Comparator { @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") @@ -167,16 +168,29 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements private final MavenProjectHelper projectHelper; @Inject + // CHECKSTYLE_OFF: ParameterNumber protected BuildClasspathMojo( - MavenProjectHelper projectHelper, + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, - ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + ArtifactHandlerManager artifactHandlerManager, + MavenProjectHelper projectHelper) { + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); this.projectHelper = projectHelper; } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates to create a classpath. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 1029988be..e79e991d2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -30,6 +30,7 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -40,6 +41,7 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -49,6 +51,7 @@ import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.util.artifact.SubArtifact; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that copies the files for a project's dependencies from the repository to a directory. @@ -59,13 +62,11 @@ * @author Brian Fox * @since 1.0 */ -// CHECKSTYLE_OFF: LineLength @Mojo( name = "copy-dependencies", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.PROCESS_SOURCES, threadSafe = true) -// CHECKSTYLE_ON: LineLength public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { /** * Also copy the pom of each artifact. @@ -97,18 +98,31 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { protected boolean addParentPoms; @Inject + // CHECKSTYLE_OFF: ParameterNumber public CopyDependenciesMojo( - CopyUtil copyUtil, - ArtifactInstaller installer, + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, - ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + ArtifactHandlerManager artifactHandlerManager, + CopyUtil copyUtil, + ArtifactInstaller installer) { + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); this.copyUtil = copyUtil; this.installer = installer; } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index f10da2cf3..589564fca 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -35,11 +36,13 @@ import org.apache.maven.plugins.dependency.utils.UnpackUtil; import org.apache.maven.plugins.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.codehaus.plexus.components.io.filemappers.FileMapper; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that unpacks the project dependencies from the repository to a defined location. @@ -103,16 +106,29 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { private final UnpackUtil unpackUtil; @Inject + // CHECKSTYLE_OFF: ParameterNumber public UnpackDependenciesMojo( - UnpackUtil unpackUtil, + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, - ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + ArtifactHandlerManager artifactHandlerManager, + UnpackUtil unpackUtil) { + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); this.unpackUtil = unpackUtil; } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. This method gets the dependencies and iterates through each one passing it to diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 636f410d0..434fea8bd 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -21,10 +21,12 @@ import java.io.File; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; @@ -34,6 +36,7 @@ import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * @author Brian Fox @@ -65,14 +68,27 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; + // CHECKSTYLE_OFF: ParameterNumber protected AbstractResolveMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber /** * @return {@link FilterArtifacts} @@ -81,7 +97,6 @@ protected FilterArtifacts getArtifactsFilter() { final FilterArtifacts filter = new FilterArtifacts(); if (excludeReactor) { - filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java index e99e9a471..7838d0d9a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java @@ -21,13 +21,16 @@ import javax.inject.Inject; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** *

      @@ -55,12 +58,26 @@ public class CollectDependenciesMojo extends ResolveDependenciesMojo { @Inject - public CollectDependenciesMojo( + // CHECKSTYLE_OFF: ParameterNumber + protected CollectDependenciesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber + } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index acff067e4..84242e2fa 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -31,11 +31,13 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; @@ -48,6 +50,7 @@ import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that resolves all project dependencies, including plugins and reports and their dependencies. @@ -61,14 +64,27 @@ public class GoOfflineMojo extends AbstractResolveMojo { @Inject + // CHECKSTYLE_OFF: ParameterNumber public GoOfflineMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies, resolves all that are not in the Reactor, and iterates diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java index 4d6e24cfd..81358579a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java @@ -21,12 +21,15 @@ import javax.inject.Inject; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Displays the list of dependencies for this project. @@ -38,13 +41,26 @@ public class ListMojo extends ResolveDependenciesMojo { @Inject + // CHECKSTYLE_OFF: ParameterNumber public ListMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber // alias for dependency:resolve } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java index caadd3ae9..828a5f24b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java @@ -21,13 +21,16 @@ import javax.inject.Inject; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that resolves the project source dependencies from the repository. @@ -45,12 +48,25 @@ public class OldResolveDependencySourcesMojo extends ResolveDependencySourcesMojo { @Inject + // CHECKSTYLE_OFF: ParameterNumber public OldResolveDependencySourcesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index fbf0baaa0..424d54bb8 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -35,6 +35,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -45,12 +46,14 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.filters.ResolveFileFilter; import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that resolves the project dependencies from the repository. When using this goal while running on Java 9 the @@ -107,14 +110,27 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { boolean includeParents; @Inject + // CHECKSTYLE_OFF: ParameterNumber public ResolveDependenciesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index 3966258c0..a4d4a14db 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -21,14 +21,17 @@ import javax.inject.Inject; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that resolves the project source dependencies from the repository. @@ -46,14 +49,27 @@ public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { private static final String SOURCES_CLASSIFIER = "sources"; @Inject + // CHECKSTYLE_OFF: ParameterNumber public ResolveDependencySourcesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber @Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true) public void setClassifier(String classifier) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index b678b7230..a8b53bbef 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -29,12 +29,14 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; @@ -48,6 +50,7 @@ import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.sonatype.plexus.build.incremental.BuildContext; /** * Goal that resolves all project plugins and reports and their dependencies. @@ -70,14 +73,27 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { private boolean outputAbsoluteArtifactFilename; @Inject + // CHECKSTYLE_OFF: ParameterNumber public ResolvePluginsMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super(resolverUtil, dependencyResolver, repositoryManager, projectBuilder, artifactHandlerManager); + super( + session, + buildContext, + project, + resolverUtil, + dependencyResolver, + repositoryManager, + projectBuilder, + artifactHandlerManager); } + // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java index 5c450f3d0..bb8f728da 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java @@ -25,7 +25,9 @@ import junit.framework.TestCase; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; +import org.sonatype.plexus.build.incremental.BuildContext; import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithArtifactRepositories; import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithPluginRepositories; @@ -42,11 +44,15 @@ public class AbstractDependencyMojoTest extends TestCase { private ArrayList pluginRepos = new ArrayList<>(); static class ConcreteDependencyMojo extends AbstractDependencyMojo { + + protected ConcreteDependencyMojo(MavenSession session, BuildContext buildContext, MavenProject project) { + super(session, buildContext, project); + } + static ConcreteDependencyMojo createConcreteDependencyMojoWithArtifactRepositories( MavenSession mavenSession, List artifactRepos) throws NoSuchFieldException, IllegalAccessException { - ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(); - cdm.session = mavenSession; + ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(mavenSession, null, null); Field par = AbstractDependencyMojo.class.getDeclaredField("remoteRepositories"); par.setAccessible(true); @@ -56,10 +62,9 @@ static ConcreteDependencyMojo createConcreteDependencyMojoWithArtifactRepositori } static ConcreteDependencyMojo createConcreteDependencyMojoWithPluginRepositories( - MavenSession mavenSession, List pluginRepos) + MavenSession session, List pluginRepos) throws NoSuchFieldException, IllegalAccessException { - ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(); - cdm.session = mavenSession; + ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(session, null, null); Field par = AbstractDependencyMojo.class.getDeclaredField("remotePluginRepositories"); par.setAccessible(true); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index e4831c917..1836b1d33 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -130,11 +130,11 @@ public void assertFileExists(ArtifactItem item, boolean exist) { } public void testMojoDefaults() { - CopyMojo themojo = new CopyMojo(null); + CopyMojo theMojo = new CopyMojo(null, null, null, null, null, null, null); - assertFalse(themojo.isStripVersion()); - assertFalse(themojo.isSkip()); - assertFalse(themojo.isStripClassifier()); + assertFalse(theMojo.isStripVersion()); + assertFalse(theMojo.isSkip()); + assertFalse(theMojo.isStripClassifier()); } public void testCopyFile() throws Exception { diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index bb7c97d10..c59b02542 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -100,7 +100,7 @@ private void doTestDependencyStatusLog(Set artifacts) { } private ResolveDependenciesMojo newMojo(final DependencyStatusSets dss) { - ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(null, null, null, null, null); + ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(null, null, null, null, null, null, null, null); mojo.results = dss; return mojo; } From 3bcfbc261c39e59043306e2f50a1f35af81fd9be Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 6 Jan 2025 15:42:18 +0000 Subject: [PATCH 215/283] Avoid deprecated ArtifactFactory (#489) --- .../fromDependencies/TestCopyDependenciesMojo2.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index cb852a1ec..bb554d33f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -27,7 +27,6 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; @@ -232,8 +231,6 @@ public void testRepositoryLayout() throws Exception { mojo.useRepositoryLayout = true; mojo.execute(); - ArtifactFactory artifactFactory = lookup(ArtifactFactory.class); - File outputDirectory = mojo.outputDirectory; ArtifactRepository targetRepository = new MavenArtifactRepository( "local", @@ -246,11 +243,12 @@ public void testRepositoryLayout() throws Exception { File baseDirectory = Paths.get(targetRepository.getBasedir()).toFile(); assertTrue(baseDirectory.isDirectory()); + org.apache.maven.repository.RepositorySystem repositorySystem = + lookup(org.apache.maven.repository.RepositorySystem.class); for (Artifact artifact : artifacts) { assertArtifactExists(artifact, targetRepository); - if (!artifact.getBaseVersion().equals(artifact.getVersion())) { - Artifact baseArtifact = artifactFactory.createArtifact( + Artifact baseArtifact = repositorySystem.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), From d325e1c18b70ae16db1f19223da21a3f7cd87a61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:17:57 +0000 Subject: [PATCH 216/283] Bump org.assertj:assertj-core from 3.27.0 to 3.27.2 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.0 to 3.27.2. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.0...assertj-build-3.27.2) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 462166a0c..8bad9de7c 100644 --- a/pom.xml +++ b/pom.xml @@ -369,7 +369,7 @@ under the License. org.assertj assertj-core - 3.27.0 + 3.27.2 test From 26f35e3e4fec2c38041e7ec4fa74afc88f6b1a10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:57:01 +0000 Subject: [PATCH 217/283] Bump jettyVersion from 9.4.56.v20240826 to 9.4.57.v20241219 Bumps `jettyVersion` from 9.4.56.v20240826 to 9.4.57.v20241219. Updates `org.eclipse.jetty:jetty-server` from 9.4.56.v20240826 to 9.4.57.v20241219 Updates `org.eclipse.jetty:jetty-util` from 9.4.56.v20240826 to 9.4.57.v20241219 Updates `org.eclipse.jetty:jetty-security` from 9.4.56.v20240826 to 9.4.57.v20241219 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8bad9de7c..ca49d4c69 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 3.6.3 1.4.1 1.7.36 - 9.4.56.v20240826 + 9.4.57.v20241219 4.11.0 4.10.0 3.3.0 From d6ca2bcd0391faedecb1b245f6d9ac2658bcd07f Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 8 Feb 2025 11:49:42 +0000 Subject: [PATCH 218/283] Unix file separators (#507) Most devs prefer / to \ --- src/site/apt/usage.apt.vm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 056418335..dc5ded5ad 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -153,16 +153,16 @@ mvn dependency:copy The artifacts can be placed in subfolders based on type. For example: - \outputDirectory + /outputDirectory - \outputDirectory\jars + /outputDirectory/jars - \outputDirectory\wars + /outputDirectory/wars The artifacts can be placed in a subfolder per artifact. For example: - \outputDirectory\junit-junit-3.8.1\ + /outputDirectory/junit-junit-3.8.1/ This feature also works with the subfolders per type. For example: - \outputDirectory\jars\junit-junit-3.8.1\ + /outputDirectory/jars/junit-junit-3.8.1/ Artifacts can also be resolved by specifying the classifier and optionally type. Type is only used with the classifier and defaults to java-sources. @@ -219,7 +219,7 @@ mvn dependency:copy ArtifactItem by setting the optional outputDirectory field. A single artifact can be unpacked multiple times if different include/exclude parameters - are defined for each artifactItem + are defined for each artifact item. See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled. @@ -311,16 +311,16 @@ mvn dependency:unpack The artifacts can be unpacked in subfolders based on type. For example: - \outputDirectory + /outputDirectory - \outputDirectory\jars + /outputDirectory/jars - \outputDirectory\wars + /outputDirectory/wars The artifacts can be placed in a subfolder per artifact. For example: - \outputDirectory\junit-junit-3.8.1\ + /outputDirectory/junit-junit-3.8.1/ This feature also works with the subfolders per type. For example: - \outputDirectory\jars\junit-junit-3.8.1\ + /outputDirectory/jars/junit-junit-3.8.1/ Artifacts can also be resolved by specifying the classifier and optionally type. Type is only used with the classifier and defaults to java-sources. @@ -395,7 +395,7 @@ mvn dependency:unpack * If <<>> = true, then a snapshot artifact (e.g. <<>>) will always overwrite. - * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<>> if unpacking). + * If all of the values are false, then a copy/unpack will only occur if the artifact doesn't exist in the destination (or <<>> if unpacking). From dc591cdf55304130ed2e87b7b3bae503278c2917 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 9 Feb 2025 19:17:07 +0000 Subject: [PATCH 219/283] Fix broken link for dependency:collect Fixes ##678 --- src/site/apt/index.apt.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index d987dff36..ca2507733 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -55,7 +55,7 @@ ${project.name} Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. The classpath file may also be attached and installed/deployed along with the main artifact. - *{{{./collect-dependencies-mojo.html}dependency:collect}} collects the project dependencies from the repository. + *{{{./collect-mojo.html}dependency:collect}} collects the project dependencies from the repository. It lists the groupId:artifactId:version information by downloading the pom files without downloading the actual artifacts such as jar files. From cf997f70c863fe741efd077ced8be3eedaef2535 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 10 Feb 2025 17:07:26 +0000 Subject: [PATCH 220/283] [MDEP-839] Avoid extra blank lines in file (#495) * Avoid control characters in file --- .../projects/mdep-839-list/invoker.properties | 18 +++++++ src/it/projects/mdep-839-list/pom.xml | 54 +++++++++++++++++++ src/it/projects/mdep-839-list/test.properties | 19 +++++++ src/it/projects/mdep-839-list/verify.groovy | 28 ++++++++++ .../resolvers/ResolveDependenciesMojo.java | 12 +++-- 5 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 src/it/projects/mdep-839-list/invoker.properties create mode 100644 src/it/projects/mdep-839-list/pom.xml create mode 100644 src/it/projects/mdep-839-list/test.properties create mode 100644 src/it/projects/mdep-839-list/verify.groovy diff --git a/src/it/projects/mdep-839-list/invoker.properties b/src/it/projects/mdep-839-list/invoker.properties new file mode 100644 index 000000000..55afe77c1 --- /dev/null +++ b/src/it/projects/mdep-839-list/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:list diff --git a/src/it/projects/mdep-839-list/pom.xml b/src/it/projects/mdep-839-list/pom.xml new file mode 100644 index 000000000..f6cd86069 --- /dev/null +++ b/src/it/projects/mdep-839-list/pom.xml @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:list-repositories + + + + UTF-8 + + + + + fake-remote-repository + http://localhost:2345 + + + + + + org.apache.maven + maven-core + 3.9.9 + + + + \ No newline at end of file diff --git a/src/it/projects/mdep-839-list/test.properties b/src/it/projects/mdep-839-list/test.properties new file mode 100644 index 000000000..406dd9aba --- /dev/null +++ b/src/it/projects/mdep-839-list/test.properties @@ -0,0 +1,19 @@ +# 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. + +outputFile = classpath.txt + diff --git a/src/it/projects/mdep-839-list/verify.groovy b/src/it/projects/mdep-839-list/verify.groovy new file mode 100644 index 000000000..50cd4ea0f --- /dev/null +++ b/src/it/projects/mdep-839-list/verify.groovy @@ -0,0 +1,28 @@ +/* + * 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. + */ + +File file = new File( basedir, "classpath.txt" ) +assert file.exists() : "output file $file does not exist" + +String output = file.getText( "UTF-8" ) +assert output.startsWith( 'The following files have been resolved:') +// no escape codes +assert !output.contains( '\u001B' ) + + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 424d54bb8..d326bda2c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -175,7 +175,9 @@ protected ArtifactsFilter getMarkedArtifactFilter() { */ public String getOutput(boolean outputAbsoluteArtifactFilename, boolean theOutputScope, boolean theSort) { StringBuilder sb = new StringBuilder(); - sb.append(System.lineSeparator()); + if (outputFile == null) { + sb.append(System.lineSeparator()); + } sb.append("The following files have been resolved:"); sb.append(System.lineSeparator()); if (results.getResolvedDependencies() == null @@ -215,9 +217,13 @@ private StringBuilder buildArtifactListOutput( Set artifacts, boolean outputAbsoluteArtifactFilename, boolean theOutputScope, boolean theSort) { StringBuilder sb = new StringBuilder(); List artifactStringList = new ArrayList<>(); + /* if (outputFile != null) { + MessageUtils.setColorEnabled(false); + } else { + MessageUtils.setColorEnabled(true); + } */ for (Artifact artifact : artifacts) { MessageBuilder messageBuilder = MessageUtils.buffer(); - messageBuilder.a(" "); if (theOutputScope) { @@ -257,7 +263,7 @@ private StringBuilder buildArtifactListOutput( } } } - artifactStringList.add(messageBuilder + System.lineSeparator()); + artifactStringList.add(messageBuilder.build() + System.lineSeparator()); } if (theSort) { Collections.sort(artifactStringList); From e60871921eb22fc1e459badda6d0356f5b00b10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sat, 8 Feb 2025 13:50:13 +0100 Subject: [PATCH 221/283] Drop unnecessary call --- .../plugins/dependency/AbstractDependencyMojoTestCase.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index fc8eacc05..6ac6ff227 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -51,9 +51,6 @@ protected void setUp(String testDirStr, boolean createFiles, boolean flattenedPa // required for mojo lookups to work super.setUp(); - testDir = new File( - getBasedir(), - "target" + File.separatorChar + "unit-tests" + File.separatorChar + testDirStr + File.separatorChar); testDir = Files.createTempDirectory("testDirStr").toFile(); testDir.deleteOnExit(); From 3cd7c36b82a85bb0aab9dbe1a49110aab317705c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sat, 8 Feb 2025 14:10:35 +0100 Subject: [PATCH 222/283] Keep files in temporary directory to be deleted after test --- .../maven/plugins/dependency/tree/TestTreeMojo.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index ad096f036..b336afd24 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -160,7 +160,7 @@ public void testTreeTGFSerializing() throws Exception { * Test the JSON format serialization on DependencyNodes with circular dependence */ public void testTreeJsonCircularDependency() throws IOException { - String outputFileName = testDir.getAbsolutePath() + "tree1.json"; + String outputFileName = testDir.getAbsolutePath() + File.separator + "tree1.json"; File outputFile = new File(outputFileName); Files.createDirectories(outputFile.getParentFile().toPath()); outputFile.createNewFile(); @@ -176,10 +176,11 @@ public void testTreeJsonCircularDependency() throws IOException { node1.getChildren().add(node2); node2.getChildren().add(node1); - JsonDependencyNodeVisitor jsonDependencyNodeVisitor = - new JsonDependencyNodeVisitor(new OutputStreamWriter(new FileOutputStream(outputFile))); + try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(outputFile))) { + JsonDependencyNodeVisitor jsonDependencyNodeVisitor = new JsonDependencyNodeVisitor(outputStreamWriter); - jsonDependencyNodeVisitor.visit(node1); + jsonDependencyNodeVisitor.visit(node1); + } } /* @@ -239,7 +240,7 @@ public void testTreeJsonParsing() throws Exception { */ private List runTreeMojo(String outputFile, String format) throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml"); - Path outputFilePath = Paths.get(testDir.getAbsolutePath() + outputFile); + Path outputFilePath = Paths.get(testDir.getAbsolutePath(), outputFile); TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom); setVariableValueToObject(mojo, "outputEncoding", "UTF-8"); setVariableValueToObject(mojo, "outputType", format); From 40a1e1fe2893f751e2584fde4c1648b41076828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCnger?= Date: Sat, 15 Feb 2025 19:23:10 +0100 Subject: [PATCH 223/283] [MNGSITE-529] Rename "Goals" to "Plugin Documentation" --- src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index 790d3d42b..16a0738d1 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -24,7 +24,7 @@ under the License.

      - + From 89914e6814866808b3a91429482bb54b2062d63a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 24 Feb 2025 18:29:38 +0000 Subject: [PATCH 224/283] Enable tests (#512) --- .../plugins/dependency/utils/filters/TestMarkerFileFilter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java index beec00806..448279da1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/filters/TestMarkerFileFilter.java @@ -65,6 +65,7 @@ public void testMarkerFile() throws ArtifactFilterException { assertEquals(2, result.size()); } + @Test public void testMarkerSnapshots() throws ArtifactFilterException, MojoExecutionException, IOException { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(fact.getSnapshotArtifact(), outputFolder); handler.setMarker(); @@ -79,6 +80,7 @@ public void testMarkerSnapshots() throws ArtifactFilterException, MojoExecutionE assertTrue(handler.clearMarker()); } + @Test public void testMarkerRelease() throws IOException, ArtifactFilterException, MojoExecutionException { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(fact.getReleaseArtifact(), outputFolder); handler.setMarker(); From 9a10ac47584ceb0933e36e00bde6d13164c328c5 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 24 Feb 2025 20:20:03 +0100 Subject: [PATCH 225/283] Add PR Automation and Stale actions --- .github/release-drafter.yml | 2 +- .github/workflows/pr-automation.yml | 27 +++++++++++++++++++++++++++ .github/workflows/stale.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-automation.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index f8dfd76b8..9b801fc6b 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -18,4 +18,4 @@ # under the License. _extends: maven-gh-actions-shared -tag-template: maven-dependency-plugin-$NEXT_MINOR_VERSION +tag-template: maven-dependency-plugin-$RESOLVED_VERSION diff --git a/.github/workflows/pr-automation.yml b/.github/workflows/pr-automation.yml new file mode 100644 index 000000000..530759572 --- /dev/null +++ b/.github/workflows/pr-automation.yml @@ -0,0 +1,27 @@ +# 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. + +name: PR Automation +on: + pull_request_target: + types: + - closed + +jobs: + pr-automation: + name: PR Automation + uses: apache/maven-gh-actions-shared/.github/workflows/pr-automation.yml@v4 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..85ae8637d --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,28 @@ +# 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. + +name: Stale + +on: + schedule: + - cron: '16 3 * * *' + issue_comment: + types: [ 'created' ] + +jobs: + stale: + uses: 'apache/maven-gh-actions-shared/.github/workflows/stale.yml@v4' From 96a660f1aafcf119fdcd9d68cfa0970db27b68b1 Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 26 Feb 2025 13:59:19 +0800 Subject: [PATCH 226/283] * Add additional comment to clarify the minimal supported version of outputing dependency tree in JSON fromat. --- .../java/org/apache/maven/plugins/dependency/tree/TreeMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index 3a49f6336..b21f74890 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -105,7 +105,7 @@ public class TreeMojo extends AbstractMojo { /** * If specified, this parameter will cause the dependency tree to be written using the specified format. Currently * supported formats are: text (default), dot, graphml, tgf - * and json. + * and json (since 3.7.0). * These additional formats can be plotted to image files. * * @since 2.2 From 377115aadb72aa2a8b11a6d2fea7708adad9eafb Mon Sep 17 00:00:00 2001 From: Tayebwa Noah Date: Tue, 25 Mar 2025 11:20:36 +0300 Subject: [PATCH 227/283] [MDEP-972] copy-dependencies: copy signatures alongside artifacts (#514) --- pom.xml | 11 ++++ .../CopyDependenciesMojo.java | 51 ++++++++++++++++ .../plugins/dependency/utils/CopyUtil.java | 15 +++++ .../TestCopyDependenciesMojo.java | 60 +++++++++++++++++++ 4 files changed, 137 insertions(+) diff --git a/pom.xml b/pom.xml index ca49d4c69..f792a94db 100644 --- a/pom.xml +++ b/pom.xml @@ -405,6 +405,17 @@ under the License. ${slf4jVersion} test + + org.apache.maven.resolver + maven-resolver-api + 1.9.22 + provided + + + org.apache.maven.resolver + maven-resolver-util + 1.9.22 + diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index e79e991d2..0d6eb7d73 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -97,6 +97,14 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { @Parameter(property = "mdep.addParentPoms", defaultValue = "false") protected boolean addParentPoms; + /** + * Also copy the signature files (.asc) of each artifact. + * + * @since 3.2.0 + */ + @Parameter(property = "mdep.copySignatures", defaultValue = "false") + protected boolean copySignatures; + @Inject // CHECKSTYLE_OFF: ParameterNumber public CopyDependenciesMojo( @@ -240,6 +248,8 @@ protected void copyArtifact( * @see CopyUtil#copyArtifactFile(Artifact, File) * @see DependencyUtil#getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact) */ + private static final String SIGNATURE_EXTENSION = ".asc"; + protected void copyArtifact( Artifact artifact, boolean removeVersion, @@ -266,12 +276,53 @@ protected void copyArtifact( } try { copyUtil.copyArtifactFile(artifact, destFile); + + // Copy the signature file if the copySignatures flag is true + if (copySignatures) { + copySignatureFile(artifact, destDir, destFileName); + } + } catch (IOException e) { throw new MojoExecutionException( "Failed to copy artifact '" + artifact + "' (" + artifact.getFile() + ") to " + destFile, e); } } + /** + * Copies the signature file of the artifact to the destination directory, if it exists or can be resolved. + * If the signature file does not exist and cannot be resolved, a warning is logged. + * @param artifact the artifact whose signature file should be copied + * @param destDir the destination directory + * @param destFileName the destination file name without the extension + */ + private void copySignatureFile(Artifact artifact, File destDir, String destFileName) { + File signatureFile = new File(artifact.getFile().getAbsolutePath() + SIGNATURE_EXTENSION); + + if (!signatureFile.exists()) { + try { + org.eclipse.aether.artifact.Artifact aArtifact = RepositoryUtils.toArtifact(artifact); + org.eclipse.aether.artifact.Artifact aSignatureArtifact = + new SubArtifact(aArtifact, null, "jar" + SIGNATURE_EXTENSION); + org.eclipse.aether.artifact.Artifact resolvedSignature = getResolverUtil() + .resolveArtifact(aSignatureArtifact, getProject().getRemoteProjectRepositories()); + signatureFile = resolvedSignature.getFile(); + } catch (ArtifactResolutionException e) { + getLog().warn("Failed to resolve signature file for artifact: " + artifact, e); + } + } + + if (signatureFile != null && signatureFile.exists()) { + File signatureDestFile = new File(destDir, destFileName + SIGNATURE_EXTENSION); + try { + copyUtil.copyFile(signatureFile, signatureDestFile); + } catch (IOException e) { + getLog().warn("Failed to copy signature file: " + signatureFile, e); + } + } else { + getLog().warn("Signature file for artifact " + artifact + " not found and could not be resolved."); + } + } + /** * Copy the pom files associated with the artifacts. * diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java index f83bb15cf..28b5cc31a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -72,4 +72,19 @@ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws I FileUtils.copyFile(source, destination); buildContext.refresh(destination); } + + /** + * Copies a file to a destination and refreshes the build context for the new file. + * + * @param source the source file to copy + * @param destination the destination file + * @throws IOException if copy has failed + * + * @since 3.2.0 + */ + public void copyFile(File source, File destination) throws IOException { + logger.debug("Copying file '{}' to {}", source, destination); + FileUtils.copyFile(source, destination); + buildContext.refresh(destination); + } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index ff2d42619..36e85399b 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -101,6 +101,66 @@ public void testCopyArtifactFile() throws Exception { assertTrue(dest.exists()); } + /** + * Tests the copying of signature files associated with artifacts. + * + * @throws Exception if an error occurs during the test + */ + public void testCopySignatureFiles() throws Exception { + // Enable the copySignatures parameter + mojo.copySignatures = true; + + if (!mojo.outputDirectory.exists()) { + assertTrue("Failed to create output directory", mojo.outputDirectory.mkdirs()); + } + + File sourceDirectory = + new File(System.getProperty("java.io.tmpdir"), "test-source-" + System.currentTimeMillis()); + if (!sourceDirectory.exists()) { + assertTrue("Failed to create source directory", sourceDirectory.mkdirs()); + } + + File artifactFile = new File(sourceDirectory, "maven-dependency-plugin-1.0.jar"); + if (!artifactFile.getParentFile().exists()) { + assertTrue( + "Failed to create parent directory", + artifactFile.getParentFile().mkdirs()); + } + if (artifactFile.exists()) { + assertTrue("Failed to delete existing artifact file", artifactFile.delete()); + } + assertTrue("Failed to create artifact file", artifactFile.createNewFile()); + + File signatureFile = new File(sourceDirectory, "maven-dependency-plugin-1.0.jar.asc"); + if (!signatureFile.getParentFile().exists()) { + assertTrue( + "Failed to create parent directory", + signatureFile.getParentFile().mkdirs()); + } + if (signatureFile.exists()) { + assertTrue("Failed to delete existing signature file", signatureFile.delete()); + } + assertTrue("Failed to create signature file", signatureFile.createNewFile()); + + Artifact artifact = stubFactory.createArtifact( + "org.apache.maven.plugins", "maven-dependency-plugin", "1.0", Artifact.SCOPE_COMPILE); + artifact.setFile(artifactFile); + + Set artifacts = new HashSet<>(); + artifacts.add(artifact); + mojo.getProject().setArtifacts(artifacts); + + mojo.execute(); + + File copiedSignatureFile = new File(mojo.outputDirectory, "maven-dependency-plugin-1.0.jar.asc"); + assertTrue("Signature file was not copied", copiedSignatureFile.exists()); + + // Clean up + artifactFile.delete(); + signatureFile.delete(); + sourceDirectory.delete(); + } + /** * Tests the proper discovery and configuration of the mojo. * From 1ce317c873447c4e5b90b4aef037fce66771f4f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:55:11 +0200 Subject: [PATCH 228/283] Bump org.apache.maven.plugins:maven-plugins from 43 to 44 (#516) * Bump org.apache.maven.plugins:maven-plugins from 43 to 44 Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 43 to 44. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits/v44) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Fix checkstyle in tests --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Slawomir Jaranowski --- pom.xml | 3 +- .../plugins/dependency/TestCollectMojo.java | 2 +- .../TestIncludeExcludeUnpackMojo.java | 8 ++--- ...tIncludeExcludeUnpackDependenciesMojo.java | 8 ++--- .../TestUnpackDependenciesMojo.java | 5 +-- .../TestUnpackDependenciesMojo2.java | 5 +-- .../resolvers/GoOfflineMojoTest.java | 36 +++++++++---------- 7 files changed, 35 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index f792a94db..cd9a56bec 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 43 + 44 @@ -254,6 +254,7 @@ under the License. org.apache.maven.plugin-tools maven-plugin-annotations + ${version.maven-plugin-tools} provided diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 9e86c813a..71fb6a03c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -74,7 +74,7 @@ public void testCollectTestEnvironment() throws Exception { * * @throws Exception if a problem occurs */ - public void testCollectTestEnvironment_excludeTransitive() throws Exception { + public void testCollectTestEnvironmentExcludeTransitive() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml"); CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 02c3644c8..c930cda29 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -33,13 +33,13 @@ import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase { - private final String PACKED_FILE = "test.zip"; + private static final String PACKED_FILE = "test.zip"; - private final String UNPACKED_FILE_PREFIX = "test"; + private static final String UNPACKED_FILE_PREFIX = "test"; - private final String UNPACKED_FILE_SUFFIX = ".txt"; + private static final String UNPACKED_FILE_SUFFIX = ".txt"; - private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; + private static final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; private UnpackMojo mojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 0617b8755..e59b042e9 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -28,13 +28,13 @@ import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { - private final String PACKED_FILE = "test.zip"; + private static final String PACKED_FILE = "test.zip"; - private final String UNPACKED_FILE_PREFIX = "test"; + private static final String UNPACKED_FILE_PREFIX = "test"; - private final String UNPACKED_FILE_SUFFIX = ".txt"; + private static final String UNPACKED_FILE_SUFFIX = ".txt"; - private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; + private static final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; private UnpackDependenciesMojo mojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 9c913e2ae..1ad120f46 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -43,9 +43,10 @@ public class TestUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { - private final String UNPACKABLE_FILE = "test.txt"; + private static final String UNPACKABLE_FILE = "test.txt"; - private final String UNPACKABLE_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + UNPACKABLE_FILE; + private static final String UNPACKABLE_FILE_PATH = + "target/test-classes/unit/unpack-dependencies-test/" + UNPACKABLE_FILE; UnpackDependenciesMojo mojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 27e43c9fc..85d85e117 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -36,9 +36,10 @@ public class TestUnpackDependenciesMojo2 extends AbstractDependencyMojoTestCase { - private final String UNPACKABLE_FILE = "test.txt"; + private static final String UNPACKABLE_FILE = "test.txt"; - private final String UNPACKABLE_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + UNPACKABLE_FILE; + private static final String UNPACKABLE_FILE_PATH = + "target/test-classes/unit/unpack-dependencies-test/" + UNPACKABLE_FILE; private UnpackDependenciesMojo mojo; diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java index caa00f160..af3938585 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java @@ -44,19 +44,19 @@ protected void setUp() throws Exception { getContainer().addComponent(session, MavenSession.class.getName()); } - String GROUP_EXCLUDE_PREFIX = "skip.this.groupid"; + private static final String GROUP_EXCLUDE_PREFIX = "skip.this.groupid"; - String ARTIFACT_EXCLUDE_PREFIX = "skip-this-artifact"; + private static final String ARTIFACT_EXCLUDE_PREFIX = "skip-this-artifact"; - String CLASSIFIER_EXCLUDE_PREFIX = "skipThisClassifier"; + private static final String CLASSIFIER_EXCLUDE_PREFIX = "skipThisClassifier"; - String DUMMY_ARTIFACT_NAME = "dummy-artifact"; + private static final String DUMMY_ARTIFACT_NAME = "dummy-artifact"; - String STUB_ARTIFACT_VERSION = "3.14"; + private static final String STUB_ARTIFACT_VERSION = "3.14"; - String VALID_GROUP = "org.junit.jupiter"; + private static final String VALID_GROUP = "org.junit.jupiter"; - public void test_excludeGroupIds() throws Exception { + public void testExcludeGroupIds() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -91,7 +91,7 @@ public void test_excludeGroupIds() throws Exception { assertFalse(artifacts.contains(artifact2)); } - public void test_excludeArtifactIds() throws Exception { + public void testExcludeArtifactIds() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -126,7 +126,7 @@ public void test_excludeArtifactIds() throws Exception { assertFalse(artifacts.contains(artifact2)); } - public void test_excludeScope() throws Exception { + public void testExcludeScope() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -162,7 +162,7 @@ public void test_excludeScope() throws Exception { assertFalse(artifacts.contains(artifact2)); } - public void test_excludeTypes() throws Exception { + public void testExcludeTypes() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -208,7 +208,7 @@ public void test_excludeTypes() throws Exception { * @throws Exception */ @Disabled("Requires update to maven-plugin-test-harness to support this test") - public void xtest_excludeClassifiers() throws Exception { + public void xtestExcludeClassifiers() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/exclude-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -245,13 +245,13 @@ public void xtest_excludeClassifiers() throws Exception { assertTrue(artifacts.contains(artifact3)); } - String GROUP_INCLUDE_PREFIX = "include.this.groupid"; + private static final String GROUP_INCLUDE_PREFIX = "include.this.groupid"; - String ARTIFACT_INCLUDE_PREFIX = "include-this-artifact"; + private static final String ARTIFACT_INCLUDE_PREFIX = "include-this-artifact"; - String CLASSIFIER_INCLUDE_PREFIX = "includeThisClassifier"; + private static final String CLASSIFIER_INCLUDE_PREFIX = "includeThisClassifier"; - public void test_includeGroupIds() throws Exception { + public void testIncludeGroupIds() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-gid-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -287,7 +287,7 @@ public void test_includeGroupIds() throws Exception { assertTrue(artifacts.contains(artifact2)); } - public void test_includeArtifactIds() throws Exception { + public void testIncludeArtifactIds() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-aid-plugin-config.xml"); subject = (GoOfflineMojo) lookupMojo("go-offline", testPom); @@ -323,7 +323,7 @@ public void test_includeArtifactIds() throws Exception { assertTrue(artifacts.contains(artifact2)); } - public void test_includeScope() throws Exception { + public void testIncludeScope() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-scope-plugin-config.xml"); @@ -363,7 +363,7 @@ public void test_includeScope() throws Exception { assertFalse(artifacts.contains(artifact3)); } - public void test_includeTypes() throws Exception { + public void testIncludeTypes() throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/go-offline-test/include-types-plugin-config.xml"); From fdbcfb4e8d1aa91ab7310a52323043576a43311a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 18 Apr 2025 21:05:40 +0000 Subject: [PATCH 229/283] Clean up test teardown and temp directories (#518) * Clean up test teardown and temp directories * assertNotEquals * avoid gc --- .../AbstractDependencyMojoTestCase.java | 18 +++++++----------- .../TestIncludeExcludeUnpackMojo.java | 9 +-------- ...stIncludeExcludeUnpackDependenciesMojo.java | 9 +-------- .../TestUnpackDependenciesMojo.java | 7 ------- .../TestUnpackDependenciesMojo2.java | 17 +++++------------ 5 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 6ac6ff227..9681f242e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -43,31 +43,27 @@ public abstract class AbstractDependencyMojoTestCase extends AbstractMojoTestCas protected DependencyArtifactStubFactory stubFactory; - protected void setUp(String testDirStr, boolean createFiles) throws Exception { - setUp(testDirStr, createFiles, true); + protected void setUp(String testDirectoryName, boolean createFiles) throws Exception { + setUp(testDirectoryName, createFiles, true); } - protected void setUp(String testDirStr, boolean createFiles, boolean flattenedPath) throws Exception { + protected void setUp(String testDirectoryName, boolean createFiles, boolean flattenedPath) throws Exception { // required for mojo lookups to work super.setUp(); - testDir = Files.createTempDirectory("testDirStr").toFile(); + testDir = Files.createTempDirectory(testDirectoryName).toFile(); testDir.deleteOnExit(); stubFactory = new DependencyArtifactStubFactory(this.testDir, createFiles, flattenedPath); } @Override - protected void tearDown() { + protected void tearDown() throws Exception { if (testDir != null) { - try { - FileUtils.deleteDirectory(testDir); - } catch (IOException e) { - e.printStackTrace(); - fail("Trying to remove directory: " + testDir + System.lineSeparator() + e); - } + FileUtils.deleteDirectory(testDir); assertFalse(testDir.exists()); } + super.tearDown(); } protected void copyArtifactFile(Artifact sourceArtifact, File destFile) throws MojoExecutionException, IOException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index c930cda29..e72e30a1f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -57,7 +57,7 @@ protected void setUp() throws Exception { mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); - // i'm using one file repeatedly to archive so I can test the name + // I'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + PACKED_FILE_PATH)); Artifact artifact = stubFactory.createArtifact("test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null); @@ -75,13 +75,6 @@ protected void setUp() throws Exception { installLocalRepository(legacySupport); } - protected void tearDown() { - super.tearDown(); - - mojo = null; - System.gc(); - } - public void assertMarkerFiles(Collection items, boolean exist) { for (ArtifactItem item : items) { assertMarkerFile(exist, item); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index e59b042e9..675e48e37 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -54,7 +54,7 @@ protected void setUp() throws Exception { // it needs to get the archivermanager // stubFactory.setUnpackableFile( mojo.getArchiverManager() ); - // i'm using one file repeatedly to archive so I can test the name + // I'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile(new File(getBasedir() + File.separatorChar + PACKED_FILE_PATH)); @@ -70,13 +70,6 @@ protected void setUp() throws Exception { mojo.markersDirectory = new File(this.testDir, "markers"); } - protected void tearDown() { - super.tearDown(); - - mojo = null; - System.gc(); - } - private void assertUnpacked(boolean unpacked, String fileName) { File destFile = new File(mojo.getOutputDirectory().getAbsolutePath(), fileName); assertEquals(unpacked, destFile.exists()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 1ad120f46..4f66e6d61 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -92,13 +92,6 @@ protected void setUp() throws Exception { setVariableValueToObject(mojo, "artifactHandlerManager", manager); } - protected void tearDown() { - super.tearDown(); - - mojo = null; - System.gc(); - } - public void assertUnpacked(Artifact artifact) { assertUnpacked(true, artifact); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 85d85e117..8f576da41 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -34,6 +34,8 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; +import static org.junit.Assert.assertNotEquals; + public class TestUnpackDependenciesMojo2 extends AbstractDependencyMojoTestCase { private static final String UNPACKABLE_FILE = "test.txt"; @@ -74,13 +76,6 @@ protected void setUp() throws Exception { mojo.markersDirectory = new File(this.testDir, "markers"); } - protected void tearDown() { - super.tearDown(); - - mojo = null; - System.gc(); - } - public File getUnpackedFile(Artifact artifact) { File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), @@ -204,7 +199,7 @@ public void testOverWriteIfNewer() assertEquals(time, unpackedFile.lastModified()); mojo.execute(); - System.gc(); + // make sure it didn't overwrite assertEquals(time, unpackedFile.lastModified()); @@ -212,9 +207,7 @@ public void testOverWriteIfNewer() mojo.execute(); - assertTrue(time != unpackedFile.lastModified()); - - System.gc(); + assertNotEquals(time, unpackedFile.lastModified()); } public void assertUnpacked(Artifact artifact, boolean overWrite) @@ -234,7 +227,7 @@ public void assertUnpacked(Artifact artifact, boolean overWrite) mojo.execute(); if (overWrite) { - assertTrue(time != unpackedFile.lastModified()); + assertNotEquals(time, unpackedFile.lastModified()); } else { assertEquals(time, unpackedFile.lastModified()); } From 8d7cd8085df12880d8fe9c564a25d1cb131d52e5 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 18 Apr 2025 21:06:11 +0000 Subject: [PATCH 230/283] Remove redundant/unneeded code (#519) --- .../dependency/analyze/AbstractAnalyzeMojo.java | 17 +++++------------ .../AbstractFromConfigurationMojo.java | 4 ++-- .../resolvers/ResolvePluginsMojo.java | 2 +- .../tree/JsonDependencyNodeVisitor.java | 2 +- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 765b334b1..b88675377 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -383,7 +383,7 @@ private boolean checkDependencies() throws MojoExecutionException { logDependencyWarning("Used undeclared dependencies found:"); if (verbose) { - logArtifacts(usedUndeclaredWithClasses, true); + logArtifacts(usedUndeclaredWithClasses); } else { logArtifacts(usedUndeclaredWithClasses.keySet(), true); } @@ -464,7 +464,7 @@ private void logArtifacts(Set artifacts, boolean warn) { } } - private void logArtifacts(Map> artifacts, boolean warn) { + private void logArtifacts(Map> artifacts) { if (artifacts.isEmpty()) { getLog().info(" None"); } else { @@ -472,16 +472,9 @@ private void logArtifacts(Map> artifacts, boolean warn) { // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961 entry.getKey().isSnapshot(); - if (warn) { - logDependencyWarning(" " + entry.getKey()); - for (String clazz : entry.getValue()) { - logDependencyWarning(" class " + clazz); - } - } else { - getLog().info(" " + entry.getKey()); - for (String clazz : entry.getValue()) { - getLog().info(" class " + clazz); - } + logDependencyWarning(" " + entry.getKey()); + for (String clazz : entry.getValue()) { + logDependencyWarning(" class " + clazz); } } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 57d6bb778..f848c98d5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -162,7 +162,7 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque boolean removeClassifier = processArtifactItemsRequest.isRemoveClassifier(); - if (artifactItems == null || artifactItems.size() < 1) { + if (artifactItems == null || artifactItems.isEmpty()) { throw new MojoExecutionException("There are no artifactItems configured."); } @@ -182,7 +182,7 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque artifactItem.setArtifact(this.getArtifact(artifactItem)); if (artifactItem.getDestFileName() == null - || artifactItem.getDestFileName().length() == 0) { + || artifactItem.getDestFileName().isEmpty()) { artifactItem.setDestFileName(DependencyUtil.getFormattedFileName( artifactItem.getArtifact(), removeVersion, prependGroupId, useBaseVersion, removeClassifier)); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index a8b53bbef..4119af06c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -110,7 +110,7 @@ protected void doExecute() throws MojoExecutionException { sb.append(System.lineSeparator()); sb.append("The following plugins have been resolved:"); sb.append(System.lineSeparator()); - if (plugins == null || plugins.isEmpty()) { + if (plugins.isEmpty()) { sb.append(" none"); sb.append(System.lineSeparator()); } else { diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java index 52fd180b4..015ce1b2d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java @@ -56,7 +56,7 @@ public boolean visit(DependencyNode node) { * @param node the node to write */ private void writeRootNode(DependencyNode node) { - Set visited = new HashSet(); + Set visited = new HashSet<>(); int indent = 2; StringBuilder sb = new StringBuilder(); sb.append("{").append("\n"); From 1d153083099ded252fc466efed1184e615935536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCnger?= Date: Sat, 19 Apr 2025 12:03:34 +0200 Subject: [PATCH 231/283] Fix broken link on analyze-exclusions-mojo (#521) There were actual two links for the same goal, one with the correct link, but at the bottom of the page. The broken one was added later in "alphabetical correct" position. I fixed the one at the top where it belongs and removed the one at the bottom with --- src/site/apt/index.apt.vm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index ca2507733..34cf45edc 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -40,7 +40,7 @@ ${project.name} *{{{./analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes the project's dependencies and lists mismatches between resolved dependencies and those listed in your dependencyManagement section. - *{{{./analyze-exclusions.html}dependency:analyze-exclusions}} analyzes the exclusions on dependencies and checks if the artifact actually brings in the given dependency. + *{{{./analyze-exclusions-mojo.html}dependency:analyze-exclusions}} analyzes the exclusions on dependencies and checks if the artifact actually brings in the given dependency. *{{{./analyze-only-mojo.html}dependency:analyze-only}} is the same as analyze, but is meant to be bound in a pom. It does not fork the build and execute test-compile. @@ -106,8 +106,6 @@ ${project.name} *{{{./unpack-dependencies-mojo.html}dependency:unpack-dependencies}} like copy-dependencies but unpacks. - *{{{./analyze-exclusions-mojo.html}dependency:analyze-exclusions}} displays invalid exclusions for this project. - [] * Usage From ae0efacbfa6a8d0c209019a7c02a0e8d3bbaf0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCnger?= Date: Fri, 25 Apr 2025 17:09:17 +0200 Subject: [PATCH 232/283] Enable GH issues (#522) --- .asf.yaml | 3 ++ .github/ISSUE_TEMPLATE/BUG.yml | 48 +++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/FEATURE.yml | 35 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 30 +++++++++++++++++ .github/pull_request_template.md | 32 ++++++++---------- .github/release-drafter.yml | 1 - .github/workflows/release-drafter.yml | 1 + README.md | 25 +++----------- pom.xml | 4 +-- 9 files changed, 136 insertions(+), 43 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/BUG.yml create mode 100644 .github/ISSUE_TEMPLATE/FEATURE.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.asf.yaml b/.asf.yaml index 4110a1d10..bde27bc8b 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -30,6 +30,9 @@ github: rebase: true autolink_jira: - MDEP + del_branch_on_merge: true + features: + issues: true notifications: commits: commits@maven.apache.org issues: issues@maven.apache.org diff --git a/.github/ISSUE_TEMPLATE/BUG.yml b/.github/ISSUE_TEMPLATE/BUG.yml new file mode 100644 index 000000000..699181ff1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG.yml @@ -0,0 +1,48 @@ +# +# 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. +# + +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema + +name: Bug Report +description: File a bug report +labels: ["bug"] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report. + + Simple fixes in single PRs do not require issues. + + **Do you use the latest project version?** + + - type: input + id: version + attributes: + label: Affected version + validations: + required: true + + - type: textarea + id: message + attributes: + label: Bug description + validations: + required: true + + diff --git a/.github/ISSUE_TEMPLATE/FEATURE.yml b/.github/ISSUE_TEMPLATE/FEATURE.yml new file mode 100644 index 000000000..ddfd1a45e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE.yml @@ -0,0 +1,35 @@ +# +# 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. +# + +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema + +name: Feature request +description: File a proposal for new feature, improvement +labels: ["enhancement"] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this new feature, improvement proposal. + + - type: textarea + id: message + attributes: + label: New feature, improvement proposal + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..2d19a3e38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,30 @@ +# +# 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. +# + +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser + +blank_issues_enabled: false + +contact_links: + + - name: Project Mailing Lists + url: https://maven.apache.org/mailing-lists.html + about: Please ask a question or discuss here + + - name: Old JIRA Issues + url: https://issues.apache.org/jira/projects/MDEP + about: Please search old JIRA issues diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fd85bb33f..51e18bc14 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,29 +1,23 @@ -Following this checklist to help us incorporate your +Following this checklist to help us incorporate your contribution quickly and easily: - - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MDEP) filed - for the change (usually before you start working on it). Trivial changes like typos do not - require a JIRA issue. Your pull request should address just this issue, without - pulling in other changes. - - [ ] Each commit in the pull request should have a meaningful subject line and body. - - [ ] Format the pull request title like `[MDEP-XXX] - Fixes bug in ApproximateQuantiles`, - where you replace `MDEP-XXX` with the appropriate JIRA issue. Best practice - is to use the JIRA issue title in the pull request title and in the first line of the - commit message. - - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will - be performed on your pull request automatically. - - [ ] You have run the integration tests successfully (`mvn -Prun-its clean verify`). +- [ ] Your pull request should address just one issue, without pulling in other changes. +- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. +- [ ] Each commit in the pull request should have a meaningful subject line and body. + Note that commits might be squashed by a maintainer on merge. +- [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. + This may not always be possible but is a best-practice. +- [ ] Run `mvn verify` to make sure basic checks pass. + A more thorough check will be performed on your pull request automatically. +- [ ] You have run the integration tests successfully (`mvn -Prun-its verify`). If your pull request is about ~20 lines of code you don't need to sign an [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure please ask on the developers list. -To make clear that you license your contribution under +To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. - - [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) - - - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). - +- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) +- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 9b801fc6b..20ebf6c34 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -18,4 +18,3 @@ # under the License. _extends: maven-gh-actions-shared -tag-template: maven-dependency-plugin-$RESOLVED_VERSION diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 5205f96ef..83008b18e 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,6 +22,7 @@ on: push: branches: - master + workflow_dispatch: jobs: update_release_draft: diff --git a/README.md b/README.md index 5ff4b4a9f..18cb862a1 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,13 @@ Contributing to [Apache Maven Dependency Plugin](https://maven.apache.org/plugins/maven-dependency-plugin/) ====================== -[![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEP.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-dependency-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-dependency-plugin) [![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/apache/maven/plugins/maven-dependency-plugin//badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-dependency-plugin/README.md) [![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-dependency-plugin/job/master.svg?)][build] [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-dependency-plugin/job/master.svg?)][test-results] - -You have found a bug or you have an idea for a cool new feature? Contributing +You have found a bug, or you have an idea for a cool new feature? Contributing code is a great way to give something back to the open source community. Before you dig right into the code, there are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of @@ -34,7 +32,6 @@ things. Getting Started --------------- -+ Make sure you have a [JIRA account](https://issues.apache.org/jira/). + Make sure you have a [GitHub account](https://github.com/signup/free). + If you're planning to implement a new feature, it makes sense to discuss your changes on the [dev list][ml-list] first. @@ -60,37 +57,23 @@ There are some guidelines which will make applying PRs easier for us: + Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted, create a separate PR for this change. + Check for unnecessary whitespace with `git diff --check` before committing. -+ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue. -``` -[MDEP-XXX] - Subject of the JIRA Ticket - Optional supplemental description. -``` + Make sure you have added the necessary tests (JUnit/IT) for your changes. + Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken. + Submit a pull request to the repository in the Apache organization. -+ Update your JIRA ticket and include a link to the pull request in the ticket. If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla]. -Making Trivial Changes ----------------------- - -For changes of a trivial nature to comments and documentation, it is not always -necessary to create a new ticket in JIRA. In this case, it is appropriate to -start the first line of a commit with '(doc)' instead of a ticket number. - Additional Resources -------------------- + [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch) -+ [Apache Maven Dependency JIRA project page][jira] + [Contributor License Agreement][cla] + [General GitHub documentation](https://help.github.com/) + [GitHub pull request documentation](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) -+ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject) -+ #Maven IRC channel on freenode.org ++ [Apache Maven X Account](https://x.com/ASFMavenProject) ++ [Apache Maven Bluesky Account](https://bsky.app/profile/maven.apache.org) ++ [Apache Maven Mastodon Account](https://mastodon.social/deck/@ASFMavenProject@fosstodon.org) -[jira]: https://issues.apache.org/jira/projects/MDEP/ [license]: https://www.apache.org/licenses/LICENSE-2.0 [ml-list]: https://maven.apache.org/mailing-lists.html [code-style]: https://maven.apache.org/developers/conventions/code.html diff --git a/pom.xml b/pom.xml index cd9a56bec..9597588c9 100644 --- a/pom.xml +++ b/pom.xml @@ -75,8 +75,8 @@ under the License. https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} - JIRA - https://issues.apache.org/jira/browse/MDEP + GitHub Issues + https://github.com/apache/maven-dependency-plugin/issues Jenkins From 986ecdcc3bc51fe6af7adc1ef1db2dbd393a4ba1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 22:48:41 +0000 Subject: [PATCH 233/283] Bump org.jsoup:jsoup from 1.18.3 to 1.19.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.18.3 to 1.19.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.18.3...jsoup-1.19.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9597588c9..28efe33a1 100644 --- a/pom.xml +++ b/pom.xml @@ -504,7 +504,7 @@ under the License. org.jsoup jsoup - 1.18.3 + 1.19.1 From d96199069648f4586a540d41f3f5c5c32f08a24e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:25:35 +0000 Subject: [PATCH 234/283] Bump org.assertj:assertj-core from 3.27.2 to 3.27.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.2 to 3.27.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.2...assertj-build-3.27.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28efe33a1..66bc01288 100644 --- a/pom.xml +++ b/pom.xml @@ -370,7 +370,7 @@ under the License. org.assertj assertj-core - 3.27.2 + 3.27.3 test From 42ec74cf7211f41e3b7817add8579b431deb3599 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 22:21:13 +0000 Subject: [PATCH 235/283] Bump commons-io:commons-io from 2.16.1 to 2.19.0 Bumps commons-io:commons-io from 2.16.1 to 2.19.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-version: 2.19.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66bc01288..2cbae8d1d 100644 --- a/pom.xml +++ b/pom.xml @@ -185,7 +185,7 @@ under the License. commons-io commons-io - 2.16.1 + 2.19.0 test From c5b782e15f0df1a0d29cc39861c1344f82aa142b Mon Sep 17 00:00:00 2001 From: Tayebwa Noah Date: Tue, 20 May 2025 05:55:18 +0300 Subject: [PATCH 236/283] fix: remove duplicate maven-resolver-api and maven-resolver-util dependencies in pom.xml (#526) --- pom.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pom.xml b/pom.xml index 2cbae8d1d..c7dc7a099 100644 --- a/pom.xml +++ b/pom.xml @@ -406,17 +406,6 @@ under the License. ${slf4jVersion} test - - org.apache.maven.resolver - maven-resolver-api - 1.9.22 - provided - - - org.apache.maven.resolver - maven-resolver-util - 1.9.22 - From b3417f0b4fb9859f271de245ba0f8a456ecb3143 Mon Sep 17 00:00:00 2001 From: Tayebwa Noah Date: Tue, 27 May 2025 13:29:57 +0300 Subject: [PATCH 237/283] MDEP-967 Change info to debug logging in AbstractFromConfigurationMojo (#529) --- .../fromConfiguration/AbstractFromConfigurationMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index f848c98d5..e06765e14 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -167,7 +167,7 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque } for (ArtifactItem artifactItem : artifactItems) { - this.getLog().info("Configured Artifact: " + artifactItem.toString()); + this.getLog().debug("Configured Artifact: " + artifactItem.toString()); if (artifactItem.getOutputDirectory() == null) { artifactItem.setOutputDirectory(this.outputDirectory); From 66fa7dad193d4926e0e53ab2dad2bc3bdecdbd45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 22:35:22 +0000 Subject: [PATCH 238/283] Bump org.jsoup:jsoup from 1.19.1 to 1.20.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.19.1 to 1.20.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.19.1...jsoup-1.20.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-version: 1.20.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7dc7a099..64e6e98e5 100644 --- a/pom.xml +++ b/pom.xml @@ -493,7 +493,7 @@ under the License. org.jsoup jsoup - 1.19.1 + 1.20.1 From 64fa778f60c07e6db455b0cbd4f9ad619515318d Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Fri, 30 May 2025 17:39:33 +0000 Subject: [PATCH 239/283] Small Javadoc clarifications (#533) --- .../plugins/dependency/resolvers/CollectDependenciesMojo.java | 4 ++-- .../plugins/dependency/resolvers/ResolveDependenciesMojo.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java index 7838d0d9a..2751d171d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java @@ -34,8 +34,8 @@ /** *

      - * Goal that collects the project dependencies from the repository. This goal requires Maven 3.0 or higher to function - * because it uses "requiresDependencyCollection". This means that it lists the groupId:artifactId:version information + * Goal that collects the project dependencies from the repository. This goal + * uses "requiresDependencyCollection" to list the groupId:artifactId:version information * by downloading the pom files without downloading the actual artifacts such as jar files. *

      *

      diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index d326bda2c..4402b4890 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -56,7 +56,7 @@ import org.sonatype.plexus.build.incremental.BuildContext; /** - * Goal that resolves the project dependencies from the repository. When using this goal while running on Java 9 the + * Goal that resolves the project dependencies from the repository. When running on Java 9, the * module names will be visible as well. * * @author Brian Fox From 2791f66a660ca38ac7736faa3171c98f77d7a90f Mon Sep 17 00:00:00 2001 From: Tayebwa Noah Date: Fri, 6 Jun 2025 00:14:50 +0300 Subject: [PATCH 240/283] Document dependency tree output formats (#535) * Document dependency tree output formats * Refactor docs --- src/site/apt/examples/tree-mojo.apt.vm | 304 +++++++++++++++++++++++++ src/site/apt/index.apt.vm | 2 + src/site/site.xml | 1 + 3 files changed, 307 insertions(+) create mode 100644 src/site/apt/examples/tree-mojo.apt.vm diff --git a/src/site/apt/examples/tree-mojo.apt.vm b/src/site/apt/examples/tree-mojo.apt.vm new file mode 100644 index 000000000..5c5a6ba32 --- /dev/null +++ b/src/site/apt/examples/tree-mojo.apt.vm @@ -0,0 +1,304 @@ +~~ 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. + + ------ + Dependency Tree Output Formats + ------ + Tayebwa Noah + ------ + 2025-06-04 + ------ + +Dependency Tree Output Formats + + The <<>> goal of the Maven Dependency Plugin generates a representation + of a project's dependency tree. The <<>> parameter allows you to specify + the output format, which can be written to a file using the <<>> parameter + or printed to the console. Supported formats are <<>>, <<>>, <<>>, + and <<>>. This section describes each format, its structure, and example usage. + +* Usage + + To <> the dependency tree in a specific format, use the following command: + ++---+ +mvn dependency:tree -DoutputType= -DoutputFile= ++---+ + + * <<>>: One of <<>>, <<>>, <<>>, or <<>>. If omitted, + the default is a text-based tree printed to the console. + + * <<>>: The file to write the output to (e.g., <<>>). + If omitted, the output is printed to the console. + + Example: + ++---+ +mvn dependency:tree -DoutputType=json -DoutputFile=dependency-tree.json ++---+ + + <>: Ensure you are using Maven Dependency Plugin version 3.7.0 or later + (latest is 3.8.1 as of June 2025) to access these output formats. + +* Output Formats + +{JSON (outputType=json)} + + <>: The JSON format represents the dependency tree as a hierarchical JSON + object. The root node describes the project's artifact, and its dependencies are listed + in a <<>> array, with nested dependencies recursively included. + + <>: + + * <>: + + * <<>>: The group ID of the project or dependency (e.g., <<>>). + + * <<>>: The artifact ID (e.g., <<>>). + + * <<>>: The version (e.g., <<<1.2.1-SNAPSHOT>>>). + + * <<>>: The artifact type (e.g., <<>>). + + * <<>>: The dependency scope (e.g., <<>>, <<>>, or empty for the project itself). + + * <<>>: The classifier, if any (e.g., empty string if none). + + * <<>>: Whether the dependency is optional (<<>> or <<>>). + + * <<>>: An array of dependency objects with the same structure, representing transitive dependencies. + + * <>: Each dependency in the <<>> array follows the same + structure, allowing for recursive representation of the dependency tree. + + + <>: + ++---+ +{ + "groupId": "org.apache.maven.extensions", + "artifactId": "maven-build-cache-extension", + "version": "1.2.1-SNAPSHOT", + "type": "jar", + "scope": "", + "classifier": "", + "optional": "false", + "children": [ + { + "groupId": "net.openhft", + "artifactId": "zero-allocation-hashing", + "version": "0.27ea0", + "type": "jar", + "scope": "compile", + "classifier": "", + "optional": "false" + }, + { + "groupId": "org.apache.maven.wagon", + "artifactId": "wagon-webdav-jackrabbit", + "version": "3.5.3", + "type": "jar", + "scope": "compile", + "classifier": "", + "optional": "false", + "children": [ + { + "groupId": "org.apache.jackrabbit", + "artifactId": "jackrabbit-webdav", + "version": "2.14.4", + "type": "jar", + "scope": "compile", + "classifier": "", + "optional": "false", + "children": [ + { + "groupId": "commons-codec", + "artifactId": "commons-codec", + "version": "1.10", + "type": "jar", + "scope": "compile", + "classifier": "", + "optional": "false" + } + ] + } + ] + } + ] +} ++---+ + + <>: + ++---+ +mvn dependency:tree -DoutputType=json -DoutputFile=dependency-tree.json ++---+ + + <>: Parse the JSON output programmatically for dependency analysis or integration + with other tools. + +{DOT (outputType=dot)} + + <>: The DOT format is a plain-text graph description language used by Graphviz. + It represents the dependency tree as a directed graph (<<>>), with nodes for + artifacts and directed edges for dependencies, labeled with their scope (e.g., <<>>). + + <>: + + * <>: Starts with <<::::">>>. + + * <>: Represented implicitly by their identifiers in edge definitions + (e.g., <<<"org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT:">>>). + + * <>: Defined as <<<"source" -> "target">>>, where <<>> is the parent artifact + and <<>> is the dependency, optionally labeled with the scope. + + <>: + ++---+ +digraph "org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT:" { + "org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT:" -> "net.openhft:zero-allocation-hashing:jar:0.27ea0:compile"; + "org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT:" -> "org.apache.maven.wagon:wagon-webdav-jackrabbit:jar:3.5.3:compile"; + "org.apache.maven.wagon:wagon-webdav-jackrabbit:jar:3.5.3:compile" -> "org.apache.jackrabbit:jackrabbit-webdav:jar:2.14.4:compile"; + "org.apache.jackrabbit:jackrabbit-webdav:jar:2.14.4:compile" -> "commons-codec:commons-codec:jar:1.10:compile"; +} ++---+ + + <>: + ++---+ +mvn dependency:tree -DoutputType=dot -DoutputFile=dependency-tree.dot ++---+ + + <>: Convert the DOT file to an image using Graphviz: + ++---+ +dot -Tpng dependency-tree.dot -o dependency-tree.png ++---+ + + <>: Visualize the dependency graph using tools like Graphviz for presentations + or analysis. + +{GraphML (outputType=graphml)} + + <>: GraphML is an XML-based format for representing graphs, compatible with + tools like yEd or Gephi. It represents the dependency tree as a directed graph with nodes + for artifacts and edges for dependencies, including scope information. + + <>: + + * <>: Contains namespace declarations and keys for node and edge graphics + (using <<>> extensions). + + * <>: Defined with <<>>. + + * <>: Each node has an <<>> (a unique number) and a <<>> with a + <<>> containing the artifact coordinates (e.g., <<>>). + + * <>: Defined with <<>> and <<>> node IDs, with a <<>> + containing a <<>> for the scope (e.g., <<>>). + + <>: + ++---+ + + + + + + org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT: + net.openhft:zero-allocation-hashing:jar:0.27ea0:compile + compile + org.apache.maven.wagon:wagon-webdav-jackrabbit:jar:3.5.3:compile + org.apache.jackrabbit:jackrabbit-webdav:jar:2.14.4:compile + compile + + ++---+ + + <>: + ++---+ +mvn dependency:tree -DoutputType=graphml -DoutputFile=dependency-tree.graphml ++---+ + + <>: Open the GraphML file in yEd or Gephi to visualize the dependency graph. + + <>: Analyze complex dependency structures using graph visualization tools. + +{TGF (outputType=tgf)} + + <>: The Trivial Graph Format (TGF) is a simple text-based format for representing + graphs. It lists nodes followed by edges, with each node and edge described on a single line. + + <>: + + * <>: Each line contains a unique node ID (a number) followed by the artifact + coordinates (e.g., <<>>). + + * <>: A line containing <<<#>>> separates nodes from edges. + + * <>: Each line contains the source node ID, target node ID, and the scope + (e.g., <<>>). + + <>: + ++---+ +1474640235 org.apache.maven.extensions:maven-build-cache-extension:jar:1.2.1-SNAPSHOT: +788877168 net.openhft:zero-allocation-hashing:jar:0.27ea0:compile +1662807313 org.apache.maven.wagon:wagon-webdav-jackrabbit:jar:3.5.3:compile +1655562261 org.apache.jackrabbit:jackrabbit-webdav:jar:2.14.4:compile +1894638973 commons-codec:commons-codec:jar:1.10:compile +# +1474640235 788877168 compile +1474640235 1662807313 compile +1662807313 1655562261 compile +1655562261 1894638973 compile ++---+ + + <>: + ++---+ +mvn dependency:tree -DoutputType=tgf -DoutputFile=dependency-tree.tgf ++---+ + + <>: Convert TGF to other formats (e.g., DOT) using tools like <<>> or + custom scripts for visualization. + + <>: Lightweight format for simple graph processing or conversion to other graph formats. + +* Notes + + * <>: The <<>>, <<>>, <<>>, and <<>> output formats are + available starting with Maven Dependency Plugin version 3.7.0. Always use the latest version + (3.8.1 as of June 2025) for the most stable experience. + + * <>: + + * <>: Parse with any JSON-compatible tool (e.g., Python's <<>> module, JavaScript's <<>>). + + * <>: Use Graphviz (<<>> command) to generate PNG, SVG, or other visual formats. + + * <>: Use yEd, Gephi, or other GraphML-compatible tools for visualization. + + * <>: Use tools supporting TGF or convert to DOT/GraphML for visualization. + + * <>: If you encounter issues or want to improve this documentation, contribute to + the Maven Dependency Plugin repository at + {{{https://github.com/apache/maven-dependency-plugin}https://github.com/apache/maven-dependency-plugin}}. + See the + {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 34cf45edc..468888d24 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -150,6 +150,8 @@ ${project.name} * {{{./examples/purging-local-repository.html}Purging the local repository}} + * {{{./examples/tree-mojo.html}Tree Mojo}} + [] * Resources diff --git a/src/site/site.xml b/src/site/site.xml index 16a0738d1..a7f5a4b32 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -42,6 +42,7 @@ under the License. +

      From 2bb3631ace2942fc163808f18149ae0334450594 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 18 Jun 2025 11:48:44 +1000 Subject: [PATCH 241/283] disable notifications during import, remove jira Signed-off-by: Olivier Lamy --- .asf.yaml | 7 ++----- .github/ISSUE_TEMPLATE/config.yml | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index bde27bc8b..e1ba5c83a 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -28,13 +28,10 @@ github: squash: true merge: false rebase: true - autolink_jira: - - MDEP del_branch_on_merge: true features: issues: true notifications: commits: commits@maven.apache.org - issues: issues@maven.apache.org - pullrequests: issues@maven.apache.org - jira_options: link label comment + #issues: issues@maven.apache.org + #pullrequests: issues@maven.apache.org diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 2d19a3e38..ba0544b5b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -25,6 +25,3 @@ contact_links: url: https://maven.apache.org/mailing-lists.html about: Please ask a question or discuss here - - name: Old JIRA Issues - url: https://issues.apache.org/jira/projects/MDEP - about: Please search old JIRA issues From ed440862d05b2bdab34936a2569eac005252ef48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 22:52:22 +0000 Subject: [PATCH 242/283] Bump org.apache.maven.plugins:maven-plugins from 44 to 45 Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 44 to 45. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-version: '45' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64e6e98e5..87077eb2d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 44 + 45 From caa60d1e9ffde38af23c2df0bf35509c750b166c Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 18 Jun 2025 15:52:59 +0000 Subject: [PATCH 243/283] Copy edit parameter descriptions (#1488) --- .../AbstractDependencyFilterMojo.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 99b4ca763..9eaa182eb 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -56,7 +56,7 @@ import org.sonatype.plexus.build.incremental.BuildContext; /** - * Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering + * Class that encapsulates the plugin parameters, and contains methods that handle dependency filtering. * * @author Brian Fox * @see org.apache.maven.plugins.dependency.AbstractDependencyMojo @@ -96,7 +96,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected boolean excludeTransitive; /** - * Comma Separated list of Types to include. Empty String indicates include everything (default). + * Comma-separated list of Types to include. Empty String indicates include everything (default). * * @since 2.0 */ @@ -104,7 +104,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String includeTypes; /** - * Comma Separated list of Types to exclude. Empty String indicates don't exclude anything (default). + * Comma-separated list of Types to exclude. Empty String indicates don't exclude anything (default). * * @since 2.0 */ @@ -150,7 +150,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String excludeScope; /** - * Comma Separated list of Classifiers to include. Empty String indicates include everything (default). + * Comma-separated list of Classifiers to include. Empty string indicates include everything (default). * * @since 2.0 */ @@ -158,7 +158,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String includeClassifiers; /** - * Comma Separated list of Classifiers to exclude. Empty String indicates don't exclude anything (default). + * Comma-separated list of Classifiers to exclude. Empty String indicates don't exclude anything (default). * * @since 2.0 */ @@ -182,7 +182,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String type; /** - * Comma separated list of Artifact names to exclude. + * Comma-separated list of artifact IDs to exclude. * * @since 2.0 */ @@ -190,7 +190,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String excludeArtifactIds; /** - * Comma separated list of Artifact names to include. Empty String indicates include everything (default). + * Comma-separated list of artifact IDs to include. Empty String indicates include everything (default). * * @since 2.0 */ @@ -198,7 +198,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String includeArtifactIds; /** - * Comma separated list of GroupId Names to exclude. + * Comma-separated list of group IDs to exclude. * * @since 2.0 */ @@ -206,7 +206,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String excludeGroupIds; /** - * Comma separated list of GroupIds to include. Empty String indicates include everything (default). + * Comma-separated list of group IDs to include. Empty string indicates include everything (default). * * @since 2.0 */ @@ -218,15 +218,13 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj * * @since 2.0 */ - // CHECKSTYLE_OFF: LineLength @Parameter( property = "markersDirectory", defaultValue = "${project.build.directory}/dependency-maven-plugin-markers") - // CHECKSTYLE_ON: LineLength protected File markersDirectory; /** - * Prepend the groupId during copy. + * Prepend the group ID during copy. * * @since 2.2 */ From fade356b506fd039e720168501d4c6ca2bb3065c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 23:47:54 +0000 Subject: [PATCH 244/283] Bump org.jsoup:jsoup from 1.20.1 to 1.21.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.20.1 to 1.21.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.20.1...jsoup-1.21.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-version: 1.21.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87077eb2d..b213f9a6d 100644 --- a/pom.xml +++ b/pom.xml @@ -493,7 +493,7 @@ under the License. org.jsoup jsoup - 1.20.1 + 1.21.1 From f164515f2fd9649b5e5f818b53fc5b238b8d5deb Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 6 Jul 2025 10:46:55 -0400 Subject: [PATCH 245/283] grammar and jacdoc fixes (#1491) * grammar * more --- .../pom.xml | 4 +- .../fromConfiguration/ArtifactItem.java | 74 +++++++++---------- .../AbstractDependencyFilterMojo.java | 2 +- .../AbstractFromDependenciesMojo.java | 4 +- .../CopyDependenciesMojo.java | 22 +++--- .../tree/JsonDependencyNodeVisitor.java | 2 +- .../dependency/utils/DependencyUtil.java | 17 ++--- 7 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml index a41847d9e..0fee5f399 100644 --- a/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml +++ b/src/it/projects/mdep-689-apply-filtering-go-offline-goal/pom.xml @@ -95,8 +95,8 @@ under the License. skip.this.groupid,skip.this.groupid.too skip-this-artifact,skip-this-artifact-too - + system ear diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java index b98b4567c..ff093978b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java @@ -36,37 +36,37 @@ */ public class ArtifactItem implements DependableCoordinate { /** - * Group ID of Artifact + * Group ID of artifact */ @Parameter(required = true) private String groupId; /** - * Name of Artifact + * Name of artifact */ @Parameter(required = true) private String artifactId; /** - * Version of Artifact + * Version of artifact */ @Parameter private String version = null; /** - * Type of Artifact (War,Jar,etc) + * Type of artifact (War, Jar, etc.) */ @Parameter(required = true) private String type = "jar"; /** - * Classifier for Artifact (tests,sources,etc) + * Classifier for artifact (tests, sources, etc.) */ @Parameter private String classifier; /** - * Location to use for this Artifact. Overrides default location. + * Location to use for this artifact. Overrides default location. */ @Parameter private File outputDirectory; @@ -78,7 +78,7 @@ public class ArtifactItem implements DependableCoordinate { private String destFileName; /** - * Force Overwrite..this is the one to set in pom + * Force Overwrite. This is the one to set in pom. */ private String overWrite; @@ -114,7 +114,7 @@ public class ArtifactItem implements DependableCoordinate { private FileMapper[] fileMappers; /** - * Default ctor. + * Default constructor. */ public ArtifactItem() { // default constructor @@ -140,7 +140,7 @@ private String filterEmptyString(String in) { } /** - * @return Returns the artifactId. + * @return returns the artifact ID */ @Override public String getArtifactId() { @@ -148,14 +148,14 @@ public String getArtifactId() { } /** - * @param theArtifact The artifactId to set. + * @param theArtifact the artifact ID to set */ public void setArtifactId(String theArtifact) { this.artifactId = filterEmptyString(theArtifact); } /** - * @return Returns the groupId. + * @return returns the group ID */ @Override public String getGroupId() { @@ -163,14 +163,14 @@ public String getGroupId() { } /** - * @param groupId The groupId to set. + * @param groupId the group ID to set */ public void setGroupId(String groupId) { this.groupId = filterEmptyString(groupId); } /** - * @return Returns the type. + * @return returns the type */ @Override public String getType() { @@ -178,14 +178,14 @@ public String getType() { } /** - * @param type The type to set. + * @param type the type to set */ public void setType(String type) { this.type = filterEmptyString(type); } /** - * @return Returns the version. + * @return returns the version */ @Override public String getVersion() { @@ -193,21 +193,21 @@ public String getVersion() { } /** - * @param version The version to set. + * @param version the version to set */ public void setVersion(String version) { this.version = filterEmptyString(version); } /** - * @return Returns the base version. + * @return teturns the base version */ public String getBaseVersion() { return ArtifactUtils.toSnapshotVersion(version); } /** - * @return Classifier. + * @return Classifier */ @Override public String getClassifier() { @@ -215,7 +215,7 @@ public String getClassifier() { } /** - * @param classifier Classifier. + * @param classifier classifier */ public void setClassifier(String classifier) { this.classifier = filterEmptyString(classifier); @@ -231,63 +231,63 @@ public String toString() { } /** - * @return Returns the location. + * @return returns the location */ public File getOutputDirectory() { return outputDirectory; } /** - * @param outputDirectory The outputDirectory to set. + * @param outputDirectory the outputDirectory to set */ public void setOutputDirectory(File outputDirectory) { this.outputDirectory = outputDirectory; } /** - * @return Returns the location. + * @return returns the location */ public String getDestFileName() { return destFileName; } /** - * @param destFileName The destFileName to set. + * @param destFileName the destination file name to set */ public void setDestFileName(String destFileName) { this.destFileName = filterEmptyString(destFileName); } /** - * @return Returns the needsProcessing. + * @return returns the needsProcessing */ public boolean isNeedsProcessing() { return this.needsProcessing; } /** - * @param needsProcessing The needsProcessing to set. + * @param needsProcessing the needsProcessing to set */ public void setNeedsProcessing(boolean needsProcessing) { this.needsProcessing = needsProcessing; } /** - * @return Returns the overWriteSnapshots. + * @return teturns the overWriteSnapshots */ public String getOverWrite() { return this.overWrite; } /** - * @param overWrite The overWrite to set. + * @param overWrite the overWrite to set */ public void setOverWrite(String overWrite) { this.overWrite = overWrite; } /** - * @return Returns the encoding. + * @return returns the encoding * @since 3.0 */ public String getEncoding() { @@ -295,7 +295,7 @@ public String getEncoding() { } /** - * @param encoding The encoding to set. + * @param encoding the encoding to set * @since 3.0 */ public void setEncoding(String encoding) { @@ -303,42 +303,42 @@ public void setEncoding(String encoding) { } /** - * @return Returns the artifact. + * @return returns the artifact */ public Artifact getArtifact() { return this.artifact; } /** - * @param artifact The artifact to set. + * @param artifact the artifact to set */ public void setArtifact(Artifact artifact) { this.artifact = artifact; } /** - * @return Returns a comma separated list of excluded items + * @return returns a comma separated list of excluded items */ public String getExcludes() { return DependencyUtil.cleanToBeTokenizedString(this.excludes); } /** - * @param excludes A comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties + * @param excludes a comma separated list of items to exclude; for example, **\/*.xml, **\/*.properties */ public void setExcludes(String excludes) { this.excludes = excludes; } /** - * @return Returns a comma separated list of included items + * @return returns a comma separated list of items to include */ public String getIncludes() { return DependencyUtil.cleanToBeTokenizedString(this.includes); } /** - * @param includes A comma separated list of items to include i.e. **\/*.xml, **\/*.properties + * @param includes comma separated list of items to include; for example, **\/*.xml, **\/*.properties */ public void setIncludes(String includes) { this.includes = includes; @@ -346,7 +346,7 @@ public void setIncludes(String includes) { /** * @return {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting shall - * happen. + * happen * * @since 3.1.2 */ @@ -356,7 +356,7 @@ public FileMapper[] getFileMappers() { /** * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no - * rewriting shall happen. + * rewriting shall happen * * @since 3.1.2 */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 9eaa182eb..3b274c5f5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -478,7 +478,7 @@ private Set resolve(Set artifact resolverUtil.resolveArtifact(artifact, getProject().getRemoteProjectRepositories()); resolvedArtifacts.add(RepositoryUtils.toArtifact(resolveArtifact)); } catch (ArtifactResolutionException ex) { - // an error occurred during resolution, log it an continue + // an error occurred during resolution, log it and continue getLog().debug("error resolving: " + artifact, ex); if (stopOnFailure) { throw new MojoExecutionException("error resolving: " + artifact, ex); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 30516ee34..5f624e7a5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -83,7 +83,7 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil /** * Place each type of file in a separate subdirectory. (example /outputDirectory/runtime /outputDirectory/provided - * etc) + * etc.) * * @since 2.2 */ @@ -91,7 +91,7 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil protected boolean useSubDirectoryPerScope; /** - * Place each type of file in a separate subdirectory. (example /outputDirectory/jars /outputDirectory/wars etc) + * Place each type of file in a separate subdirectory. (example /outputDirectory/jars /outputDirectory/wars etc.) * * @since 2.0-alpha-1 */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 0d6eb7d73..8223d95ce 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -222,11 +222,11 @@ private void installBaseSnapshot(Artifact artifact, ProjectBuildingRequest build * Copies the Artifact after building the destination file name if overridden. This method also checks if the * classifier is set and adds it to the destination file name if needed. * - * @param artifact representing the object to be copied. - * @param removeVersion specifies if the version should be removed from the file name when copying. - * @param prependGroupId specifies if the groupId should be prepend to the file while copying. - * @param theUseBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. - * @throws MojoExecutionException with a message if an error occurs. + * @param artifact the object to be copied + * @param removeVersion specifies if the version should be removed from the file name when copying + * @param prependGroupId specifies if the group ID should be prefixed to the file while copying + * @param theUseBaseVersion specifies if the baseVersion of the artifact should be used instead of the version + * @throws MojoExecutionException with a message if an error occurs * @see #copyArtifact(Artifact, boolean, boolean, boolean, boolean) */ protected void copyArtifact( @@ -239,12 +239,12 @@ protected void copyArtifact( * Copies the Artifact after building the destination file name if overridden. This method also checks if the * classifier is set and adds it to the destination file name if needed. * - * @param artifact representing the object to be copied. - * @param removeVersion specifies if the version should be removed from the file name when copying. - * @param prependGroupId specifies if the groupId should be prepend to the file while copying. - * @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version. - * @param removeClassifier specifies if the classifier should be removed from the file name when copying. - * @throws MojoExecutionException with a message if an error occurs. + * @param artifact the object to be copied + * @param removeVersion specifies if the version should be removed from the file name when copying + * @param prependGroupId specifies if the groupId should be prefixed to the file while copying + * @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version + * @param removeClassifier specifies if the classifier should be removed from the file name when copying + * @throws MojoExecutionException with a message if an error occurs * @see CopyUtil#copyArtifactFile(Artifact, File) * @see DependencyUtil#getFormattedOutputDirectory(boolean, boolean, boolean, boolean, boolean, boolean, File, Artifact) */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java index 015ce1b2d..333928212 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java @@ -84,7 +84,7 @@ private void writeNode(int indent, DependencyNode node, StringBuilder sb, Set Date: Sun, 15 Jun 2025 03:27:19 +0530 Subject: [PATCH 246/283] Fix - markersDirectory is not working when unpack goal is executed from command line #536 --- .../plugins/dependency/fromConfiguration/UnpackMojo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 9d2815cbb..46476a99a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -55,7 +55,9 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { /** * Directory to store flag files after unpack */ - @Parameter(defaultValue = "${project.build.directory}/dependency-maven-plugin-markers") + @Parameter( + property = "markersDirectory", + defaultValue = "${project.build.directory}/dependency-maven-plugin-markers") private File markersDirectory; /** From 88585aa737d87da39f009ec1dff3add469e625fe Mon Sep 17 00:00:00 2001 From: Mark Derricutt Date: Mon, 7 Jul 2025 23:07:35 +1200 Subject: [PATCH 247/283] Update maven-dependency-analyzer to support Java24 (#528) * Update maven-dependency-analyzer to support Java24 This commit updates the analyser version which supports reading byte code generated by Java 24. Fixes #524 * Fix IT --------- Co-authored-by: Slawomir Jaranowski --- pom.xml | 2 +- .../mdep-779-analyze-only-verbose-shows-class-names/pom.xml | 6 +++--- .../src/main/java/usedUndeclaredReference/Project.java | 2 +- .../verify.bsh | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index b213f9a6d..4feb86acb 100644 --- a/pom.xml +++ b/pom.xml @@ -217,7 +217,7 @@ under the License. org.apache.maven.shared maven-dependency-analyzer - 1.15.1 + 1.16.0 org.apache.maven.shared diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml index 74504df21..690938fbd 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/pom.xml @@ -33,9 +33,9 @@ - net.java.dev.msv - xsdlib - 2022.7 + org.apache.maven.shared + maven-shared-utils + 3.4.2 diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/src/main/java/usedUndeclaredReference/Project.java b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/src/main/java/usedUndeclaredReference/Project.java index 5432b4056..a9d3fe68e 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/src/main/java/usedUndeclaredReference/Project.java +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/src/main/java/usedUndeclaredReference/Project.java @@ -21,5 +21,5 @@ public class Project { - public static final Class CLASS_REF = org.apache.xmlcommons.Version.class; + public static final Class CLASS_REF = org.apache.commons.io.IOUtils.class; } diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh index b3300d87b..97e837535 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh @@ -24,10 +24,10 @@ String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); log = StringUtils.unifyLineSeparators(log, "\n"); String expected = "[WARNING] Used undeclared dependencies found:\n" + - "[WARNING] xml-apis:xml-apis:jar:1.4.01:compile\n" + - "[WARNING] class org.apache.xmlcommons.Version\n" + + "[WARNING] commons-io:commons-io:jar:2.11.0:compile\n" + + "[WARNING] class org.apache.commons.io.IOUtils\n" + "[WARNING] Unused declared dependencies found:\n" + - "[WARNING] net.java.dev.msv:xsdlib:jar:2022.7:compile"; + "[WARNING] org.apache.maven.shared:maven-shared-utils:jar:3.4.2:compile"; if ( !log.contains(expected) ) { From 953f412d4ceb1bcf361bda6aa9163300dc7e4333 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 7 Jul 2025 08:44:44 -0400 Subject: [PATCH 248/283] [MEDP-964] unconditionally ignore dependencies known to be loaded by reflection (#1492) * unconditionally ignore dependencies known to be loaded by reflection * docs --- .../analyze/AbstractAnalyzeMojo.java | 16 +++++++++++----- ...ependencies-from-dependency-analysis.apt.vm | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index b88675377..0fda8b8a0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -78,7 +78,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { private boolean verbose; /** - * Ignore Runtime/Provided/Test/System scopes for unused dependency analysis. + * Ignore runtime/provided/test/system scopes for unused dependency analysis. *

      * Non-test scoped list will be not affected. */ @@ -86,7 +86,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { private boolean ignoreNonCompile; /** - * Ignore Runtime scope for unused dependency analysis. + * Ignore runtime scope for unused dependency analysis. * * @since 3.2.0 */ @@ -211,13 +211,18 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { * segment is treated as an implicit wildcard. * *

      * For example, org.apache.* matches all artifacts whose group id starts with - * org.apache., and :::*-SNAPSHOT will match all snapshot artifacts. + * org.apache., and :::*-SNAPSHOT matches all snapshot artifacts. *

      * + *

      Certain dependencies that are known to be used and loaded by reflection + * are always ignored. This includes {@code org.slf4j:slf4j-simple::}.

      + * * @since 2.10 */ - @Parameter(defaultValue = "org.slf4j:slf4j-simple::") - private String[] ignoredUnusedDeclaredDependencies; + @Parameter + private String[] ignoredUnusedDeclaredDependencies = new String[0]; + + private String[] unconditionallyIgnoredDeclaredDependencies = {"org.slf4j:slf4j-simple::"}; /** * List of dependencies that are ignored if they are in not test scope but are only used in test classes. @@ -361,6 +366,7 @@ private boolean checkDependencies() throws MojoExecutionException { ignoredUnusedDeclared.addAll(filterDependencies(unusedDeclared, ignoredDependencies)); ignoredUnusedDeclared.addAll(filterDependencies(unusedDeclared, ignoredUnusedDeclaredDependencies)); + ignoredUnusedDeclared.addAll(filterDependencies(unusedDeclared, unconditionallyIgnoredDeclaredDependencies)); if (ignoreAllNonTestScoped) { ignoredNonTestScope.addAll(filterDependencies(nonTestScope, new String[] {"*"})); diff --git a/src/site/apt/examples/exclude-dependencies-from-dependency-analysis.apt.vm b/src/site/apt/examples/exclude-dependencies-from-dependency-analysis.apt.vm index 706127f14..4514937df 100644 --- a/src/site/apt/examples/exclude-dependencies-from-dependency-analysis.apt.vm +++ b/src/site/apt/examples/exclude-dependencies-from-dependency-analysis.apt.vm @@ -28,16 +28,18 @@ Exclude dependencies from dependency analysis A project's dependencies can be analyzed as part of the build process by binding the <<>> goal to the lifecycle. By default, the analysis will be performed during the <<>> lifecycle phase. - In rare cases it is possible to have dependencies that are - legitimate on the classpath but cause either "Declared but unused" - or "Undeclared but used" warnings. The most common case is with jars - that contain annotations and the byte code analysis is unable to - determine whether a jar is actually required or not. + It is possible to have necessary dependencies on the classpath that + cause either "Declared but unused" or "Undeclared but used" warnings. + One common cause of byte code analysis being unable to + determine whether a jar is required are annotations with + source retention. Another common cause is + a class that is loaded by reflection at runtime. - The plugin can then be configured to ignore dependencies that are - "declared but unused", "undeclared but used", and "non-test scoped" - in selected list or in all simultaneously. + The dependency plugin does not warn about a few common dependencies + where its analysis is known to be unreliable, most notably SLF4J. + If you encounter other false positives, you can configure the plugin to ignore particular + dependencies that are "declared but unused", "undeclared but used", and "non-test scoped". See the following POM configuration for an example: +---+ From 6214394c738952a76121f8c96c8b7f39dfe4f8f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Jul 2025 06:37:58 +0200 Subject: [PATCH 249/283] Bump org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0 (#1494) Bumps org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-version: 3.18.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4feb86acb..664775963 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ under the License. org.apache.commons commons-lang3 - 3.17.0 + 3.18.0 commons-io From e8235e00074957545eb430492977162dc6d525c7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 12 Jul 2025 20:46:06 +0200 Subject: [PATCH 250/283] enable notifications after JIRA import --- .asf.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index e1ba5c83a..0a7d80dcb 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -33,5 +33,5 @@ github: issues: true notifications: commits: commits@maven.apache.org - #issues: issues@maven.apache.org - #pullrequests: issues@maven.apache.org + issues: issues@maven.apache.org + pullrequests: issues@maven.apache.org From e3b121a18c5eb5e3d5fc308b82f528e25963410e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 13 Jul 2025 10:40:08 +0200 Subject: [PATCH 251/283] Cleanups dependencies --- pom.xml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 664775963..a8a305809 100644 --- a/pom.xml +++ b/pom.xml @@ -139,12 +139,6 @@ under the License. ${mavenVersion} provided - - org.apache.maven - maven-resolver-provider - ${mavenVersion} - provided - @@ -318,12 +312,6 @@ under the License. junit-jupiter-params test - - jakarta.json - jakarta.json-api - 2.0.2 - test - org.glassfish jakarta.json @@ -442,6 +430,25 @@ under the License. src/config/checkstyle-suppressions.xml
      + + org.apache.maven.plugins + maven-dependency-plugin + + + analyze + + true + + + org.apache.maven.resolver:maven-resolver-connector-basic + org.apache.maven.resolver:maven-resolver-transport-file + org.apache.maven.resolver:maven-resolver-transport-http + org.junit.vintage:junit-vintage-engine + + + + + From 0ff6c5330ecdb6544cf7a649f375bf4769b13488 Mon Sep 17 00:00:00 2001 From: Noah Tayebwa Date: Fri, 25 Jul 2025 04:04:59 +0300 Subject: [PATCH 252/283] Add Apache 2.0 LICENSE file (#1497) --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. From fb788570f4efbf6938d5cf244cc4f8af4605a967 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 12:09:30 +0200 Subject: [PATCH 253/283] Bump org.assertj:assertj-core from 3.27.3 to 3.27.4 (#1501) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.3 to 3.27.4. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.3...assertj-build-3.27.4) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.4 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8a305809..2cbb55ce4 100644 --- a/pom.xml +++ b/pom.xml @@ -358,7 +358,7 @@ under the License. org.assertj assertj-core - 3.27.3 + 3.27.4 test From 8b94652eec5954ae29566305abf0a0d49bf3956e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Jul 2025 22:40:43 +0000 Subject: [PATCH 254/283] Bump commons-io:commons-io from 2.19.0 to 2.20.0 Bumps [commons-io:commons-io](https://github.com/apache/commons-io) from 2.19.0 to 2.20.0. - [Changelog](https://github.com/apache/commons-io/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-io/compare/rel/commons-io-2.19.0...rel/commons-io-2.20.0) --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-version: 2.20.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2cbb55ce4..be0d210c1 100644 --- a/pom.xml +++ b/pom.xml @@ -179,7 +179,7 @@ under the License. commons-io commons-io - 2.19.0 + 2.20.0 test From bed92902d2f51f1931ec44d4357e1f56e90da700 Mon Sep 17 00:00:00 2001 From: Noah Tayebwa Date: Sun, 10 Aug 2025 16:08:23 +0300 Subject: [PATCH 255/283] Fix [MDEP-931] Replace PrintWriter with Writer in AbstractSerializing Visitor and subclasses (#530) --- .../verify.bsh | 4 +- .../analyze/AnalyzeDuplicateMojo.java | 4 +- .../tree/AbstractSerializingVisitor.java | 9 +--- .../tree/DOTDependencyNodeVisitor.java | 32 +++++++---- .../tree/GraphmlDependencyNodeVisitor.java | 53 ++++++++++++------- .../tree/JsonDependencyNodeVisitor.java | 32 ++++++----- .../tree/TGFDependencyNodeVisitor.java | 45 ++++++++++------ .../plugins/dependency/tree/TestTreeMojo.java | 2 +- 8 files changed, 112 insertions(+), 69 deletions(-) diff --git a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh index 97e837535..7632bd758 100644 --- a/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh +++ b/src/it/projects/mdep-779-analyze-only-verbose-shows-class-names/verify.bsh @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java index 9ad7de2c6..1d59ff8d6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDuplicateMojo.java @@ -122,7 +122,7 @@ private void createMessage( Set duplicateDependencies, StringBuilder sb, String messageDuplicateDepInDependencies) { if (!duplicateDependencies.isEmpty()) { if (sb.length() > 0) { - sb.append("\n"); + sb.append(System.lineSeparator()); } sb.append(messageDuplicateDepInDependencies); for (Iterator it = duplicateDependencies.iterator(); it.hasNext(); ) { @@ -130,7 +130,7 @@ private void createMessage( sb.append("\to ").append(dup); if (it.hasNext()) { - sb.append("\n"); + sb.append(System.lineSeparator()); } } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java index 8f8f40ed8..32ec08837 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java @@ -18,7 +18,6 @@ */ package org.apache.maven.plugins.dependency.tree; -import java.io.PrintWriter; import java.io.Writer; /** @@ -31,7 +30,7 @@ public abstract class AbstractSerializingVisitor { /** * The writer to serialize to. */ - protected final PrintWriter writer; + protected final Writer writer; /** * Constructor. @@ -42,10 +41,6 @@ public abstract class AbstractSerializingVisitor { * @param writer the writer to serialize to. */ public AbstractSerializingVisitor(Writer writer) { - if (writer instanceof PrintWriter) { - this.writer = (PrintWriter) writer; - } else { - this.writer = new PrintWriter(writer, true); - } + this.writer = writer; } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java index 238a62ae6..5cc8f86c9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.tree; +import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; import java.util.List; @@ -47,16 +49,23 @@ public DOTDependencyNodeVisitor(Writer writer) { */ @Override public boolean visit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - writer.write("digraph \"" + node.toNodeString() + "\" { " + System.lineSeparator()); - } + try { + if (node.getParent() == null || node.getParent() == node) { + writer.write("digraph \"" + node.toNodeString() + "\" { " + System.lineSeparator()); + writer.flush(); + } - // Generate "currentNode -> Child" lines + // Generate "currentNode -> Child" lines - List children = node.getChildren(); + List children = node.getChildren(); - for (DependencyNode child : children) { - writer.println("\t\"" + node.toNodeString() + "\" -> \"" + child.toNodeString() + "\" ; "); + for (DependencyNode child : children) { + writer.write("\t\"" + node.toNodeString() + "\" -> \"" + child.toNodeString() + "\" ; " + + System.lineSeparator()); + } + writer.flush(); + } catch (IOException e) { + throw new UncheckedIOException("Failed to write DOT format output", e); } return true; @@ -67,8 +76,13 @@ public boolean visit(DependencyNode node) { */ @Override public boolean endVisit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - writer.write(" } "); + try { + if (node.getParent() == null || node.getParent() == node) { + writer.write(" } " + System.lineSeparator()); + writer.flush(); + } + } catch (IOException e) { + throw new UncheckedIOException("Failed to write DOT format output", e); } return true; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java index 77c55c413..c6c600fa5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.tree; +import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; import org.apache.maven.shared.dependency.graph.DependencyNode; @@ -64,19 +66,24 @@ public GraphmlDependencyNodeVisitor(Writer writer) { */ @Override public boolean endVisit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - writer.write(GRAPHML_FOOTER); - } else { - DependencyNode p = node.getParent(); - writer.print(""); - if (node.getArtifact().getScope() != null) { - // add Edge label - writer.print("" - + node.getArtifact().getScope() + ""); + try { + if (node.getParent() == null || node.getParent() == node) { + writer.write(GRAPHML_FOOTER); + } else { + DependencyNode p = node.getParent(); + writer.write(""); + if (node.getArtifact().getScope() != null) { + // add Edge label + writer.write("" + + node.getArtifact().getScope() + ""); + } + writer.write("" + System.lineSeparator()); } - writer.println(""); + writer.flush(); + return true; + } catch (IOException e) { + throw new UncheckedIOException("Failed to write GraphML format output", e); } - return true; } /** @@ -84,16 +91,22 @@ public boolean endVisit(DependencyNode node) { */ @Override public boolean visit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - writer.write(GRAPHML_HEADER); + try { + if (node.getParent() == null || node.getParent() == node) { + writer.write(GRAPHML_HEADER); + writer.flush(); + } + // write node + writer.write(""); + // add node label + writer.write("" + node.toNodeString() + + ""); + writer.write("" + System.lineSeparator()); + writer.flush(); + return true; + } catch (IOException e) { + throw new UncheckedIOException("Failed to write GraphML format output", e); } - // write node - writer.print(""); - // add node label - writer.print("" + node.toNodeString() - + ""); - writer.println(""); - return true; } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java index 333928212..5faefbf1a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/JsonDependencyNodeVisitor.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.tree; +import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; import java.util.HashSet; import java.util.Set; @@ -44,25 +46,31 @@ public JsonDependencyNodeVisitor(Writer writer) { @Override public boolean visit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - writeRootNode(node); + try { + if (node.getParent() == null || node.getParent() == node) { + writeRootNode(node); + } + return true; + } catch (IOException e) { + throw new UncheckedIOException("Failed to write JSON format output", e); } - return true; } /** * Writes the node to the writer. This method is recursive and will write all children nodes. * * @param node the node to write + * @throws IOException if an I/O error occurs while writing */ - private void writeRootNode(DependencyNode node) { + private void writeRootNode(DependencyNode node) throws IOException { Set visited = new HashSet<>(); int indent = 2; StringBuilder sb = new StringBuilder(); - sb.append("{").append("\n"); + sb.append("{").append(System.lineSeparator()); writeNode(indent, node, sb, visited); - sb.append("}").append("\n"); + sb.append("}").append(System.lineSeparator()); writer.write(sb.toString()); + writer.flush(); } /** * Appends the node and its children to the string builder. @@ -91,21 +99,21 @@ private void writeNode(int indent, DependencyNode node, StringBuilder sb, Set visited) { - sb.append(indent(indent)).append("\"children\": [").append("\n"); + sb.append(indent(indent)).append("\"children\": [").append(System.lineSeparator()); indent += 2; for (int i = 0; i < node.getChildren().size(); i++) { DependencyNode child = node.getChildren().get(i); sb.append(indent(indent)); - sb.append("{").append("\n"); + sb.append("{").append(System.lineSeparator()); writeNode(indent + 2, child, sb, visited); sb.append(indent(indent)).append("}"); // we skip the comma for the last child if (i != node.getChildren().size() - 1) { sb.append(","); } - sb.append("\n"); + sb.append(System.lineSeparator()); } - sb.append(indent(indent)).append("]").append("\n"); + sb.append(indent(indent)).append("]").append(System.lineSeparator()); } @Override @@ -156,7 +164,7 @@ private void appendKeyValue(StringBuilder sb, int indent, String key, String val .append(value) .append("\"") .append(",") - .append("\n"); + .append(System.lineSeparator()); } /** * Appends a key value pair to the string builder without a comma at the end. This is used for the last children of a node. @@ -180,7 +188,7 @@ private void appendKeyWithoutComma(StringBuilder sb, int indent, String key, Str .append("\"") .append(value) .append("\"") - .append("\n"); + .append(System.lineSeparator()); } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java index 48ebfb0e9..c2fb62fd4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.dependency.tree; +import java.io.IOException; +import java.io.UncheckedIOException; import java.io.Writer; import java.util.ArrayList; import java.util.List; @@ -35,7 +37,7 @@ public class TGFDependencyNodeVisitor extends AbstractSerializingVisitor implements DependencyNodeVisitor { /** - * Utiity class to write an Edge. + * Utility class to write an Edge. * * @author Jerome Creignou */ @@ -102,18 +104,23 @@ public TGFDependencyNodeVisitor(Writer writer) { */ @Override public boolean endVisit(DependencyNode node) { - if (node.getParent() == null || node.getParent() == node) { - // dump edges on last node endVisit - writer.println("#"); - for (EdgeAppender edge : edges) { - writer.println(edge.toString()); + try { + if (node.getParent() == null || node.getParent() == node) { + // dump edges on last node endVisit + writer.write("#" + System.lineSeparator()); + for (EdgeAppender edge : edges) { + writer.write(edge.toString() + System.lineSeparator()); + } + writer.flush(); + } else { + DependencyNode parent = node.getParent(); + // using scope as edge label. + edges.add(new EdgeAppender(parent, node, node.getArtifact().getScope())); } - } else { - DependencyNode p = node.getParent(); - // using scope as edge label. - edges.add(new EdgeAppender(p, node, node.getArtifact().getScope())); + return true; + } catch (IOException e) { + throw new UncheckedIOException("Failed to write TGF format output", e); } - return true; } /** @@ -121,11 +128,17 @@ public boolean endVisit(DependencyNode node) { */ @Override public boolean visit(DependencyNode node) { - // write node - writer.write(generateId(node)); - writer.write(" "); - writer.println(node.toNodeString()); - return true; + try { + // Write node + writer.write(generateId(node)); + writer.write(" "); + writer.write(node.toNodeString()); + writer.write(System.lineSeparator()); + writer.flush(); + return true; + } catch (IOException e) { + throw new UncheckedIOException("Failed to write TGF format output", e); + } } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index b336afd24..6cfa0ef99 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -190,7 +190,7 @@ public void testTreeJsonParsing() throws Exception { List contents = runTreeMojo("tree2.json", "json"); System.setProperty("jakarta.json.provider", "org.glassfish.json.JsonProviderImpl"); - try (JsonReader reader = Json.createReader(new StringReader(String.join("\n", contents)))) { + try (JsonReader reader = Json.createReader(new StringReader(String.join(System.lineSeparator(), contents)))) { JsonObject root = reader.readObject(); assertEquals(root.getString("groupId"), "testGroupId"); From 78664f4f960c811e4de03ec20c3cfbfcc4d86f46 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 12 Aug 2025 19:34:52 +0200 Subject: [PATCH 256/283] Enable prevent branch protection rules --- .asf.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index 0a7d80dcb..2ac11146a 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -28,7 +28,10 @@ github: squash: true merge: false rebase: true - del_branch_on_merge: true + protected_branches: + master: {} + pull_requests: + del_branch_on_merge: true features: issues: true notifications: From 40b7c0f84d75e611f0253eb6974d2e4c0f140f2d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 25 Apr 2024 00:24:08 +0200 Subject: [PATCH 257/283] Build by Maven 4 --- .github/workflows/maven-verify.yml | 2 + .../projects/list-repositories/verify.groovy | 6 +- src/it/projects/tree-excluded/expected-v4.txt | 13 +++ src/it/projects/tree-excluded/verify.groovy | 5 +- .../tree-multimodule/module-a/expected-v4.txt | 14 +++ .../tree-multimodule/module-b/expected-v4.txt | 15 ++++ .../projects/tree-multimodule/test.properties | 1 - .../projects/tree-multimodule/verify.groovy | 7 +- src/it/projects/tree-scope/expected1-v4.txt | 37 ++++++++ src/it/projects/tree-scope/expected2-v4.txt | 39 ++++++++ src/it/projects/tree-scope/invoker.properties | 4 +- src/it/projects/tree-scope/test1.properties | 1 - src/it/projects/tree-scope/test2.properties | 1 - src/it/projects/tree-scope/verify.groovy | 8 +- .../module-a/expected-v4.txt | 30 +++++++ .../module-b/expected-v4.txt | 31 +++++++ .../tree-verbose-multimodule/test.properties | 1 - .../tree-verbose-multimodule/verify.groovy | 7 +- src/it/projects/tree-verbose/expected-v4.txt | 89 +++++++++++++++++++ src/it/projects/tree-verbose/test.properties | 18 ---- src/it/projects/tree-verbose/verify.groovy | 5 +- src/it/projects/tree/expected-v4.txt | 38 ++++++++ src/it/projects/tree/test.properties | 1 - src/it/projects/tree/verify.groovy | 5 +- .../dependency/ListRepositoriesMojo.java | 17 ++++ 25 files changed, 359 insertions(+), 36 deletions(-) create mode 100644 src/it/projects/tree-excluded/expected-v4.txt create mode 100644 src/it/projects/tree-multimodule/module-a/expected-v4.txt create mode 100644 src/it/projects/tree-multimodule/module-b/expected-v4.txt create mode 100644 src/it/projects/tree-scope/expected1-v4.txt create mode 100644 src/it/projects/tree-scope/expected2-v4.txt create mode 100644 src/it/projects/tree-verbose-multimodule/module-a/expected-v4.txt create mode 100644 src/it/projects/tree-verbose-multimodule/module-b/expected-v4.txt create mode 100644 src/it/projects/tree-verbose/expected-v4.txt delete mode 100644 src/it/projects/tree-verbose/test.properties create mode 100644 src/it/projects/tree/expected-v4.txt diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 932827cf9..ce4b500dc 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,3 +25,5 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 + with: + maven4-enabled: true diff --git a/src/it/projects/list-repositories/verify.groovy b/src/it/projects/list-repositories/verify.groovy index b14fc5b43..bd311cf9c 100644 --- a/src/it/projects/list-repositories/verify.groovy +++ b/src/it/projects/list-repositories/verify.groovy @@ -24,5 +24,7 @@ String buildLog = file.getText( "UTF-8" ) assert buildLog.contains( 'Project remote repositories used by this build:') assert buildLog.contains( '* fake-remote-repository (http://localhost:2345, default, releases+snapshots)') assert buildLog.contains( '* sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, default, snapshots) mirrored by mrm-maven-plugin') -assert buildLog.contains( '* central (https://repo.maven.apache.org/maven2, default, releases) mirrored by mrm-maven-plugin') - +if (!mavenVersion.startsWith('4.')) { + // Maven 4 drop central repo from default super pom - so model doesn't have it + assert buildLog.contains('* central (https://repo.maven.apache.org/maven2, default, releases) mirrored by mrm-maven-plugin') +} diff --git a/src/it/projects/tree-excluded/expected-v4.txt b/src/it/projects/tree-excluded/expected-v4.txt new file mode 100644 index 000000000..82cd95252 --- /dev/null +++ b/src/it/projects/tree-excluded/expected-v4.txt @@ -0,0 +1,13 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + +- org.apache.maven:maven-profile:jar:2.0.6:compile + +- org.apache.maven:maven-model:jar:2.0.6:compile + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + \- classworlds:classworlds:jar:1.1:compile diff --git a/src/it/projects/tree-excluded/verify.groovy b/src/it/projects/tree-excluded/verify.groovy index b79d25ba4..e9d8d8135 100644 --- a/src/it/projects/tree-excluded/verify.groovy +++ b/src/it/projects/tree-excluded/verify.groovy @@ -19,7 +19,10 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected = mavenVersion.startsWith('4.') ? "expected-v4.txt" : "expected.txt" + assertThat(new File(basedir, "target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "expected.txt")) + .hasSameTextualContentAs(new File(basedir, expected)) return true diff --git a/src/it/projects/tree-multimodule/module-a/expected-v4.txt b/src/it/projects/tree-multimodule/module-a/expected-v4.txt new file mode 100644 index 000000000..2d7981077 --- /dev/null +++ b/src/it/projects/tree-multimodule/module-a/expected-v4.txt @@ -0,0 +1,14 @@ +org.apache.maven.its.dependency:tree-multimodule-module-a:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + +- org.apache.maven:maven-profile:jar:2.0.6:compile + +- org.apache.maven:maven-model:jar:2.0.6:compile + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + \- classworlds:classworlds:jar:1.1:compile diff --git a/src/it/projects/tree-multimodule/module-b/expected-v4.txt b/src/it/projects/tree-multimodule/module-b/expected-v4.txt new file mode 100644 index 000000000..00f930ed6 --- /dev/null +++ b/src/it/projects/tree-multimodule/module-b/expected-v4.txt @@ -0,0 +1,15 @@ +org.apache.maven.its.dependency:tree-multimodule-module-b:jar:1.0-SNAPSHOT +\- org.apache.maven.its.dependency:tree-multimodule-module-a:jar:1.0-SNAPSHOT:compile + \- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + +- org.apache.maven:maven-profile:jar:2.0.6:compile + +- org.apache.maven:maven-model:jar:2.0.6:compile + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + \- classworlds:classworlds:jar:1.1:compile diff --git a/src/it/projects/tree-multimodule/test.properties b/src/it/projects/tree-multimodule/test.properties index 1a148045c..2a312e22e 100644 --- a/src/it/projects/tree-multimodule/test.properties +++ b/src/it/projects/tree-multimodule/test.properties @@ -16,4 +16,3 @@ # under the License. outputFile = target/tree.txt -maven.resolver.dependencyManagerTransitivity=false diff --git a/src/it/projects/tree-multimodule/verify.groovy b/src/it/projects/tree-multimodule/verify.groovy index 868ac9d9c..03cfc779e 100644 --- a/src/it/projects/tree-multimodule/verify.groovy +++ b/src/it/projects/tree-multimodule/verify.groovy @@ -19,13 +19,16 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected = mavenVersion.startsWith('4.') ? "expected-v4.txt" : "expected.txt" + assertThat(new File(basedir, "target/tree.txt")) .hasSameTextualContentAs(new File(basedir, "expected.txt")) assertThat(new File(basedir, "module-a/target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "module-a/expected.txt")) + .hasSameTextualContentAs(new File(basedir, "module-a/" + expected)) assertThat(new File(basedir, "module-b/target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "module-b/expected.txt")) + .hasSameTextualContentAs(new File(basedir, "module-b/" + expected)) return true; diff --git a/src/it/projects/tree-scope/expected1-v4.txt b/src/it/projects/tree-scope/expected1-v4.txt new file mode 100644 index 000000000..cbec48bd7 --- /dev/null +++ b/src/it/projects/tree-scope/expected1-v4.txt @@ -0,0 +1,37 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-core:jar:3.6.3:compile + +- org.apache.maven:maven-model:jar:3.6.3:compile + +- org.apache.maven:maven-settings:jar:3.6.3:compile + +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile + | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile + | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile + | \- org.sonatype.plexus:plexus-cipher:jar:1.7:compile + +- org.apache.maven:maven-builder-support:jar:3.6.3:compile + +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile + +- org.apache.maven:maven-artifact:jar:3.6.3:compile + +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile + +- org.apache.maven:maven-model-builder:jar:3.6.3:compile + +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile + +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile + +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile + +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile + | \- commons-io:commons-io:jar:2.5:compile + +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile + | \- javax.enterprise:cdi-api:jar:1.0:compile + | \- javax.annotation:jsr250-api:jar:1.0:compile + +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile + +- com.google.inject:guice:jar:no_aop:4.2.1:compile + | +- aopalliance:aopalliance:jar:1.0:compile + | \- com.google.guava:guava:jar:25.1-android:compile + | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile + | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile + | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile + | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile + | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile + +- javax.inject:javax.inject:jar:1:compile + +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile + +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile + +- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile + \- org.apache.commons:commons-lang3:jar:3.8.1:compile diff --git a/src/it/projects/tree-scope/expected2-v4.txt b/src/it/projects/tree-scope/expected2-v4.txt new file mode 100644 index 000000000..1b7e59ae3 --- /dev/null +++ b/src/it/projects/tree-scope/expected2-v4.txt @@ -0,0 +1,39 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT ++- org.apache.maven:maven-core:jar:3.6.3:compile +| +- org.apache.maven:maven-model:jar:3.6.3:compile +| +- org.apache.maven:maven-settings:jar:3.6.3:compile +| +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile +| | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile +| | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile +| | \- org.sonatype.plexus:plexus-cipher:jar:1.7:compile +| +- org.apache.maven:maven-builder-support:jar:3.6.3:compile +| +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile +| +- org.apache.maven:maven-artifact:jar:3.6.3:compile +| +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile +| +- org.apache.maven:maven-model-builder:jar:3.6.3:compile +| +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile +| +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile +| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile +| | \- commons-io:commons-io:jar:2.5:compile +| +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile +| | \- javax.enterprise:cdi-api:jar:1.0:compile +| | \- javax.annotation:jsr250-api:jar:1.0:compile +| +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile +| +- com.google.inject:guice:jar:no_aop:4.2.1:compile +| | +- aopalliance:aopalliance:jar:1.0:compile +| | \- com.google.guava:guava:jar:25.1-android:compile +| | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile +| | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile +| | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile +| | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile +| | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile +| +- javax.inject:javax.inject:jar:1:compile +| +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile +| +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile +| +- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile +| \- org.apache.commons:commons-lang3:jar:3.8.1:compile +\- org.slf4j:slf4j-simple:jar:2.0.13:test + \- org.slf4j:slf4j-api:jar:2.0.13:compile diff --git a/src/it/projects/tree-scope/invoker.properties b/src/it/projects/tree-scope/invoker.properties index 2535673ad..0999b3e48 100644 --- a/src/it/projects/tree-scope/invoker.properties +++ b/src/it/projects/tree-scope/invoker.properties @@ -16,7 +16,7 @@ # under the License. invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:tree -invoker.systemPropertiesFile.1 = test1.properties +invoker.userPropertiesFile.1 = test1.properties invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:tree -invoker.systemPropertiesFile.2 = test2.properties +invoker.userPropertiesFile.2 = test2.properties diff --git a/src/it/projects/tree-scope/test1.properties b/src/it/projects/tree-scope/test1.properties index 4f3ff1dc1..42b6c4298 100644 --- a/src/it/projects/tree-scope/test1.properties +++ b/src/it/projects/tree-scope/test1.properties @@ -17,4 +17,3 @@ outputFile = target/tree1.txt scope = compile -maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree-scope/test2.properties b/src/it/projects/tree-scope/test2.properties index e9d6c7d05..784d605e5 100644 --- a/src/it/projects/tree-scope/test2.properties +++ b/src/it/projects/tree-scope/test2.properties @@ -17,4 +17,3 @@ outputFile = target/tree2.txt scope = test -maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree-scope/verify.groovy b/src/it/projects/tree-scope/verify.groovy index c6ed22429..521bd47b2 100644 --- a/src/it/projects/tree-scope/verify.groovy +++ b/src/it/projects/tree-scope/verify.groovy @@ -20,10 +20,14 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected1 = mavenVersion.startsWith('4.') ? "expected1-v4.txt" : "expected1.txt" +def expected2 = mavenVersion.startsWith('4.') ? "expected2-v4.txt" : "expected2.txt" + assertThat(new File(basedir, "target/tree1.txt")) - .hasSameTextualContentAs(new File(basedir, "expected1.txt")) + .hasSameTextualContentAs(new File(basedir, expected1)) assertThat(new File(basedir, "target/tree2.txt")) - .hasSameTextualContentAs(new File(basedir, "expected2.txt")) + .hasSameTextualContentAs(new File(basedir, expected2)) return true \ No newline at end of file diff --git a/src/it/projects/tree-verbose-multimodule/module-a/expected-v4.txt b/src/it/projects/tree-verbose-multimodule/module-a/expected-v4.txt new file mode 100644 index 000000000..027731031 --- /dev/null +++ b/src/it/projects/tree-verbose-multimodule/module-a/expected-v4.txt @@ -0,0 +1,30 @@ +org.apache.maven.its.dependency:tree-multimodule-module-a:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + | +- (org.apache.maven:maven-model:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.apache.maven:maven-profile:jar:2.0.6:compile + | +- (org.apache.maven:maven-model:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.apache.maven:maven-model:jar:2.0.6:compile + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile (version managed from 2.0.6) + | | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | +- (org.apache.maven:maven-artifact:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile (version managed from 1.0-beta-2) + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) + \- classworlds:classworlds:jar:1.1:compile (version managed from 1.1-alpha-2) diff --git a/src/it/projects/tree-verbose-multimodule/module-b/expected-v4.txt b/src/it/projects/tree-verbose-multimodule/module-b/expected-v4.txt new file mode 100644 index 000000000..ffc3a86ce --- /dev/null +++ b/src/it/projects/tree-verbose-multimodule/module-b/expected-v4.txt @@ -0,0 +1,31 @@ +org.apache.maven.its.dependency:tree-multimodule-module-b:jar:1.0-SNAPSHOT +\- org.apache.maven.its.dependency:tree-multimodule-module-a:jar:1.0-SNAPSHOT:compile + \- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + | +- (org.apache.maven:maven-model:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.apache.maven:maven-profile:jar:2.0.6:compile + | +- (org.apache.maven:maven-model:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.apache.maven:maven-model:jar:2.0.6:compile + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile (version managed from 2.0.6) + | | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | +- (org.apache.maven:maven-artifact:jar:2.0.6:compile - version managed from 2.0.6; omitted for duplicate) + | +- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile (version managed from 1.0-beta-2) + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) + +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) + \- classworlds:classworlds:jar:1.1:compile (version managed from 1.1-alpha-2) diff --git a/src/it/projects/tree-verbose-multimodule/test.properties b/src/it/projects/tree-verbose-multimodule/test.properties index 1a148045c..2a312e22e 100644 --- a/src/it/projects/tree-verbose-multimodule/test.properties +++ b/src/it/projects/tree-verbose-multimodule/test.properties @@ -16,4 +16,3 @@ # under the License. outputFile = target/tree.txt -maven.resolver.dependencyManagerTransitivity=false diff --git a/src/it/projects/tree-verbose-multimodule/verify.groovy b/src/it/projects/tree-verbose-multimodule/verify.groovy index 868ac9d9c..03cfc779e 100644 --- a/src/it/projects/tree-verbose-multimodule/verify.groovy +++ b/src/it/projects/tree-verbose-multimodule/verify.groovy @@ -19,13 +19,16 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected = mavenVersion.startsWith('4.') ? "expected-v4.txt" : "expected.txt" + assertThat(new File(basedir, "target/tree.txt")) .hasSameTextualContentAs(new File(basedir, "expected.txt")) assertThat(new File(basedir, "module-a/target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "module-a/expected.txt")) + .hasSameTextualContentAs(new File(basedir, "module-a/" + expected)) assertThat(new File(basedir, "module-b/target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "module-b/expected.txt")) + .hasSameTextualContentAs(new File(basedir, "module-b/" + expected)) return true; diff --git a/src/it/projects/tree-verbose/expected-v4.txt b/src/it/projects/tree-verbose/expected-v4.txt new file mode 100644 index 000000000..e0095ea97 --- /dev/null +++ b/src/it/projects/tree-verbose/expected-v4.txt @@ -0,0 +1,89 @@ +org.apache.maven.its.dependency:tree-verbose:jar:1.0-SNAPSHOT ++- org.apache.maven:maven-project:jar:2.0.6:compile +| +- org.apache.maven:maven-settings:jar:2.0.6:compile +| | +- (org.apache.maven:maven-model:jar:2.0.5:test - version managed from 2.0.6; scope managed from compile; omitted for conflict with 2.0.7) +| | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) +| | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) +| +- (org.apache.maven:maven-profile:jar:2.0.6:compile - omitted for conflict with 2.0.4) +| +- (org.apache.maven:maven-model:jar:2.0.5:test - version managed from 2.0.6; scope managed from compile; omitted for conflict with 2.0.7) +| +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile +| | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile (version managed from 2.0.6) +| | | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) +| | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) +| | +- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) +| | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile (version managed from 1.0-beta-2) +| | \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) +| +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile +| | +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.4.1; omitted for duplicate) +| | \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile - version managed from 1.0-alpha-9-stable-1; omitted for duplicate) +| +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile +| \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile +| +- junit:junit:jar:3.8.1:compile +| +- (org.codehaus.plexus:plexus-utils:jar:1.4.1:compile - version managed from 1.0.4; omitted for duplicate) +| \- classworlds:classworlds:jar:1.1:compile (version managed from 1.1-alpha-2) ++- org.apache.maven:maven-profile:jar:2.0.4:test (scope not updated to compile) +| +- (org.apache.maven:maven-model:jar:2.0.5:test - version managed from 2.0.4; scope managed from compile; omitted for conflict with 2.0.7) +| +- (org.codehaus.plexus:plexus-utils:jar:1.1:test - omitted for conflict with 1.4.1) +| \- (org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9:test - omitted for conflict with 1.0-alpha-9-stable-1) ++- org.apache.maven:maven-model:jar:2.0.7:runtime +| \- (org.codehaus.plexus:plexus-utils:jar:1.4.1:runtime - omitted for duplicate) +\- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile + +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-dom:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-ext:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-parser:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | +- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile + | \- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-css:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-ext:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | +- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-css:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-ext:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-xml:jar:1.7:compile - omitted for duplicate) + | +- (xalan:xalan:jar:2.6.0:compile - omitted for duplicate) + | +- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile + | \- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | \- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-parser:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | \- (org.apache.xmlgraphics:batik-xml:jar:1.7:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-script:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-dom:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-ext:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | +- org.apache.xmlgraphics:batik-js:jar:1.7:compile + | | \- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + | \- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile + | +- (org.apache.xmlgraphics:batik-anim:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-css:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-dom:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-ext:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-parser:jar:1.7:compile - omitted for duplicate) + | +- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + | +- (xml-apis:xml-apis:jar:1.3.04:compile - omitted for duplicate) + | \- (xml-apis:xml-apis-ext:jar:1.3.04:compile - omitted for duplicate) + +- org.apache.xmlgraphics:batik-util:jar:1.7:compile + +- org.apache.xmlgraphics:batik-xml:jar:1.7:compile + | \- (org.apache.xmlgraphics:batik-util:jar:1.7:compile - omitted for duplicate) + +- xalan:xalan:jar:2.6.0:compile + | \- (xml-apis:xml-apis:jar:1.0.b2:compile - omitted for conflict with 1.3.04) + +- xml-apis:xml-apis:jar:1.3.04:compile + \- xml-apis:xml-apis-ext:jar:1.3.04:compile diff --git a/src/it/projects/tree-verbose/test.properties b/src/it/projects/tree-verbose/test.properties deleted file mode 100644 index 08bf0c035..000000000 --- a/src/it/projects/tree-verbose/test.properties +++ /dev/null @@ -1,18 +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. - -maven.resolver.dependencyManagerTransitivity=false diff --git a/src/it/projects/tree-verbose/verify.groovy b/src/it/projects/tree-verbose/verify.groovy index b79d25ba4..e9d8d8135 100644 --- a/src/it/projects/tree-verbose/verify.groovy +++ b/src/it/projects/tree-verbose/verify.groovy @@ -19,7 +19,10 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected = mavenVersion.startsWith('4.') ? "expected-v4.txt" : "expected.txt" + assertThat(new File(basedir, "target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "expected.txt")) + .hasSameTextualContentAs(new File(basedir, expected)) return true diff --git a/src/it/projects/tree/expected-v4.txt b/src/it/projects/tree/expected-v4.txt new file mode 100644 index 000000000..91703010d --- /dev/null +++ b/src/it/projects/tree/expected-v4.txt @@ -0,0 +1,38 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT ++- org.apache.maven:maven-core:jar:3.6.3:compile +| +- org.apache.maven:maven-model:jar:3.6.3:compile +| +- org.apache.maven:maven-settings:jar:3.6.3:compile +| +- org.apache.maven:maven-settings-builder:jar:3.6.3:compile +| | +- org.codehaus.plexus:plexus-interpolation:jar:1.25:compile +| | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile +| | \- org.sonatype.plexus:plexus-cipher:jar:1.7:compile +| +- org.apache.maven:maven-builder-support:jar:3.6.3:compile +| +- org.apache.maven:maven-repository-metadata:jar:3.6.3:compile +| +- org.apache.maven:maven-artifact:jar:3.6.3:compile +| +- org.apache.maven:maven-plugin-api:jar:3.6.3:compile +| +- org.apache.maven:maven-model-builder:jar:3.6.3:compile +| +- org.apache.maven:maven-resolver-provider:jar:3.6.3:compile +| | \- org.slf4j:slf4j-api:jar:1.7.29:compile +| +- org.apache.maven.resolver:maven-resolver-impl:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-spi:jar:1.4.1:compile +| +- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:compile +| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile +| | \- commons-io:commons-io:jar:2.5:compile +| +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.4:compile +| | \- javax.enterprise:cdi-api:jar:1.0:compile +| | \- javax.annotation:jsr250-api:jar:1.0:compile +| +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.4:compile +| +- com.google.inject:guice:jar:no_aop:4.2.1:compile +| | +- aopalliance:aopalliance:jar:1.0:compile +| | \- com.google.guava:guava:jar:25.1-android:compile +| | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile +| | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile +| | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile +| | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile +| | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile +| +- javax.inject:javax.inject:jar:1:compile +| +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile +| +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile +| \- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile +\- org.apache.commons:commons-lang3:jar:3.14.0:compile (optional) \ No newline at end of file diff --git a/src/it/projects/tree/test.properties b/src/it/projects/tree/test.properties index 2cc9c4a0d..2a312e22e 100644 --- a/src/it/projects/tree/test.properties +++ b/src/it/projects/tree/test.properties @@ -16,4 +16,3 @@ # under the License. outputFile = target/tree.txt -maven.resolver.dependencyManagerTransitivity = false diff --git a/src/it/projects/tree/verify.groovy b/src/it/projects/tree/verify.groovy index b79d25ba4..e9d8d8135 100644 --- a/src/it/projects/tree/verify.groovy +++ b/src/it/projects/tree/verify.groovy @@ -19,7 +19,10 @@ import static org.assertj.core.api.Assertions.assertThat +// Maven 4 use transitive dependency manager +def expected = mavenVersion.startsWith('4.') ? "expected-v4.txt" : "expected.txt" + assertThat(new File(basedir, "target/tree.txt")) - .hasSameTextualContentAs(new File(basedir, "expected.txt")) + .hasSameTextualContentAs(new File(basedir, expected)) return true diff --git a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java index 07cd668c8..01b9cc21c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/ListRepositoriesMojo.java @@ -99,6 +99,7 @@ protected void doExecute() throws MojoExecutionException { @Override public boolean visitEnter(DependencyNode node) { repositories.addAll(node.getRepositories()); + debugLogNodeRepo(node); return true; } @@ -131,6 +132,22 @@ public boolean visitLeave(DependencyNode node) { } } + private void debugLogNodeRepo(DependencyNode node) { + if (!getLog().isDebugEnabled()) { + return; + } + + getLog().debug("Node: " + node + " resolved from:"); + node.getRepositories().forEach(repo -> { + if (repo.getMirroredRepositories().isEmpty()) { + getLog().debug(" - " + repo); + } else { + getLog().debug(" - " + repo + " as mirror for:"); + repo.getMirroredRepositories().forEach(mrepo -> getLog().debug(" - " + mrepo)); + } + }); + } + private void prepareRemoteMirrorRepositoriesList( StringBuilder message, Collection remoteProjectRepositories) { From b9c6c2c2459926bcb36f48ea9fe1d62fca432175 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 07:49:34 +0200 Subject: [PATCH 258/283] Bump org.codehaus.plexus:plexus-archiver from 4.10.0 to 4.10.1 (#1505) Bumps [org.codehaus.plexus:plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) from 4.10.0 to 4.10.1. - [Release notes](https://github.com/codehaus-plexus/plexus-archiver/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-archiver/compare/plexus-archiver-4.10.0...plexus-archiver-4.10.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-archiver dependency-version: 4.10.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index be0d210c1..8c610ba4a 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ under the License. 1.7.36 9.4.57.v20241219 4.11.0 - 4.10.0 + 4.10.1 3.3.0 2024-10-18T18:16:14Z From 9a73a352a708c052f5604953e250d72917a0667e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:58:57 +0000 Subject: [PATCH 259/283] Bump jettyVersion from 9.4.57.v20241219 to 9.4.58.v20250814 Bumps `jettyVersion` from 9.4.57.v20241219 to 9.4.58.v20250814. Updates `org.eclipse.jetty:jetty-server` from 9.4.57.v20241219 to 9.4.58.v20250814 Updates `org.eclipse.jetty:jetty-util` from 9.4.57.v20241219 to 9.4.58.v20250814 Updates `org.eclipse.jetty:jetty-security` from 9.4.57.v20241219 to 9.4.58.v20250814 --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-server dependency-version: 9.4.58.v20250814 dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-util dependency-version: 9.4.58.v20250814 dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-security dependency-version: 9.4.58.v20250814 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c610ba4a..45768665d 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ under the License. 3.6.3 1.4.1 1.7.36 - 9.4.57.v20241219 + 9.4.58.v20250814 4.11.0 4.10.1 3.3.0 From 1deae6751904b848c58e6a7c9f255ed6d63551be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 22:27:37 +0000 Subject: [PATCH 260/283] Bump org.codehaus.mojo:mrm-maven-plugin from 1.6.0 to 1.7.0 Bumps [org.codehaus.mojo:mrm-maven-plugin](https://github.com/mojohaus/mrm) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/mojohaus/mrm/releases) - [Commits](https://github.com/mojohaus/mrm/compare/1.6.0...1.7.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mrm-maven-plugin dependency-version: 1.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 45768665d..287230c07 100644 --- a/pom.xml +++ b/pom.xml @@ -507,7 +507,7 @@ under the License. org.codehaus.mojo mrm-maven-plugin - 1.6.0 + 1.7.0 repository.proxy.url From 9bdfecf8ebf91183e396c0cd80506e1bc56116f9 Mon Sep 17 00:00:00 2001 From: Ndacyayisenga-droid Date: Thu, 26 Jun 2025 09:07:26 +0300 Subject: [PATCH 261/283] [MDEP-979] Clean up AbstractDependencyMojoTestCase setUp --- .../AbstractDependencyMojoTestCase.java | 55 ++++++++++++++++--- .../plugins/dependency/TestCollectMojo.java | 13 ++++- .../maven/plugins/dependency/TestGetMojo.java | 13 ++++- .../dependency/TestListClassesMojo.java | 13 ++++- .../dependency/TestPropertiesMojo.java | 14 ++++- .../exclusion/AnalyzeExclusionsMojoTest.java | 20 ++++++- .../fromConfiguration/TestArtifactItem.java | 14 ++++- .../fromConfiguration/TestCopyMojo.java | 19 ++++++- .../TestIncludeExcludeUnpackMojo.java | 18 +++++- .../fromConfiguration/TestUnpackMojo.java | 19 ++++++- .../TestBuildClasspathMojo.java | 13 ++++- .../TestCopyDependenciesMojo.java | 17 +++++- .../TestCopyDependenciesMojo2.java | 12 +++- ...tIncludeExcludeUnpackDependenciesMojo.java | 13 ++++- .../TestUnpackDependenciesMojo.java | 18 +++++- .../TestUnpackDependenciesMojo2.java | 13 ++++- .../resolvers/GoOfflineMojoTest.java | 13 ++++- .../ResolveDependenciesMojoTest.java | 13 ++++- .../dependency/resolvers/TestResolveMojo.java | 12 +++- .../plugins/dependency/tree/TestTreeMojo.java | 12 +++- .../utils/TestDependencyStatusSets.java | 13 ++++- .../TestClassifierTypeTranslator.java | 12 +++- 22 files changed, 328 insertions(+), 31 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java index 9681f242e..7e1006770 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTestCase.java @@ -43,25 +43,62 @@ public abstract class AbstractDependencyMojoTestCase extends AbstractMojoTestCas protected DependencyArtifactStubFactory stubFactory; - protected void setUp(String testDirectoryName, boolean createFiles) throws Exception { - setUp(testDirectoryName, createFiles, true); - } - - protected void setUp(String testDirectoryName, boolean createFiles, boolean flattenedPath) throws Exception { - // required for mojo lookups to work + /** + * Initializes the test environment by creating a temporary directory and setting up the stub factory. + * Subclasses must call super.setUp() in their own setUp method to ensure proper initialization. + * To customize the test directory name, file creation, or path structure, override getTestDirectoryName(), + * shouldCreateFiles(), and shouldUseFlattenedPath() respectively. + * + * @throws Exception if setup fails + */ + protected void setUp() throws Exception { + // Required for mojo lookups to work super.setUp(); - testDir = Files.createTempDirectory(testDirectoryName).toFile(); + testDir = Files.createTempDirectory(getTestDirectoryName()).toFile(); testDir.deleteOnExit(); - stubFactory = new DependencyArtifactStubFactory(this.testDir, createFiles, flattenedPath); + stubFactory = new DependencyArtifactStubFactory(testDir, shouldCreateFiles(), shouldUseFlattenedPath()); + } + + /** + * Returns the name of the temporary test directory. Subclasses can override to customize. + * + * @return the test directory name + */ + protected String getTestDirectoryName() { + return "test-dir"; + } + + /** + * Determines whether files should be created by the stub factory. Subclasses can override to customize. + * + * @return true if files should be created, false otherwise + */ + protected boolean shouldCreateFiles() { + return true; + } + + /** + * Determines whether the stub factory should use flattened paths. Subclasses can override to customize. + * + * @return true if flattened paths should be used, false otherwise + */ + protected boolean shouldUseFlattenedPath() { + return true; } + /** + * Cleans up the test environment by deleting the temporary directory. + * Subclasses must call super.tearDown() in their own tearDown method to ensure proper cleanup. + * + * @throws Exception if cleanup fails + */ @Override protected void tearDown() throws Exception { if (testDir != null) { FileUtils.deleteDirectory(testDir); - assertFalse(testDir.exists()); + assertFalse("Test directory should not exist after cleanup", testDir.exists()); } super.tearDown(); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 71fb6a03c..f93ee2cef 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -32,10 +32,21 @@ public class TestCollectMojo extends AbstractDependencyMojoTestCase { + @Override + protected String getTestDirectoryName() { + return "markers"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("markers", false); + super.setUp(); + MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java index fd820791d..ae793392d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java @@ -47,9 +47,20 @@ public class TestGetMojo extends AbstractDependencyMojoTestCase { private GetMojo mojo; + @Override + protected String getTestDirectoryName() { + return "markers"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("markers", false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index 0d79086f4..1569b9173 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -38,8 +38,19 @@ public class TestListClassesMojo extends AbstractDependencyMojoTestCase { private ListClassesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "markers"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + + @Override protected void setUp() throws Exception { - super.setUp("markers", false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java index 75ae7cab0..2e3db085f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java @@ -27,9 +27,21 @@ import org.apache.maven.project.MavenProject; public class TestPropertiesMojo extends AbstractDependencyMojoTestCase { + + @Override + protected String getTestDirectoryName() { + return "markers"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("markers", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index f4e37d424..4c69bfd1e 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -60,8 +60,24 @@ public class AnalyzeExclusionsMojoTest extends AbstractDependencyMojoTestCase { private ResolverUtil resolverUtil; @Override - public void setUp() throws Exception { - super.setUp("analyze-exclusions", true, false); + protected String getTestDirectoryName() { + return "analyze-exclusions"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + + @Override + protected void setUp() throws Exception { + // required for mojo lookups to work + super.setUp(); project = new DependencyProjectStub(); project.setName("projectName"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java index 9aa993f86..63fefb1de 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestArtifactItem.java @@ -25,8 +25,20 @@ public class TestArtifactItem extends AbstractDependencyMojoTestCase { + @Override + protected String getTestDirectoryName() { + return "artifactItems"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + + @Override protected void setUp() throws Exception { - setUp("artifactItems", false); + // required for mojo lookups to work + super.setUp(); } public void testArtifactItemConstructor() throws IOException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index 1836b1d33..ef0013353 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -38,9 +38,26 @@ public class TestCopyMojo extends AbstractDependencyMojoTestCase { private CopyMojo mojo; + @Override + protected String getTestDirectoryName() { + return "copy"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + @Override protected void setUp() throws Exception { - super.setUp("copy", false, false); + // required for mojo lookups to work + super.setUp(); + MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index e72e30a1f..f42e42aed 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -43,9 +43,25 @@ public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase private UnpackMojo mojo; + @Override + protected String getTestDirectoryName() { + return "unpack"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("unpack", true, false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index f18776fb0..0b8d44443 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -45,8 +45,25 @@ public class TestUnpackMojo extends AbstractDependencyMojoTestCase { UnpackMojo mojo; + @Override + protected String getTestDirectoryName() { + return "unpack"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + + @Override protected void setUp() throws Exception { - super.setUp("unpack", true, false); + // required for mojo lookups to work + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index f310ec0df..86856c633 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -33,9 +33,20 @@ public class TestBuildClasspathMojo extends AbstractDependencyMojoTestCase { private BuildClasspathMojo mojo; + @Override + protected String getTestDirectoryName() { + return "build-classpath"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("build-classpath", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index 36e85399b..bd5043bd8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -43,10 +43,25 @@ public class TestCopyDependenciesMojo extends AbstractDependencyMojoTestCase { CopyDependenciesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "copy-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("copy-dependencies", true, false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index bb554d33f..ae53378fb 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -51,10 +51,20 @@ public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { private CopyDependenciesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "copy-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("copy-dependencies", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 675e48e37..eeb093818 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -38,9 +38,20 @@ public class TestIncludeExcludeUnpackDependenciesMojo extends AbstractDependency private UnpackDependenciesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "unpack-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("unpack-dependencies", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index 4f66e6d61..98ddc8135 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -50,9 +50,25 @@ public class TestUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { UnpackDependenciesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "unpack-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("unpack-dependencies", true, false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 8f576da41..932dbb564 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -45,9 +45,20 @@ public class TestUnpackDependenciesMojo2 extends AbstractDependencyMojoTestCase private UnpackDependenciesMojo mojo; + @Override + protected String getTestDirectoryName() { + return "unpack-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("unpack-dependencies", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java index af3938585..9c48d72c8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojoTest.java @@ -34,9 +34,20 @@ public class GoOfflineMojoTest extends AbstractDependencyMojoTestCase { private GoOfflineMojo subject; + @Override + protected String getTestDirectoryName() { + return "go-offline"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("go-offline", true); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index c59b02542..da3b9f8f5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -28,10 +28,21 @@ import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; public class ResolveDependenciesMojoTest extends AbstractDependencyMojoTestCase { + + @Override + protected String getTestDirectoryName() { + return "dss"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("dss", true); + super.setUp(); } public void testDependencyStatusLog() throws IOException { diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 2bdcb6fc8..2a5d2d843 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -31,10 +31,20 @@ public class TestResolveMojo extends AbstractDependencyMojoTestCase { + @Override + protected String getTestDirectoryName() { + return "markers"; + } + + @Override + protected boolean shouldCreateFiles() { + return false; + } + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("markers", false); + super.setUp(); MavenProject project = new DependencyProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index 6cfa0ef99..b34fa55b4 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -56,13 +56,23 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { // TestCase methods ------------------------------------------------------- + @Override + protected String getTestDirectoryName() { + return "tree"; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + /* * @see org.apache.maven.plugin.testing.AbstractMojoTestCase#setUp() */ @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("tree", false); + super.setUp(); MavenProject project = new MavenProjectStub(); getContainer().addComponent(project, MavenProject.class.getName()); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java index 7da3810f7..58b33a84a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java @@ -22,9 +22,20 @@ public class TestDependencyStatusSets extends AbstractDependencyMojoTestCase { + @Override + protected String getTestDirectoryName() { + return "dss"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override protected void setUp() throws Exception { // required for mojo lookups to work - super.setUp("dss", true); + super.setUp(); } public void testDependencyStatusSettersGetters() { diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index 86b35142e..39c59a7dd 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -48,9 +48,19 @@ public class TestClassifierTypeTranslator extends AbstractDependencyMojoTestCase private ArtifactHandlerManager artifactHandlerManager; + @Override + protected String getTestDirectoryName() { + return "classifiertype-translator"; + } + + @Override + protected boolean shouldUseFlattenedPath() { + return false; + } + @Override protected void setUp() throws Exception { - super.setUp("classifiertype-translator", false); + super.setUp(); artifactHandlerManager = new DefaultArtifactHandlerManager(); this.setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap<>()); From 3982da611d034db5b0388059f5ee9f28115f1551 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 20:28:04 +0000 Subject: [PATCH 262/283] Bump org.apache.commons:commons-lang3 in /src/it/projects/tree Bumps org.apache.commons:commons-lang3 from 3.14.0 to 3.18.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-version: 3.18.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/it/projects/tree/expected-v4.txt | 2 +- src/it/projects/tree/expected.txt | 2 +- src/it/projects/tree/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/it/projects/tree/expected-v4.txt b/src/it/projects/tree/expected-v4.txt index 91703010d..48b9a84f6 100644 --- a/src/it/projects/tree/expected-v4.txt +++ b/src/it/projects/tree/expected-v4.txt @@ -35,4 +35,4 @@ org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT | +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile | +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile | \- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile -\- org.apache.commons:commons-lang3:jar:3.14.0:compile (optional) \ No newline at end of file +\- org.apache.commons:commons-lang3:jar:3.18.0:compile (optional) diff --git a/src/it/projects/tree/expected.txt b/src/it/projects/tree/expected.txt index a1fe1338f..0c8f28deb 100644 --- a/src/it/projects/tree/expected.txt +++ b/src/it/projects/tree/expected.txt @@ -35,4 +35,4 @@ org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT | +- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile | +- org.codehaus.plexus:plexus-classworlds:jar:2.6.0:compile | \- org.codehaus.plexus:plexus-component-annotations:jar:2.1.0:compile -\- org.apache.commons:commons-lang3:jar:3.14.0:compile (optional) \ No newline at end of file +\- org.apache.commons:commons-lang3:jar:3.18.0:compile (optional) diff --git a/src/it/projects/tree/pom.xml b/src/it/projects/tree/pom.xml index d18c8ffdd..c757695b3 100644 --- a/src/it/projects/tree/pom.xml +++ b/src/it/projects/tree/pom.xml @@ -45,7 +45,7 @@ org.apache.commons commons-lang3 - 3.14.0 + 3.18.0 true From 35949b16427e0272d86da1c2e90174df5b2477ce Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 23 Aug 2025 14:31:43 +0200 Subject: [PATCH 263/283] Add tag-template to release-drafter configuration --- .github/release-drafter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 20ebf6c34..9b801fc6b 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -18,3 +18,4 @@ # under the License. _extends: maven-gh-actions-shared +tag-template: maven-dependency-plugin-$RESOLVED_VERSION From 7436d59d99c5b242192a1fcedf579e61fff844b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 17:07:34 +0200 Subject: [PATCH 264/283] Bump org.jsoup:jsoup from 1.21.1 to 1.21.2 (#1509) Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.21.1 to 1.21.2. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.21.1...jsoup-1.21.2) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-version: 1.21.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 287230c07..015fd6aa7 100644 --- a/pom.xml +++ b/pom.xml @@ -500,7 +500,7 @@ under the License. org.jsoup jsoup - 1.21.1 + 1.21.2 From 58604f9cd6c5d29299e07d74fb74de1053de57b4 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 23 Aug 2025 16:19:23 +0200 Subject: [PATCH 265/283] Update site descriptor to 2.0.0 --- src/site/site.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/site.xml b/src/site/site.xml index a7f5a4b32..fe973276c 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -19,8 +19,8 @@ specific language governing permissions and limitations under the License. --> - + @@ -48,4 +48,4 @@ under the License. - + From 0ece27d9414d2ce874ea40fb5b2122395595225c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 22:01:21 +0200 Subject: [PATCH 266/283] Bump org.codehaus.plexus:plexus-i18n from 1.0-beta-10 to 1.0.0 (#1510) * Bump org.codehaus.plexus:plexus-i18n from 1.0-beta-10 to 1.0.0 Bumps [org.codehaus.plexus:plexus-i18n](https://github.com/codehaus-plexus/plexus-i18n) from 1.0-beta-10 to 1.0.0. - [Release notes](https://github.com/codehaus-plexus/plexus-i18n/releases) - [Commits](https://github.com/codehaus-plexus/plexus-i18n/commits/plexus-i18n-1.0.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-i18n dependency-version: 1.0.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Remove exclusions from plexus-i18n dependency --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sylwester Lachiewicz --- pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 015fd6aa7..d98f14e49 100644 --- a/pom.xml +++ b/pom.xml @@ -198,13 +198,7 @@ under the License. org.codehaus.plexus plexus-i18n - 1.0-beta-10 - - - org.codehaus.plexus - plexus-component-api - - + 1.0.0 From d52bc1f8fb396a14a107080850f829a0be2719bf Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 1 Sep 2025 22:52:33 +0200 Subject: [PATCH 267/283] Re-run failed tests and redirect outputs from tests to file some test are flaky, try to re-run it make build more stable tests generate many debug outputs, it is not needed by default --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index d98f14e49..ac62cec8f 100644 --- a/pom.xml +++ b/pom.xml @@ -452,6 +452,8 @@ under the License. -Xmx512m + 2 + true From a69038f1ad242e67ef1fa419d7f9c2d5b13c3b00 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 3 Sep 2025 00:15:45 +0200 Subject: [PATCH 268/283] Use Resolver API in copy and unpack Next step to remove maven-artifact-transfer and legacy staff --- .../AbstractFromConfigurationMojo.java | 94 +++++++++++-------- .../fromConfiguration/CopyMojo.java | 10 +- .../fromConfiguration/UnpackMojo.java | 10 +- .../exclusion/AnalyzeExclusionsMojoTest.java | 5 - .../fromConfiguration/TestCopyMojo.java | 15 +-- .../fromConfiguration/TestUnpackMojo.java | 14 +-- .../TestClassifierTypeTranslator.java | 15 --- 7 files changed, 65 insertions(+), 98 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index e06765e14..0cb048149 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -24,6 +24,7 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -36,12 +37,17 @@ import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; -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.apache.maven.shared.transfer.repository.RepositoryManager; +import org.eclipse.aether.DefaultRepositoryCache; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -112,23 +118,19 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo @Parameter private File localRepositoryDirectory; - private final ArtifactResolver artifactResolver; - - private final RepositoryManager repositoryManager; - private final ArtifactHandlerManager artifactHandlerManager; + private final RepositorySystem repositorySystem; + protected AbstractFromConfigurationMojo( MavenSession session, BuildContext buildContext, MavenProject project, - ArtifactResolver artifactResolver, - RepositoryManager repositoryManager, - ArtifactHandlerManager artifactHandlerManager) { + ArtifactHandlerManager artifactHandlerManager, + RepositorySystem repositorySystem) { super(session, buildContext, project); - this.artifactResolver = artifactResolver; - this.repositoryManager = repositoryManager; this.artifactHandlerManager = artifactHandlerManager; + this.repositorySystem = repositorySystem; } abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item); @@ -156,9 +158,9 @@ protected void verifyRequirements() throws MojoFailureException { protected List getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) throws MojoExecutionException { - boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(), - prependGroupId = processArtifactItemsRequest.isPrependGroupId(), - useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); + boolean removeVersion = processArtifactItemsRequest.isRemoveVersion(); + boolean prependGroupId = processArtifactItemsRequest.isPrependGroupId(); + boolean useBaseVersion = processArtifactItemsRequest.isUseBaseVersion(); boolean removeClassifier = processArtifactItemsRequest.isRemoveClassifier(); @@ -196,11 +198,31 @@ protected List getProcessedArtifactItems(ProcessArtifactItemsReque return artifactItems; } - private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException, ArtifactFilterException { + private boolean checkIfProcessingNeeded(ArtifactItem item) throws ArtifactFilterException { return "true".equalsIgnoreCase(item.getOverWrite()) || getMarkedArtifactFilter(item).isArtifactIncluded(item); } + private RepositorySystemSession createSystemSessionForLocalRepo() { + RepositorySystemSession repositorySystemSession = session.getRepositorySession(); + if (localRepositoryDirectory != null) { + // "clone" repository session and replace localRepository + DefaultRepositorySystemSession newSession = + new DefaultRepositorySystemSession(session.getRepositorySession()); + // Clear cache, since we're using a new local repository + newSession.setCache(new DefaultRepositoryCache()); + LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager( + newSession, new LocalRepository(localRepositoryDirectory)); + + newSession.setLocalRepositoryManager(localRepositoryManager); + repositorySystemSession = newSession; + getLog().debug("localRepoPath: " + + localRepositoryManager.getRepository().getBasedir()); + } + + return repositorySystemSession; + } + /** * Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved * from the dependency list or from the DependencyManagement section of the pom. @@ -210,23 +232,8 @@ private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionE * @throws MojoExecutionException if the version can't be found in DependencyManagement */ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException { - Artifact artifact; try { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - if (localRepositoryDirectory != null) { - buildingRequest = - repositoryManager.setLocalRepositoryBasedir(buildingRequest, localRepositoryDirectory); - } - - // Map dependency to artifact coordinate - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId(artifactItem.getGroupId()); - coordinate.setArtifactId(artifactItem.getArtifactId()); - coordinate.setVersion(artifactItem.getVersion()); - coordinate.setClassifier(artifactItem.getClassifier()); - final String extension; ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(artifactItem.getType()); @@ -235,16 +242,23 @@ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionEx } else { extension = artifactItem.getType(); } - coordinate.setExtension(extension); - artifact = artifactResolver - .resolveArtifact(buildingRequest, coordinate) - .getArtifact(); - } catch (ArtifactResolverException e) { + DefaultArtifact artifact = new DefaultArtifact( + artifactItem.getGroupId(), + artifactItem.getArtifactId(), + artifactItem.getClassifier(), + extension, + artifactItem.getVersion()); + + RepositorySystemSession repositorySession = createSystemSessionForLocalRepo(); + + ArtifactRequest request = new ArtifactRequest(artifact, getProject().getRemoteProjectRepositories(), null); + ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySession, request); + return RepositoryUtils.toArtifact(artifactResult.getArtifact()); + + } catch (ArtifactResolutionException e) { throw new MojoExecutionException("Unable to find/resolve artifact.", e); } - - return artifact; } /** diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index 123e76825..91499fdd9 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -36,8 +36,7 @@ import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugins.dependency.utils.filters.DestFileFilter; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.eclipse.aether.RepositorySystem; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -92,11 +91,10 @@ public CopyMojo( MavenSession session, BuildContext buildContext, MavenProject project, - ArtifactResolver artifactResolver, - RepositoryManager repositoryManager, ArtifactHandlerManager artifactHandlerManager, - CopyUtil copyUtil) { - super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager); + CopyUtil copyUtil, + RepositorySystem repositorySystem) { + super(session, buildContext, project, artifactHandlerManager, repositorySystem); this.copyUtil = copyUtil; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 46476a99a..58349e38a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -36,9 +36,8 @@ import org.apache.maven.plugins.dependency.utils.markers.MarkerHandler; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.codehaus.plexus.components.io.filemappers.FileMapper; +import org.eclipse.aether.RepositorySystem; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -110,11 +109,10 @@ public UnpackMojo( MavenSession session, BuildContext buildContext, MavenProject project, - ArtifactResolver artifactResolver, - RepositoryManager repositoryManager, ArtifactHandlerManager artifactHandlerManager, - UnpackUtil unpackUtil) { - super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager); + UnpackUtil unpackUtil, + RepositorySystem repositorySystem) { + super(session, buildContext, project, artifactHandlerManager, repositorySystem); this.unpackUtil = unpackUtil; } diff --git a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java index 4c69bfd1e..d0da7947a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java @@ -34,7 +34,6 @@ import org.apache.maven.model.Exclusion; import org.apache.maven.model.InputLocation; import org.apache.maven.model.InputSource; -import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; @@ -97,10 +96,6 @@ protected void setUp() throws Exception { mojo = (AnalyzeExclusionsMojo) lookupMojo("analyze-exclusions", testPom); assertNotNull(mojo); - LegacySupport legacySupport = lookup(LegacySupport.class); - legacySupport.setSession(session); - installLocalRepository(legacySupport); - testLog = new TestLog(); mojo.setLog(testLog); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index ef0013353..9040e73b1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; -import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; @@ -71,9 +70,7 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - LegacySupport legacySupport = lookup(LegacySupport.class); - legacySupport.setSession(session); - installLocalRepository(legacySupport); + installLocalRepository(session.getRepositorySession()); } private ArtifactItem getSingleArtifactItem(boolean removeVersion, boolean useBaseVersion) @@ -147,7 +144,7 @@ public void assertFileExists(ArtifactItem item, boolean exist) { } public void testMojoDefaults() { - CopyMojo theMojo = new CopyMojo(null, null, null, null, null, null, null); + CopyMojo theMojo = new CopyMojo(null, null, null, null, null, null); assertFalse(theMojo.isStripVersion()); assertFalse(theMojo.isSkip()); @@ -507,14 +504,6 @@ public void testMissingVersionFromDependencyMgtWithClassifier() throws Exception } public void testArtifactNotFound() throws Exception { - dotestArtifactExceptions(false, true); - } - - public void testArtifactResolutionException() throws Exception { - dotestArtifactExceptions(true, false); - } - - public void dotestArtifactExceptions(boolean are, boolean anfe) throws Exception { ArtifactItem item = new ArtifactItem(); item.setArtifactId("artifactId"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 0b8d44443..4346ed946 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; -import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; @@ -87,10 +86,7 @@ protected void setUp() throws Exception { stubFactory.setSrcFile(new File( getBasedir() + File.separatorChar + "target/test-classes/unit/unpack-dependencies-test/test.txt")); - LegacySupport legacySupport = lookup(LegacySupport.class); - - legacySupport.setSession(session); - installLocalRepository(legacySupport); + installLocalRepository(session.getRepositorySession()); } public ArtifactItem getSingleArtifactItem(boolean removeVersion) throws MojoExecutionException { @@ -374,14 +370,6 @@ public void testMissingVersionFromDependencyMgtWithClassifier() throws Exception } public void testArtifactNotFound() throws Exception { - dotestArtifactExceptions(false, true); - } - - public void testArtifactResolutionException() throws Exception { - dotestArtifactExceptions(true, false); - } - - public void dotestArtifactExceptions(boolean are, boolean anfe) throws Exception { ArtifactItem item = new ArtifactItem(); item.setArtifactId("artifactId"); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index 39c59a7dd..1ffea9631 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -26,13 +26,8 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.SilentLog; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; @@ -42,8 +37,6 @@ public class TestClassifierTypeTranslator extends AbstractDependencyMojoTestCase { Set artifacts = new HashSet<>(); - ArtifactRepository artifactRepository; - Log log = new SilentLog(); private ArtifactHandlerManager artifactHandlerManager; @@ -65,16 +58,8 @@ protected void setUp() throws Exception { artifactHandlerManager = new DefaultArtifactHandlerManager(); this.setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap<>()); - artifactRepository = new StubArtifactRepository(null); - DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory(null, false); artifacts = factory.getMixedArtifacts(); - - LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession session = newMavenSession(new MavenProjectStub()); - legacySupport.setSession(session); - - installLocalRepository(legacySupport); } public void testNullClassifier() { From 7b5c7ad31866fdd78db237960bba84f44ed9d119 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 3 Sep 2025 23:09:14 +0200 Subject: [PATCH 269/283] Bump Maven in dependencies to 3.9.11 project still require 3.6.3 --- pom.xml | 6 +++--- src/it/projects/analyze-excluded-classes/verify.groovy | 4 ++-- .../plugins/dependency/fromConfiguration/TestCopyMojo.java | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index ac62cec8f..7a8def860 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ under the License. - ${mavenVersion} + 3.6.3 @@ -91,8 +91,8 @@ under the License. 8 - 3.6.3 - 1.4.1 + 3.9.11 + 1.9.24 1.7.36 9.4.58.v20250814 4.11.0 diff --git a/src/it/projects/analyze-excluded-classes/verify.groovy b/src/it/projects/analyze-excluded-classes/verify.groovy index 47457c6f6..96b61dc73 100644 --- a/src/it/projects/analyze-excluded-classes/verify.groovy +++ b/src/it/projects/analyze-excluded-classes/verify.groovy @@ -26,6 +26,6 @@ assert file.exists() String buildLog = file.getText( "UTF-8" ) assert buildLog.contains( '[WARNING] Used undeclared dependencies found:') -assert buildLog.contains( '[WARNING] org.apache.maven:maven-model:jar:3.6.3:compile') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-model:jar:') assert buildLog.contains( '[WARNING] Unused declared dependencies found:') -assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:jar:3.6.3:compile') +assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:jar:') diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index 9040e73b1..a619d7750 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -161,7 +161,11 @@ public void testCopyFile() throws Exception { assertFilesExist(list, true); } - public void testCopyFileWithBaseVersion() throws Exception { + /** + * New version of resolver on classpath does not support timestamp version lookups in local repository. + * TODO move to an integration test ... + */ + public void skipTestCopyFileWithBaseVersion() throws Exception { List list = stubFactory.getArtifactItems(stubFactory.getClassifiedArtifacts()); ArtifactItem item = new ArtifactItem(); From 91a03a6c132216a05cab1d72ece8acd50a9c2435 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 19:13:14 +0000 Subject: [PATCH 270/283] Bump org.apache.commons:commons-lang3 Bumps org.apache.commons:commons-lang3 from 3.9 to 3.18.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-version: 3.18.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .../mdep-204-go-offline-resolve-intermodule/module-1/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-1/pom.xml b/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-1/pom.xml index 07bec4073..5bff94ea0 100644 --- a/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-1/pom.xml +++ b/src/it/projects/mdep-204-go-offline-resolve-intermodule/module-1/pom.xml @@ -35,7 +35,7 @@ org.apache.commons commons-lang3 - 3.9 + 3.18.0 From cf4ffccef0c092f24f45f7bfa87da94393c1b4e5 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 13 Sep 2025 22:06:59 +0200 Subject: [PATCH 271/283] Simplify usage of RepositoryManager and DependencyResolver Move it where is used, not all Mojos need it --- .../AbstractDependencyFilterMojo.java | 26 ------------------- .../AbstractFromDependenciesMojo.java | 18 ++----------- .../fromDependencies/BuildClasspathMojo.java | 22 +++------------- .../CopyDependenciesMojo.java | 22 +++++----------- .../UnpackDependenciesMojo.java | 16 +----------- .../resolvers/AbstractResolveMojo.java | 16 +----------- .../resolvers/CollectDependenciesMojo.java | 17 +----------- .../dependency/resolvers/GoOfflineMojo.java | 17 ++++-------- .../dependency/resolvers/ListMojo.java | 14 +--------- .../OldResolveDependencySourcesMojo.java | 14 +--------- .../resolvers/ResolveDependenciesMojo.java | 14 +--------- .../ResolveDependencySourcesMojo.java | 14 +--------- .../resolvers/ResolvePluginsMojo.java | 17 ++++-------- .../ResolveDependenciesMojoTest.java | 2 +- 14 files changed, 30 insertions(+), 199 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 3b274c5f5..14c040b65 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -50,8 +50,6 @@ import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.sonatype.plexus.build.incremental.BuildContext; @@ -233,33 +231,23 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj private final ResolverUtil resolverUtil; - private final DependencyResolver dependencyResolver; - - private final RepositoryManager repositoryManager; - private final ProjectBuilder projectBuilder; private final ArtifactHandlerManager artifactHandlerManager; @Inject - // CHECKSTYLE_OFF: ParameterNumber protected AbstractDependencyFilterMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { super(session, buildContext, project); this.resolverUtil = resolverUtil; - this.dependencyResolver = dependencyResolver; - this.repositoryManager = repositoryManager; this.projectBuilder = projectBuilder; this.artifactHandlerManager = artifactHandlerManager; } - // CHECKSTYLE_ON: ParameterNumber /** * Return an {@link ArtifactsFilter} indicating which artifacts must be filtered out. @@ -524,18 +512,4 @@ public void setPrependGroupId(boolean prependGroupId) { protected final ResolverUtil getResolverUtil() { return resolverUtil; } - - /** - * @return {@link #dependencyResolver} - */ - protected final DependencyResolver getDependencyResolver() { - return dependencyResolver; - } - - /** - * @return {@link #repositoryManager} - */ - protected final RepositoryManager getRepositoryManager() { - return repositoryManager; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 5f624e7a5..275f35d09 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -26,8 +26,6 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -114,27 +112,15 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil @Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "false") protected boolean failOnMissingClassifierArtifact; - // CHECKSTYLE_OFF: ParameterNumber protected AbstractFromDependenciesMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); - } - // CHECKSTYLE_ON: ParameterNumber + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); + } /** * @return returns the output directory diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index d108b1e34..28068ffb2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -51,10 +51,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -168,29 +165,17 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements private final MavenProjectHelper projectHelper; @Inject - // CHECKSTYLE_OFF: ParameterNumber protected BuildClasspathMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager, MavenProjectHelper projectHelper) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); this.projectHelper = projectHelper; } - // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates to create a classpath. @@ -288,9 +273,8 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { String file = art.getFile().getPath(); // substitute the property for the local repo path to make the classpath file portable. if (localRepoProperty != null && !localRepoProperty.isEmpty()) { - ProjectBuildingRequest projectBuildingRequest = session.getProjectBuildingRequest(); - File localBasedir = getRepositoryManager().getLocalRepositoryBasedir(projectBuildingRequest); - + File localBasedir = + session.getRepositorySession().getLocalRepository().getBasedir(); file = StringUtils.replace(file, localBasedir.getAbsolutePath(), localRepoProperty); } sb.append(file); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 8223d95ce..1bb9c40e0 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -47,7 +47,6 @@ import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller; import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.util.artifact.SubArtifact; @@ -80,6 +79,8 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { private final ArtifactInstaller installer; + private final RepositoryManager repositoryManager; + /** * Either append the artifact's baseVersion or uniqueVersion to the filename. Will only be used if * {@link #isStripVersion()} is {@code false}. @@ -106,31 +107,22 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo { protected boolean copySignatures; @Inject - // CHECKSTYLE_OFF: ParameterNumber + @SuppressWarnings("checkstyle:ParameterNumber") public CopyDependenciesMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager, CopyUtil copyUtil, ArtifactInstaller installer) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); this.copyUtil = copyUtil; this.installer = installer; + this.repositoryManager = repositoryManager; } - // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. @@ -165,8 +157,8 @@ protected void doExecute() throws MojoExecutionException { artifact, isStripVersion(), this.prependGroupId, this.useBaseVersion, this.stripClassifier); } } else { - ProjectBuildingRequest buildingRequest = getRepositoryManager() - .setLocalRepositoryBasedir(session.getProjectBuildingRequest(), outputDirectory); + ProjectBuildingRequest buildingRequest = + repositoryManager.setLocalRepositoryBasedir(session.getProjectBuildingRequest(), outputDirectory); artifacts.forEach(artifact -> installArtifact(artifact, buildingRequest)); } diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index 589564fca..dd018fd86 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -39,8 +39,6 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.codehaus.plexus.components.io.filemappers.FileMapper; import org.sonatype.plexus.build.incremental.BuildContext; @@ -106,29 +104,17 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { private final UnpackUtil unpackUtil; @Inject - // CHECKSTYLE_OFF: ParameterNumber public UnpackDependenciesMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager, UnpackUtil unpackUtil) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); this.unpackUtil = unpackUtil; } - // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. This method gets the dependencies and iterates through each one passing it to diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 434fea8bd..6abcb140e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -34,8 +34,6 @@ import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -68,27 +66,15 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; - // CHECKSTYLE_OFF: ParameterNumber protected AbstractResolveMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } - // CHECKSTYLE_ON: ParameterNumber /** * @return {@link FilterArtifacts} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java index 2751d171d..bd8927586 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/CollectDependenciesMojo.java @@ -28,8 +28,6 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -58,26 +56,13 @@ public class CollectDependenciesMojo extends ResolveDependenciesMojo { @Inject - // CHECKSTYLE_OFF: ParameterNumber protected CollectDependenciesMojo( MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } - // CHECKSTYLE_ON: ParameterNumber - } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index 84242e2fa..d503d65fe 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -49,7 +49,6 @@ import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -63,6 +62,8 @@ @Mojo(name = "go-offline", threadSafe = true) public class GoOfflineMojo extends AbstractResolveMojo { + private final DependencyResolver dependencyResolver; + @Inject // CHECKSTYLE_OFF: ParameterNumber public GoOfflineMojo( @@ -71,18 +72,10 @@ public GoOfflineMojo( MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); + this.dependencyResolver = dependencyResolver; } // CHECKSTYLE_ON: ParameterNumber @@ -152,7 +145,7 @@ private Set resolveDependableCoordinate( for (DependableCoordinate dependableCoordinate : dependableCoordinates) { final Iterable artifactResults = - getDependencyResolver().resolveDependencies(buildingRequest, dependableCoordinate, filter); + dependencyResolver.resolveDependencies(buildingRequest, dependableCoordinate, filter); for (final ArtifactResult artifactResult : artifactResults) { results.add(artifactResult.getArtifact()); diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java index 81358579a..306b12d98 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ListMojo.java @@ -27,8 +27,6 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -47,19 +45,9 @@ public ListMojo( BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } // CHECKSTYLE_ON: ParameterNumber // alias for dependency:resolve diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java index 828a5f24b..866c1b84e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/OldResolveDependencySourcesMojo.java @@ -28,8 +28,6 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -54,19 +52,9 @@ public OldResolveDependencySourcesMojo( BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } // CHECKSTYLE_ON: ParameterNumber } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 4402b4890..62a5330e5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -49,8 +49,6 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.apache.maven.shared.utils.logging.MessageBuilder; import org.apache.maven.shared.utils.logging.MessageUtils; import org.sonatype.plexus.build.incremental.BuildContext; @@ -116,19 +114,9 @@ public ResolveDependenciesMojo( BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } // CHECKSTYLE_ON: ParameterNumber diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index a4d4a14db..24c7b7a67 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -29,8 +29,6 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -55,19 +53,9 @@ public ResolveDependencySourcesMojo( BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } // CHECKSTYLE_ON: ParameterNumber diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 4119af06c..e925c2381 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -48,7 +48,6 @@ import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; -import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.sonatype.plexus.build.incremental.BuildContext; @@ -72,6 +71,8 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") private boolean outputAbsoluteArtifactFilename; + private final DependencyResolver dependencyResolver; + @Inject // CHECKSTYLE_OFF: ParameterNumber public ResolvePluginsMojo( @@ -80,18 +81,10 @@ public ResolvePluginsMojo( MavenProject project, ResolverUtil resolverUtil, DependencyResolver dependencyResolver, - RepositoryManager repositoryManager, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { - super( - session, - buildContext, - project, - resolverUtil, - dependencyResolver, - repositoryManager, - projectBuilder, - artifactHandlerManager); + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); + this.dependencyResolver = dependencyResolver; } // CHECKSTYLE_ON: ParameterNumber @@ -191,7 +184,7 @@ private Set resolveArtifactDependencies(final DependableCoordinate art ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); Iterable artifactResults = - getDependencyResolver().resolveDependencies(buildingRequest, artifact, null); + dependencyResolver.resolveDependencies(buildingRequest, artifact, null); Set artifacts = new LinkedHashSet<>(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java index da3b9f8f5..2af967760 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java @@ -111,7 +111,7 @@ private void doTestDependencyStatusLog(Set artifacts) { } private ResolveDependenciesMojo newMojo(final DependencyStatusSets dss) { - ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(null, null, null, null, null, null, null, null); + ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(null, null, null, null, null, null); mojo.results = dss; return mojo; } From f99b5984bd99cb936225721a9f51a15f7b1dee7e Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 13 Sep 2025 18:31:14 -0400 Subject: [PATCH 272/283] Follow Oracle javadoc guidelines (#1519) --- .../dependency/AbstractDependencyMojo.java | 20 +++--- .../maven/plugins/dependency/GetMojo.java | 13 ++-- .../plugins/dependency/PropertiesMojo.java | 4 +- .../dependency/PurgeLocalRepositoryMojo.java | 38 +++++------ .../analyze/AbstractAnalyzeMojo.java | 6 +- .../dependency/analyze/AnalyzeDepMgt.java | 4 +- .../dependency/analyze/AnalyzeReport.java | 22 ++++--- .../analyze/AnalyzeReportRenderer.java | 4 +- .../AbstractFromConfigurationMojo.java | 54 +++++++-------- .../fromConfiguration/ArtifactItem.java | 16 ++--- .../fromConfiguration/CopyMojo.java | 20 +++--- .../ProcessArtifactItemsRequest.java | 8 +-- .../fromConfiguration/UnpackMojo.java | 32 +++++---- .../AbstractDependencyFilterMojo.java | 54 +++++++-------- .../AbstractFromDependenciesMojo.java | 22 +++---- .../fromDependencies/BuildClasspathMojo.java | 6 +- .../CopyDependenciesMojo.java | 19 +++--- .../UnpackDependenciesMojo.java | 22 +++---- .../dependency/resolvers/GoOfflineMojo.java | 6 +- .../resolvers/ResolveDependenciesMojo.java | 6 +- .../resolvers/ResolvePluginsMojo.java | 6 +- .../tree/AbstractSerializingVisitor.java | 2 +- .../tree/DOTDependencyNodeVisitor.java | 2 +- .../tree/GraphmlDependencyNodeVisitor.java | 6 +- .../tree/TGFDependencyNodeVisitor.java | 12 ++-- .../plugins/dependency/tree/TreeMojo.java | 1 - .../plugins/dependency/utils/CopyUtil.java | 2 - .../utils/DependencyStatusSets.java | 12 ++-- .../dependency/utils/DependencyUtil.java | 34 +++++----- .../dependency/utils/ParamArtifact.java | 4 +- .../dependency/utils/ResolverUtil.java | 8 +-- .../plugins/dependency/utils/UnpackUtil.java | 16 ++--- .../utils/filters/ArtifactItemFilter.java | 4 +- .../utils/filters/DestFileFilter.java | 66 +++++++++---------- .../utils/filters/MarkerFileFilter.java | 18 ++--- .../markers/DefaultFileMarkerHandler.java | 20 +++--- .../utils/markers/MarkerHandler.java | 14 ++-- .../markers/SourcesFileMarkerHandler.java | 24 +++---- .../markers/UnpackFileMarkerHandler.java | 4 +- .../utils/translators/ArtifactTranslator.java | 2 +- .../translators/ClassifierTypeTranslator.java | 14 ++-- 41 files changed, 322 insertions(+), 325 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index b24e2ba6e..5045f607c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -57,15 +57,15 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { protected List reactorProjects; /** - * The Maven session + * The Maven session. */ protected final MavenSession session; /** * If the plugin should be silent. * - * @deprecated to be removed in 4.0; use -q command line option instead * @since 2.0 + * @deprecated to be removed in 4.0; use -q command line option instead */ @Deprecated @Parameter(property = "silent", defaultValue = "false") @@ -82,19 +82,19 @@ public abstract class AbstractDependencyMojo extends AbstractMojo { /** * Skip plugin execution only during incremental builds (e.g. triggered from M2E). * - * @since 3.4.0 * @see #skip + * @since 3.4.0 */ @Parameter(defaultValue = "false") private boolean skipDuringIncrementalBuild; /** - * For IDE build support + * For IDE build support. */ private final BuildContext buildContext; /** - * POM + * POM. */ private final MavenProject project; @@ -126,16 +126,16 @@ public final void execute() throws MojoExecutionException, MojoFailureException protected abstract void doExecute() throws MojoExecutionException, MojoFailureException; /** - * @return Returns a new ProjectBuildingRequest populated from the current session and the current project remote - * repositories, used to resolve artifacts. + * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote + * repositories, used to resolve artifacts */ public ProjectBuildingRequest newResolveArtifactProjectBuildingRequest() { return newProjectBuildingRequest(remoteRepositories); } /** - * @return Returns a new ProjectBuildingRequest populated from the current session and the current project remote - * repositories, used to resolve plugins. + * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote + * repositories, used to resolve plugins */ protected ProjectBuildingRequest newResolvePluginProjectBuildingRequest() { return newProjectBuildingRequest(remotePluginRepositories); @@ -150,7 +150,7 @@ private ProjectBuildingRequest newProjectBuildingRequest(List directDependencies; /** - * Default constructor + * Default constructor. * - * @param directDependencies Set of dependencies objects which represent the direct dependencies of the project + * @param directDependencies set of dependencies objects which represent the direct dependencies of the project */ DirectDependencyFilter(Artifact projectArtifact, List directDependencies) { this.projectArtifact = projectArtifact; @@ -287,7 +287,7 @@ private boolean artifactsGAMatch(Node node, String groupId, String artifactId) { } /** - * Includes only snapshot artifacts + * Includes only snapshot artifacts. */ private static class SnapshotsFilter extends AbstractFilter { @Override @@ -330,7 +330,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { * Determines if all projects in the reactor should be purged from their dependencies. When this goal is started on * the command-line, it is always the case. When it is bound to a phase in the lifecycle, it is never the case. * - * @return true if all projects in the reactor should be purged, false otherwise. + * @return true if all projects in the reactor should be purged, false otherwise */ private boolean shouldPurgeAllProjectsInReactor() { Source source = mojoExecution.getSource(); @@ -340,9 +340,9 @@ private boolean shouldPurgeAllProjectsInReactor() { /** * Purges the local repository for the dependencies in the given Maven project. * - * @param theProject Maven project. - * @param purgedArtifacts The artifacts that were already purged. - * @throws MojoFailureException in case of errors during the purge. + * @param theProject maven project + * @param purgedArtifacts the artifacts that were already purged + * @throws MojoFailureException in case of errors during the purge */ private void purgeLocalRepository(MavenProject theProject, Set purgedArtifacts) throws MojoFailureException { @@ -375,8 +375,8 @@ private void purgeLocalRepository(MavenProject theProject, Set purgedA /** * Purge/Delete artifacts from the local repository according to the given patterns. * - * @param theIncludes The includes. - * @throws MojoExecutionException in case of an error. + * @param theIncludes the includes + * @throws MojoExecutionException in case of an error */ private void manualPurge(List theIncludes) throws MojoExecutionException { MessageBuilder messageBuilder = MessageUtils.buffer(); @@ -417,7 +417,7 @@ private void manualPurge(List theIncludes) throws MojoExecutionException } /** - * Convert a groupId:artifactId:version to a file system path + * Convert a groupId:artifactId:version to a file system path. * * @param gav the groupId:artifactId:version string * @return the corresponding path @@ -440,11 +440,11 @@ private String gavToPath(String gav) { /** * Create the includes exclude filter to use when resolving and purging dependencies Also excludes any "system" - * scope dependencies + * scope dependencies. * - * @param theProject The Maven project. - * @param dependencies The dependencies to use as a reference if we're excluding transitive dependencies - * @param purgedArtifacts The artifacts already purged. + * @param theProject the Maven project + * @param dependencies the dependencies to use as a reference if we're excluding transitive dependencies + * @param purgedArtifacts the artifacts already purged * @return the created filter */ private TransformableFilter createPurgeArtifactsFilter( @@ -494,8 +494,8 @@ private TransformableFilter createPurgeArtifactsFilter( /** * Returns a string that represents a pattern for an exclude filter for the given artifact. * - * @param artifact Artifact. - * @return String representation of a pattern for an exclude filter for the given artifact. + * @param artifact artifact + * @return string representation of a pattern for an exclude filter for the given artifact */ private String toPatternExcludes(Artifact artifact) { return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" @@ -503,9 +503,9 @@ private String toPatternExcludes(Artifact artifact) { } /** - * Convert comma separated list of includes to List object + * Convert comma separated list of includes to List object. * - * @param theInclude The list of includes + * @param theInclude the list of includes * @return the includes list */ private List parseIncludes(String theInclude) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java index 0fda8b8a0..ac79d7178 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java @@ -129,7 +129,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { private String scriptableFlag; /** - * Flag to use for scriptable output + * Flag to use for scriptable output. * * @since 2.0-alpha-5 */ @@ -137,7 +137,7 @@ public abstract class AbstractAnalyzeMojo extends AbstractMojo { private File baseDir; /** - * Target folder + * Target folder. * * @since 2.0-alpha-5 */ @@ -309,7 +309,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { /** * @return {@link ProjectDependencyAnalyzer} - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java index 6037ecff2..1df1d74a4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeDepMgt.java @@ -203,7 +203,7 @@ public String getExclusionKey(Artifact artifact) { } /** - * @param ex The exclusion key. + * @param ex the exclusion key * @return the resulting combination of groupId+artifactId */ public String getExclusionKey(Exclusion ex) { @@ -211,7 +211,7 @@ public String getExclusionKey(Exclusion ex) { } /** - * Calculate the mismatches between the DependencyManagement and resolved artifacts + * Calculate the mismatches between the DependencyManagement and resolved artifacts. * * @param depMgtMap a keyset of the Dependency.GetManagementKey for quick lookup * @param allDependencyArtifacts the set of all artifacts to compare diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java index ef08b0259..038a1fdac 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReport.java @@ -52,12 +52,12 @@ public class AnalyzeReport extends AbstractMavenReport { private final ProjectDependencyAnalyzer analyzer; /** - * Internationalization component + * Internationalization component. */ private final I18N i18n; /** - * Ignore Runtime/Provided/Test/System scopes for unused dependency analysis + * Ignore Runtime/Provided/Test/System scopes for unused dependency analysis. * * @since 2.2 */ @@ -140,19 +140,25 @@ public boolean canGenerateReport() { return true; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String getOutputName() { return "dependency-analysis"; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String getName(Locale locale) { return getI18nString(locale, "name"); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String getDescription(Locale locale) { return getI18nString(locale, "description"); @@ -161,9 +167,9 @@ public String getDescription(Locale locale) { // protected methods ------------------------------------------------------ /** - * @param locale The locale - * @param key The key to search for - * @return The text appropriate for the locale. + * @param locale the locale + * @param key the key to search for + * @return the text appropriate for the locale */ protected String getI18nString(Locale locale, String key) { return i18n.getString("analyze-report", locale, "report.analyze." + key); diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java index 80fb1b2d6..af46a1b6e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java +++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AnalyzeReportRenderer.java @@ -51,8 +51,8 @@ public String getTitle() { } /** - * @param key The key. - * @return The translated string. + * @param key the key + * @return the translated string */ private String getI18nString(String key) { return i18n.getString("analyze-report", locale, "report.analyze." + key); diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java index 0cb048149..88914298e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java @@ -52,7 +52,7 @@ /** * Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of - * ArtifactItems + * ArtifactItems. * * @author Brian Fox * @see ArtifactItem @@ -67,7 +67,7 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo private File outputDirectory; /** - * Overwrite release artifacts + * Overwrite release artifacts. * * @since 1.0 */ @@ -75,7 +75,7 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo private boolean overWriteReleases; /** - * Overwrite snapshot artifacts + * Overwrite snapshot artifacts. * * @since 1.0 */ @@ -83,17 +83,17 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo private boolean overWriteSnapshots; /** - * Overwrite if newer + * Overwrite if newer. * * @since 2.0 - * @deprecated Use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing now. + * @deprecated use 'overWriteIfNewer' or 'mdep.overWriteIfNewer' as this does nothing now */ @Deprecated @Parameter(property = "mdep.overIfNewer", defaultValue = "true") private boolean overIfNewer; /** - * Overwrite if newer + * Overwrite if newer. * * @since 3.7.0 */ @@ -111,7 +111,7 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo /** * Path to override default local repository during plugin's execution. To remove all downloaded artifacts as part - * of the build, set this value to a location under your project's target directory + * of the build, set this value to a location under your project's target directory. * * @since 2.2 */ @@ -136,9 +136,9 @@ protected AbstractFromConfigurationMojo( abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item); /** - * artifactItems is filled by either field injection or by setArtifact(). + * ArtifactItems is filled by either field injection or by setArtifact(). * - * @throws MojoFailureException in case of an error. + * @throws MojoFailureException in case of an error */ protected void verifyRequirements() throws MojoFailureException { if (artifactItems == null || artifactItems.isEmpty()) { @@ -151,8 +151,8 @@ protected void verifyRequirements() throws MojoFailureException { * output Directory if it doesn't exist. * * @param processArtifactItemsRequest preprocessing instructions - * @return An ArrayList of preprocessed ArtifactItems - * @throws MojoExecutionException with a message if an error occurs. + * @return an ArrayList of preprocessed ArtifactItems + * @throws MojoExecutionException with a message if an error occurs * @see ArtifactItem */ protected List getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) @@ -228,7 +228,7 @@ private RepositorySystemSession createSystemSessionForLocalRepo() { * from the dependency list or from the DependencyManagement section of the pom. * * @param artifactItem containing information about artifact from plugin configuration - * @return Artifact object representing the specified file + * @return artifact object representing the specified file * @throws MojoExecutionException if the version can't be found in DependencyManagement */ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException { @@ -266,7 +266,7 @@ protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionEx * with the correct version. It will first look for an exact match on artifactId/groupId/classifier/type and if it * doesn't find a match, it will try again looking for artifactId and groupId only. * - * @param artifact representing configured file. + * @param artifact representing configured file * @throws MojoExecutionException */ private void fillMissingArtifactVersion(ArtifactItem artifact) throws MojoExecutionException { @@ -289,8 +289,8 @@ private void fillMissingArtifactVersion(ArtifactItem artifact) throws MojoExecut * Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct * version. * - * @param artifact representing configured file. - * @param dependencies list of dependencies to search. + * @param artifact representing configured file + * @param dependencies list of dependencies to search * @param looseMatch only look at artifactId and groupId * @return the found dependency */ @@ -310,70 +310,70 @@ private boolean findDependencyVersion(ArtifactItem artifact, List de } /** - * @return Returns the artifactItems. + * @return returns the artifactItems */ public List getArtifactItems() { return this.artifactItems; } /** - * @param theArtifactItems The artifactItems to set. + * @param theArtifactItems the artifactItems to set */ public void setArtifactItems(List theArtifactItems) { this.artifactItems = theArtifactItems; } /** - * @return Returns the outputDirectory. + * @return returns the outputDirectory */ public File getOutputDirectory() { return this.outputDirectory; } /** - * @param theOutputDirectory The outputDirectory to set. + * @param theOutputDirectory the outputDirectory to set */ public void setOutputDirectory(File theOutputDirectory) { this.outputDirectory = theOutputDirectory; } /** - * @return Returns the overWriteIfNewer. + * @return returns the overWriteIfNewer */ public boolean isOverWriteIfNewer() { return this.overWriteIfNewer; } /** - * @param theOverWriteIfNewer The overWriteIfNewer to set. + * @param theOverWriteIfNewer the overWriteIfNewer to set */ public void setOverWriteIfNewer(boolean theOverWriteIfNewer) { this.overWriteIfNewer = theOverWriteIfNewer; } /** - * @return Returns the overWriteReleases. + * @return returns the overWriteReleases */ public boolean isOverWriteReleases() { return this.overWriteReleases; } /** - * @param theOverWriteReleases The overWriteReleases to set. + * @param theOverWriteReleases the overWriteReleases to set */ public void setOverWriteReleases(boolean theOverWriteReleases) { this.overWriteReleases = theOverWriteReleases; } /** - * @return Returns the overWriteSnapshots. + * @return returns the overWriteSnapshots */ public boolean isOverWriteSnapshots() { return this.overWriteSnapshots; } /** - * @param theOverWriteSnapshots The overWriteSnapshots to set. + * @param theOverWriteSnapshots the overWriteSnapshots to set */ public void setOverWriteSnapshots(boolean theOverWriteSnapshots) { this.overWriteSnapshots = theOverWriteSnapshots; @@ -387,8 +387,8 @@ public void setLocalRepositoryDirectory(File localRepositoryDirectory) { } /** - * @param artifact The artifact. - * @throws MojoFailureException in case of an error. + * @param artifact the artifact + * @throws MojoFailureException in case of an error */ public void setArtifact(String artifact) throws MojoFailureException { if (artifact != null) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java index ff093978b..4fbea1c3f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java @@ -31,24 +31,24 @@ /** * ArtifactItem represents information specified in the plugin configuration section for each artifact. * - * @since 1.0 * @author Brian Fox + * @since 1.0 */ public class ArtifactItem implements DependableCoordinate { /** - * Group ID of artifact + * Group ID of artifact. */ @Parameter(required = true) private String groupId; /** - * Name of artifact + * Name of artifact. */ @Parameter(required = true) private String artifactId; /** - * Version of artifact + * Version of artifact. */ @Parameter private String version = null; @@ -72,7 +72,7 @@ public class ArtifactItem implements DependableCoordinate { private File outputDirectory; /** - * Provides ability to change destination file name + * Provides ability to change destination file name. */ @Parameter private String destFileName; @@ -91,7 +91,7 @@ public class ArtifactItem implements DependableCoordinate { private boolean needsProcessing; /** - * Artifact Item + * Artifact Item. */ private Artifact artifact; @@ -207,7 +207,7 @@ public String getBaseVersion() { } /** - * @return Classifier + * @return classifier */ @Override public String getClassifier() { @@ -347,7 +347,6 @@ public void setIncludes(String includes) { /** * @return {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting shall * happen - * * @since 3.1.2 */ public FileMapper[] getFileMappers() { @@ -357,7 +356,6 @@ public FileMapper[] getFileMappers() { /** * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no * rewriting shall happen - * * @since 3.1.2 */ public void setFileMappers(FileMapper[] fileMappers) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java index 91499fdd9..dab686a50 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java @@ -51,19 +51,19 @@ public class CopyMojo extends AbstractFromConfigurationMojo { private final CopyUtil copyUtil; /** - * Strip artifact version during copy + * Strip artifact version during copy. */ @Parameter(property = "mdep.stripVersion", defaultValue = "false") private boolean stripVersion = false; /** - * Strip artifact classifier during copy + * Strip artifact classifier during copy. */ @Parameter(property = "mdep.stripClassifier", defaultValue = "false") private boolean stripClassifier = false; /** - * Prepend artifact groupId during copy + * Prepend artifact groupId during copy. * * @since 2.7 */ @@ -71,7 +71,7 @@ public class CopyMojo extends AbstractFromConfigurationMojo { private boolean prependGroupId = false; /** - * Use artifact baseVersion during copy + * Use artifact baseVersion during copy. * * @since 2.7 */ @@ -102,7 +102,7 @@ public CopyMojo( * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * copyArtifact. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs * @see ArtifactItem * @see #getArtifactItems * @see #copyArtifact(ArtifactItem) @@ -162,35 +162,35 @@ protected ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item) { } /** - * @return Returns the stripVersion. + * @return returns the stripVersion */ public boolean isStripVersion() { return this.stripVersion; } /** - * @param stripVersion The stripVersion to set. + * @param stripVersion the stripVersion to set */ public void setStripVersion(boolean stripVersion) { this.stripVersion = stripVersion; } /** - * @return Returns the stripClassifier. + * @return returns the stripClassifier */ public boolean isStripClassifier() { return this.stripClassifier; } /** - * @param stripClassifier The stripClassifier to set. + * @param stripClassifier the stripClassifier to set */ public void setStripClassifier(boolean stripClassifier) { this.stripClassifier = stripClassifier; } /** - * @param useBaseVersion The useBaseVersion to set. + * @param useBaseVersion the useBaseVersion to set */ public void setUseBaseVersion(boolean useBaseVersion) { this.useBaseVersion = useBaseVersion; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ProcessArtifactItemsRequest.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ProcessArtifactItemsRequest.java index e70897d5d..a2d9fa80f 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ProcessArtifactItemsRequest.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ProcessArtifactItemsRequest.java @@ -24,22 +24,22 @@ */ public class ProcessArtifactItemsRequest { /** - * remove the version from the filename. + * Remove the version from the filename. */ private boolean removeVersion; /** - * remove the classifier from the filename. + * Remove the classifier from the filename. */ private boolean removeClassifier; /** - * prepend the groupId to the filename. + * Prepend the groupId to the filename. */ private boolean prependGroupId; /** - * use the baseVersion of the artifact instead of version for the filename. + * Use the baseVersion of the artifact instead of version for the filename. */ private boolean useBaseVersion; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java index 58349e38a..e4854371c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java @@ -52,7 +52,7 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { private final UnpackUtil unpackUtil; /** - * Directory to store flag files after unpack + * Directory to store flag files after unpack. */ @Parameter( property = "markersDirectory", @@ -80,7 +80,7 @@ public class UnpackMojo extends AbstractFromConfigurationMojo { private String excludes; /** - * ignore to set file permissions when unpacking a dependency + * Ignore to set file permissions when unpacking a dependency. * * @since 2.7 */ @@ -120,7 +120,7 @@ public UnpackMojo( * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to * unpackArtifact. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs * @see ArtifactItem * @see #getArtifactItems * @see #unpackArtifact(ArtifactItem) @@ -146,8 +146,8 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { /** * This method gets the Artifact object and calls DependencyUtil.unpackFile. * - * @param artifactItem containing the information about the Artifact to unpack. - * @throws MojoExecutionException with a message if an error occurs. + * @param artifactItem containing the information about the Artifact to unpack + * @throws MojoExecutionException with a message if an error occurs * @see #getArtifact */ private void unpackArtifact(ArtifactItem artifactItem) throws MojoExecutionException { @@ -175,9 +175,9 @@ ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item) { } /** - * @param removeVersion removeVersion. + * @param removeVersion removeVersion * @return list of {@link ArtifactItem} - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ protected List getProcessedArtifactItems(boolean removeVersion) throws MojoExecutionException { List items = @@ -194,42 +194,42 @@ protected List getProcessedArtifactItems(boolean removeVersion) th } /** - * @return Returns the markersDirectory. + * @return returns the markersDirectory */ public File getMarkersDirectory() { return this.markersDirectory; } /** - * @param theMarkersDirectory The markersDirectory to set. + * @param theMarkersDirectory the markersDirectory to set */ public void setMarkersDirectory(File theMarkersDirectory) { this.markersDirectory = theMarkersDirectory; } /** - * @return Returns a comma separated list of excluded items + * @return returns a comma separated list of excluded items */ public String getExcludes() { return this.excludes; } /** - * @param excludes A comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties + * @param excludes a comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties */ public void setExcludes(String excludes) { this.excludes = excludes; } /** - * @return Returns a comma separated list of included items + * @return returns a comma separated list of included items */ public String getIncludes() { return this.includes; } /** - * @param includes A comma separated list of items to include i.e. **\/*.xml, **\/*.properties + * @param includes a comma separated list of items to include i.e. **\/*.xml, **\/*.properties */ public void setIncludes(String includes) { this.includes = includes; @@ -237,8 +237,7 @@ public void setIncludes(String includes) { /** * @return {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting shall - * happen. - * + * happen * @since 3.1.2 */ public FileMapper[] getFileMappers() { @@ -247,8 +246,7 @@ public FileMapper[] getFileMappers() { /** * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no - * rewriting shall happen. - * + * rewriting shall happen * @since 3.1.2 */ public void setFileMappers(FileMapper[] fileMappers) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 14c040b65..0f4def217 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -62,7 +62,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMojo { /** - * Overwrite release artifacts + * Overwrite release artifacts. * * @since 1.0 */ @@ -70,7 +70,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected boolean overWriteReleases; /** - * Overwrite snapshot artifacts + * Overwrite snapshot artifacts. * * @since 1.0 */ @@ -86,7 +86,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected boolean overWriteIfNewer; /** - * If we should exclude transitive dependencies + * If we should exclude transitive dependencies. * * @since 2.0 */ @@ -164,7 +164,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String excludeClassifiers; /** - * Specify classifier to look for. Example: sources + * Specify classifier to look for. Example: sources. * * @since 2.0 */ @@ -172,7 +172,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String classifier; /** - * Specify type to look for when constructing artifact based on classifier. Example: java-source,jar,war + * Specify type to look for when constructing artifact based on classifier. Example: java-source,jar,war. * * @since 2.0 */ @@ -212,7 +212,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj protected String includeGroupIds; /** - * Directory to store flag files + * Directory to store flag files. * * @since 2.0 */ @@ -259,9 +259,9 @@ protected AbstractDependencyFilterMojo( /** * Retrieves dependencies, either direct only or all including transitive. * - * @param stopOnFailure true to fail if resolution does not work or false not to fail. - * @return A set of artifacts - * @throws MojoExecutionException in case of errors. + * @param stopOnFailure true to fail if resolution does not work or false not to fail + * @return a set of artifacts + * @throws MojoExecutionException in case of errors */ protected Set getResolvedDependencies(boolean stopOnFailure) throws MojoExecutionException { @@ -271,9 +271,9 @@ protected Set getResolvedDependencies(boolean stopOnFailure) throws Mo } /** - * @param stopOnFailure true/false. + * @param stopOnFailure true/false * @return {@link DependencyStatusSets} - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ protected DependencyStatusSets getDependencySets(boolean stopOnFailure) throws MojoExecutionException { return getDependencySets(stopOnFailure, false); @@ -281,12 +281,12 @@ protected DependencyStatusSets getDependencySets(boolean stopOnFailure) throws M /** * Method creates filters and filters the projects dependencies. This method also transforms the dependencies if - * classifier is set. The dependencies are filtered in least specific to most specific order + * classifier is set. The dependencies are filtered in least specific to most specific order. * - * @param stopOnFailure true to fail if artifacts can't be resolved false otherwise. - * @param includeParents true if parents should be included or not false. + * @param stopOnFailure true to fail if artifacts can't be resolved false otherwise + * @param includeParents true if parents should be included or not false * @return DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies - * @throws MojoExecutionException in case of errors. + * @throws MojoExecutionException in case of errors */ protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean includeParents) throws MojoExecutionException { @@ -381,12 +381,12 @@ private void addParentArtifacts(MavenProject project, Set artifacts) t } /** - * Transform artifacts + * Transform artifacts. * - * @param artifacts set of artifacts {@link Artifact}. - * @param stopOnFailure true/false. + * @param artifacts set of artifacts {@link Artifact} + * @param stopOnFailure true/false * @return DependencyStatusSets - Bean of TreeSets that contains information on the projects dependencies - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ private DependencyStatusSets getClassifierTranslatedDependencies(Set artifacts, boolean stopOnFailure) throws MojoExecutionException { @@ -423,11 +423,11 @@ private DependencyStatusSets getClassifierTranslatedDependencies(Set a } /** - * Filter the marked dependencies + * Filter the marked dependencies. * - * @param artifacts The artifacts set {@link Artifact}. - * @return status set {@link DependencyStatusSets}. - * @throws MojoExecutionException in case of an error. + * @param artifacts the artifacts set {@link Artifact} + * @return status set {@link DependencyStatusSets} + * @throws MojoExecutionException in case of an error */ protected DependencyStatusSets filterMarkedDependencies(Set artifacts) throws MojoExecutionException { // remove files that have markers already @@ -450,11 +450,11 @@ protected DependencyStatusSets filterMarkedDependencies(Set artifacts) } /** - * @param artifacts The set of artifacts + * @param artifacts the set of artifacts * @param stopOnFailure true if we should fail with exception if an artifact couldn't be resolved - * false otherwise. + * false otherwise * @return the resolved artifacts. {@link Artifact}. - * @throws MojoExecutionException in case of error. + * @throws MojoExecutionException in case of error */ private Set resolve(Set artifacts, boolean stopOnFailure) throws MojoExecutionException { @@ -477,7 +477,7 @@ private Set resolve(Set artifact } /** - * @return Returns the markersDirectory. + * @return returns the markersDirectory */ public File getMarkersDirectory() { return this.markersDirectory; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java index 275f35d09..19038fac4 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java @@ -43,13 +43,13 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil protected File outputDirectory; /** - * Strip artifact version during copy + * Strip artifact version during copy. */ @Parameter(property = "mdep.stripVersion", defaultValue = "false") protected boolean stripVersion = false; /** - * Strip artifact type during copy + * Strip artifact type during copy. * * @since 3.4.0 */ @@ -57,7 +57,7 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil protected boolean stripType = false; /** - * Strip artifact classifier during copy + * Strip artifact classifier during copy. */ @Parameter(property = "mdep.stripClassifier", defaultValue = "false") protected boolean stripClassifier = false; @@ -130,49 +130,49 @@ public File getOutputDirectory() { } /** - * @param theOutputDirectory The outputDirectory to set. + * @param theOutputDirectory the outputDirectory to set */ public void setOutputDirectory(File theOutputDirectory) { this.outputDirectory = theOutputDirectory; } /** - * @return Returns the useSubDirectoryPerArtifact. + * @return returns the useSubDirectoryPerArtifact */ public boolean isUseSubDirectoryPerArtifact() { return this.useSubDirectoryPerArtifact; } /** - * @param theUseSubDirectoryPerArtifact The useSubDirectoryPerArtifact to set. + * @param theUseSubDirectoryPerArtifact the useSubDirectoryPerArtifact to set */ public void setUseSubDirectoryPerArtifact(boolean theUseSubDirectoryPerArtifact) { this.useSubDirectoryPerArtifact = theUseSubDirectoryPerArtifact; } /** - * @return Returns the useSubDirectoryPerScope + * @return returns the useSubDirectoryPerScope */ public boolean isUseSubDirectoryPerScope() { return this.useSubDirectoryPerScope; } /** - * @param theUseSubDirectoryPerScope The useSubDirectoryPerScope to set. + * @param theUseSubDirectoryPerScope the useSubDirectoryPerScope to set */ public void setUseSubDirectoryPerScope(boolean theUseSubDirectoryPerScope) { this.useSubDirectoryPerScope = theUseSubDirectoryPerScope; } /** - * @return Returns the useSubDirectoryPerType. + * @return returns the useSubDirectoryPerType */ public boolean isUseSubDirectoryPerType() { return this.useSubDirectoryPerType; } /** - * @param theUseSubDirectoryPerType The useSubDirectoryPerType to set. + * @param theUseSubDirectoryPerType the useSubDirectoryPerType to set */ public void setUseSubDirectoryPerType(boolean theUseSubDirectoryPerType) { this.useSubDirectoryPerType = theUseSubDirectoryPerType; @@ -228,7 +228,7 @@ public boolean isUseRepositoryLayout() { } /** - * @param useRepositoryLayout - true if dependencies must be planted in a repository layout + * @param useRepositoryLayout true if dependencies must be planted in a repository layout */ public void setUseRepositoryLayout(boolean useRepositoryLayout) { this.useRepositoryLayout = useRepositoryLayout; diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index 28068ffb2..c0cc14f03 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -110,7 +110,7 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements /** * Override the char used between the paths. This field is initialized to contain the first character of the value * of the system property file.separator. On UNIX systems the value of this field is '/'; on Microsoft Windows - * systems it is '\'. The default is File.separator + * systems it is '\'. The default is File.separator. * * @since 2.0 */ @@ -290,7 +290,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { * Checks that new classpath differs from that found inside the old classpathFile. * * @return true if the specified classpath equals the one found inside the file, false otherwise (including when - * file does not exist but new classpath does). + * file does not exist but new classpath does) */ private boolean isUpToDate(String cpString) { try { @@ -353,7 +353,7 @@ protected String readClasspathFile() throws IOException { * @param art2 second object * @return the value 0 if the argument string is equal to this string; a value less than 0 * if this string is lexicographically less than the string argument; and a value greater than - * 0 if this string is lexicographically greater than the string argument. + * 0 if this string is lexicographically greater than the string argument */ @Override public int compare(Artifact art1, Artifact art2) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java index 1bb9c40e0..ece098283 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/CopyDependenciesMojo.java @@ -283,6 +283,7 @@ protected void copyArtifact( /** * Copies the signature file of the artifact to the destination directory, if it exists or can be resolved. * If the signature file does not exist and cannot be resolved, a warning is logged. + * * @param artifact the artifact whose signature file should be copied * @param destDir the destination directory * @param destFileName the destination file name without the extension @@ -318,10 +319,10 @@ private void copySignatureFile(Artifact artifact, File destDir, String destFileN /** * Copy the pom files associated with the artifacts. * - * @param destDir The destination directory {@link File}. - * @param artifacts The artifacts {@link Artifact}. - * @param removeVersion remove version or not. - * @throws MojoExecutionException in case of errors. + * @param destDir the destination directory {@link File} + * @param artifacts the artifacts {@link Artifact} + * @param removeVersion remove version or not + * @throws MojoExecutionException in case of errors */ public void copyPoms(File destDir, Set artifacts, boolean removeVersion) throws MojoExecutionException { @@ -331,11 +332,11 @@ public void copyPoms(File destDir, Set artifacts, boolean removeVersio /** * Copy the pom files associated with the artifacts. * - * @param destDir The destination directory {@link File}. - * @param artifacts The artifacts {@link Artifact}. - * @param removeVersion remove version or not. - * @param removeClassifier remove the classifier or not. - * @throws MojoExecutionException in case of errors. + * @param destDir the destination directory {@link File} + * @param artifacts the artifacts {@link Artifact} + * @param removeVersion remove version or not + * @param removeClassifier remove the classifier or not + * @throws MojoExecutionException in case of errors */ public void copyPoms(File destDir, Set artifacts, boolean removeVersion, boolean removeClassifier) throws MojoExecutionException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java index dd018fd86..707178373 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java @@ -78,7 +78,7 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { private String excludes; /** - * ignore to set file permissions when unpacking a dependency + * Ignore to set file permissions when unpacking a dependency. * * @since 2.7 */ @@ -120,7 +120,7 @@ public UnpackDependenciesMojo( * Main entry into mojo. This method gets the dependencies and iterates through each one passing it to * DependencyUtil.unpackFile(). * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs * @see #getDependencySets(boolean) */ @Override @@ -166,35 +166,35 @@ protected ArtifactsFilter getMarkedArtifactFilter() { } /** - * @return Returns a comma separated list of excluded items + * @return returns a comma separated list of excluded items */ public String getExcludes() { return DependencyUtil.cleanToBeTokenizedString(this.excludes); } /** - * @param excludes A comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties + * @param excludes a comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties */ public void setExcludes(String excludes) { this.excludes = excludes; } /** - * @return Returns a comma separated list of included items + * @return returns a comma separated list of included items */ public String getIncludes() { return DependencyUtil.cleanToBeTokenizedString(this.includes); } /** - * @param includes A comma separated list of items to include i.e. **\/*.xml, **\/*.properties + * @param includes a comma separated list of items to include i.e. **\/*.xml, **\/*.properties */ public void setIncludes(String includes) { this.includes = includes; } /** - * @param encoding The encoding to set. + * @param encoding the encoding to set * @since 3.0 */ public void setEncoding(String encoding) { @@ -202,7 +202,7 @@ public void setEncoding(String encoding) { } /** - * @return Returns the encoding. + * @return returns the encoding * @since 3.0 */ public String getEncoding() { @@ -211,8 +211,7 @@ public String getEncoding() { /** * @return {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting shall - * happen. - * + * happen * @since 3.1.2 */ public FileMapper[] getFileMappers() { @@ -221,8 +220,7 @@ public FileMapper[] getFileMappers() { /** * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no - * rewriting shall happen. - * + * rewriting shall happen * @since 3.1.2 */ public void setFileMappers(FileMapper[] fileMappers) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index d503d65fe..d6adeefb5 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -83,7 +83,7 @@ public GoOfflineMojo( * Main entry into mojo. Gets the list of dependencies, resolves all that are not in the Reactor, and iterates * through displaying the resolved versions. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs */ @Override protected void doExecute() throws MojoExecutionException { @@ -112,8 +112,8 @@ protected void doExecute() throws MojoExecutionException { * This method resolves the dependency artifacts from the project. * * @return set of resolved dependency artifacts - * @throws DependencyResolverException in case of an error while resolving the artifacts * @throws ArtifactFilterException + * @throws DependencyResolverException in case of an error while resolving the artifacts */ protected Set resolveDependencyArtifacts() throws DependencyResolverException, ArtifactFilterException { Collection dependencies = getProject().getDependencies(); @@ -167,8 +167,8 @@ private TransformableFilter getTransformableFilter() { * This method resolves the plugin artifacts from the project. * * @return set of resolved plugin artifacts - * @throws DependencyResolverException in case of an error while resolving the artifacts * @throws ArtifactFilterException + * @throws DependencyResolverException in case of an error while resolving the artifacts */ protected Set resolvePluginArtifacts() throws DependencyResolverException, ArtifactFilterException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java index 62a5330e5..b9bf0fb5b 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java @@ -71,7 +71,7 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { private String outputEncoding; /** - * If we should display the scope when resolving + * If we should display the scope when resolving. * * @since 2.0-alpha-2 */ @@ -79,7 +79,7 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { protected boolean outputScope; /** - * Output absolute filename for resolved artifacts + * Output absolute filename for resolved artifacts. * * @since 2.0 */ @@ -87,7 +87,7 @@ public class ResolveDependenciesMojo extends AbstractResolveMojo { private boolean outputAbsoluteArtifactFilename; /** - * Only used to store results for integration test validation + * Only used to store results for integration test validation. */ DependencyStatusSets results; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index e925c2381..d9f6a8681 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -64,7 +64,7 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { private String outputEncoding; /** - * Output absolute filename for resolved artifacts + * Output absolute filename for resolved artifacts. * * @since 2.0 */ @@ -91,7 +91,7 @@ public ResolvePluginsMojo( /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. * - * @throws MojoExecutionException with a message if an error occurs. + * @throws MojoExecutionException with a message if an error occurs */ @Override protected void doExecute() throws MojoExecutionException { @@ -177,7 +177,7 @@ protected void doExecute() throws MojoExecutionException { * * @param artifact the artifact used to retrieve dependencies * @return resolved set of dependencies - * @throws DependencyResolverException in case of error while resolving artifacts. + * @throws DependencyResolverException in case of error while resolving artifacts */ private Set resolveArtifactDependencies(final DependableCoordinate artifact) throws DependencyResolverException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java index 32ec08837..658813164 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/AbstractSerializingVisitor.java @@ -38,7 +38,7 @@ public abstract class AbstractSerializingVisitor { * Build a new AbstractSerializingDependencyNodeVisitor with the writer to serialize to. *

      * - * @param writer the writer to serialize to. + * @param writer the writer to serialize to */ public AbstractSerializingVisitor(Writer writer) { this.writer = writer; diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java index 5cc8f86c9..0508a313a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/DOTDependencyNodeVisitor.java @@ -38,7 +38,7 @@ public class DOTDependencyNodeVisitor extends AbstractSerializingVisitor impleme /** * Constructor. * - * @param writer the writer to write to. + * @param writer the writer to write to */ public DOTDependencyNodeVisitor(Writer writer) { super(writer); diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java index c6c600fa5..c81a81a61 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/GraphmlDependencyNodeVisitor.java @@ -55,7 +55,7 @@ public class GraphmlDependencyNodeVisitor extends AbstractSerializingVisitor imp /** * Constructor. * - * @param writer the writer to write to. + * @param writer the writer to write to */ public GraphmlDependencyNodeVisitor(Writer writer) { super(writer); @@ -115,8 +115,8 @@ public boolean visit(DependencyNode node) { * Current implementation is rather simple and uses hashcode. *

      * - * @param node the DependencyNode to use. - * @return the unique id. + * @param node the DependencyNode to use + * @return the unique id */ private static String generateId(DependencyNode node) { return String.valueOf(node.hashCode()); diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java index c2fb62fd4..3dc3a3286 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TGFDependencyNodeVisitor.java @@ -60,9 +60,9 @@ static final class EdgeAppender { /** * Build a new EdgeAppender. * - * @param from edge start. + * @param from edge start * @param to edge end - * @param label optional label. + * @param label optional label */ EdgeAppender(DependencyNode from, DependencyNode to, String label) { super(); @@ -72,7 +72,7 @@ static final class EdgeAppender { } /** - * build a string representing the edge. + * Build a string representing the edge. */ @Override public String toString() { @@ -93,7 +93,7 @@ public String toString() { /** * Constructor. * - * @param writer the writer to write to. + * @param writer the writer to write to */ public TGFDependencyNodeVisitor(Writer writer) { super(writer); @@ -147,8 +147,8 @@ public boolean visit(DependencyNode node) { * Current implementation is rather simple and uses hashcode. *

      * - * @param node the DependencyNode to use. - * @return the unique id. + * @param node the DependencyNode to use + * @return the unique id */ private static String generateId(DependencyNode node) { return String.valueOf(node.hashCode()); diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java index b21f74890..a2e7d8e84 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/tree/TreeMojo.java @@ -65,7 +65,6 @@ * TGF and * JSON. * - * * @author Mark Hobson * @since 2.0-alpha-5 */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java index 28b5cc31a..d18fbd992 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/CopyUtil.java @@ -57,7 +57,6 @@ public CopyUtil(BuildContext buildContext) { * @param destination file name of destination file * @throws IOException if copy has failed * @throws MojoExecutionException if artifact file is a directory (which has not been packaged yet) - * * @since 3.7.0 */ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws IOException, MojoExecutionException { @@ -79,7 +78,6 @@ public void copyArtifactFile(Artifact sourceArtifact, File destination) throws I * @param source the source file to copy * @param destination the destination file * @throws IOException if copy has failed - * * @since 3.2.0 */ public void copyFile(File source, File destination) throws IOException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java index 483e34691..4aed77fa6 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java @@ -56,14 +56,14 @@ public DependencyStatusSets(Set resolved, Set unResolved, Se } /** - * @return Returns the resolvedDependencies. + * @return returns the resolvedDependencies */ public Set getResolvedDependencies() { return this.resolvedDependencies; } /** - * @param resolvedDependencies The resolvedDependencies to set. + * @param resolvedDependencies the resolvedDependencies to set */ public void setResolvedDependencies(Set resolvedDependencies) { if (resolvedDependencies != null) { @@ -74,14 +74,14 @@ public void setResolvedDependencies(Set resolvedDependencies) { } /** - * @return Returns the skippedDependencies. + * @return returns the skippedDependencies */ public Set getSkippedDependencies() { return this.skippedDependencies; } /** - * @param skippedDependencies The skippedDependencies to set. + * @param skippedDependencies the skippedDependencies to set */ public void setSkippedDependencies(Set skippedDependencies) { if (skippedDependencies != null) { @@ -92,14 +92,14 @@ public void setSkippedDependencies(Set skippedDependencies) { } /** - * @return Returns the unResolvedDependencies. + * @return returns the unResolvedDependencies */ public Set getUnResolvedDependencies() { return this.unResolvedDependencies; } /** - * @param unResolvedDependencies The unResolvedDependencies to set. + * @param unResolvedDependencies the unResolvedDependencies to set */ public void setUnResolvedDependencies(Set unResolvedDependencies) { if (unResolvedDependencies != null) { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index f0a333794..11e8be21a 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -44,9 +44,9 @@ public final class DependencyUtil { * Builds the file name. If removeVersion is set, then the file name must be reconstructed from the artifactId, * Classifier (if used) and Type. Otherwise, this method returns the artifact file name. * - * @param artifact File to be formatted. - * @param removeVersion Specifies if the version should be removed from the file name. - * @return Formatted file name in the format artifactId-[version]-[classifier].[type] + * @param artifact file to be formatted + * @param removeVersion specifies if the version should be removed from the file name + * @return formatted file name in the format artifactId-[version]-[classifier].[type] * @see #getFormattedFileName(Artifact, boolean, boolean) */ public static String getFormattedFileName(Artifact artifact, boolean removeVersion) { @@ -58,10 +58,10 @@ public static String getFormattedFileName(Artifact artifact, boolean removeVersi * prependGroupId is true) artifactId, Classifier (if used) and Type. Otherwise, this method returns the * artifact file name. * - * @param artifact File to be formatted. - * @param removeVersion Specifies if the version should be removed from the file name. - * @param prependGroupId Specifies if the groupId should be prepended to the file name. - * @return Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] + * @param artifact file to be formatted + * @param removeVersion specifies if the version should be removed from the file name + * @param prependGroupId specifies if the groupId should be prepended to the file name + * @return formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] */ public static String getFormattedFileName(Artifact artifact, boolean removeVersion, boolean prependGroupId) { return getFormattedFileName(artifact, removeVersion, prependGroupId, false); @@ -73,10 +73,10 @@ public static String getFormattedFileName(Artifact artifact, boolean removeVersi * artifact file name. * * @param artifact file to be formatted - * @param removeVersion Specifies if the version should be removed from the file name - * @param prependGroupId Specifies if the groupId should be prepended to the file name - * @param useBaseVersion Specifies if the baseVersion of the artifact should be used instead of the version - * @return Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] + * @param removeVersion specifies if the version should be removed from the file name + * @param prependGroupId specifies if the groupId should be prepended to the file name + * @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version + * @return formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] */ public static String getFormattedFileName( Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion) { @@ -88,12 +88,12 @@ public static String getFormattedFileName( * prependGroupId is true) artifactId, Classifier (if used) and Type. Otherwise, this method returns the * artifact file name. * - * @param artifact File to be formatted. - * @param removeVersion Specifies if the version should be removed from the file name. - * @param prependGroupId Specifies if the groupId should be prepended to the file name. - * @param useBaseVersion Specifies if the baseVersion of the artifact should be used instead of the version. - * @param removeClassifier Specifies if the classifier of the artifact should be remved from the file name. - * @return Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] + * @param artifact file to be formatted + * @param removeVersion specifies if the version should be removed from the file name + * @param prependGroupId specifies if the groupId should be prepended to the file name + * @param useBaseVersion specifies if the baseVersion of the artifact should be used instead of the version + * @param removeClassifier specifies if the classifier of the artifact should be remved from the file name + * @return formatted file name in the format [groupId].artifactId-[version]-[classifier].[type] */ public static String getFormattedFileName( Artifact artifact, diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java index 1727c4852..ace152ef7 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ParamArtifact.java @@ -19,7 +19,7 @@ package org.apache.maven.plugins.dependency.utils; /** - * Represent artifact data collected from Mojo parameters + * Represent artifact data collected from Mojo parameters. */ public class ParamArtifact { private String groupId; @@ -83,7 +83,7 @@ public void setArtifact(String artifact) { } /** - * Determinate if all needed data is set + * Determinate if all needed data is set. */ public boolean isDataSet() { return artifact != null || (groupId != null && artifactId != null && version != null); diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java index d661377fe..83e31dba1 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -87,12 +87,12 @@ public Collection collectDependencies(Dependency root) throws Depend } /** - * Resolve given artifact + * Resolve given artifact. * * @param artifact an artifact to resolve * @param repositories remote repositories list * @return resolved artifact - * @throws ArtifactResolutionException If the artifact could not be resolved. + * @throws ArtifactResolutionException if the artifact could not be resolved */ public Artifact resolveArtifact(Artifact artifact, List repositories) throws ArtifactResolutionException { @@ -108,8 +108,8 @@ public Artifact resolveArtifact(Artifact artifact, List reposi * @param artifact an artifact to resolve * @param repositories remote repositories list * @return list of transitive dependencies for artifact - * @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could - * not be resolved. + * @throws DependencyResolutionException if the dependency tree could not be built or any dependency artifact could + * not be resolved */ public List resolveDependencies(Artifact artifact, List repositories) throws DependencyResolutionException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java index 817adb4d6..0d6cd7164 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java @@ -44,12 +44,12 @@ public class UnpackUtil { /** - * To look up Archiver/UnArchiver implementations + * To look up Archiver/UnArchiver implementations. */ private final ArchiverManager archiverManager; /** - * For IDE build support + * For IDE build support. */ private final BuildContext buildContext; @@ -68,16 +68,16 @@ public UnpackUtil(ArchiverManager archiverManager, BuildContext buildContext) { /** * @param file file to unpack * @param type file / artifact type - * @param location The location. - * @param includes includes list. - * @param excludes excludes list. - * @param encoding the encoding. + * @param location the location + * @param includes includes list + * @param excludes excludes list + * @param encoding the encoding * @param ignorePermissions ignore permissions * @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no * rewriting - * shall happen. + * shall happen * @param logger a Mojo logger - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ public void unpack( File file, diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/ArtifactItemFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/ArtifactItemFilter.java index a6880e626..9b2135639 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/ArtifactItemFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/ArtifactItemFilter.java @@ -28,8 +28,8 @@ public interface ArtifactItemFilter { /** * @param item {@link ArtifactItem} - * @return true/false. - * @throws ArtifactFilterException in case of an error. + * @return true/false + * @throws ArtifactFilterException in case of an error */ boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterException; } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java index 669c90c13..3d04a537e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/DestFileFilter.java @@ -61,24 +61,24 @@ public class DestFileFilter extends AbstractArtifactsFilter implements ArtifactI private File outputFileDirectory; /** - * @param outputFileDirectory the output directory. + * @param outputFileDirectory the output directory */ public DestFileFilter(File outputFileDirectory) { this(false, false, false, false, false, false, false, false, false, false, outputFileDirectory); } /** - * @param overWriteReleases true/false. - * @param overWriteSnapshots true/false. - * @param overWriteIfNewer true/false. - * @param useSubDirectoryPerArtifact true/false. - * @param useSubDirectoryPerType true/false. - * @param useSubDirectoryPerScope true/false. - * @param useRepositoryLayout true/false. - * @param removeVersion true/false. - * @param prependGroupId true/false. - * @param useBaseVersion true/false. - * @param outputFileDirectory the output directory. + * @param overWriteReleases true/false + * @param overWriteSnapshots true/false + * @param overWriteIfNewer true/false + * @param useSubDirectoryPerArtifact true/false + * @param useSubDirectoryPerType true/false + * @param useSubDirectoryPerScope true/false + * @param useRepositoryLayout true/false + * @param removeVersion true/false + * @param prependGroupId true/false + * @param useBaseVersion true/false + * @param outputFileDirectory the output directory */ public DestFileFilter( boolean overWriteReleases, @@ -123,133 +123,133 @@ public Set filter(Set artifacts) throws ArtifactFilterExcept } /** - * @return Returns the overWriteReleases. + * @return returns the overWriteReleases */ public boolean isOverWriteReleases() { return this.overWriteReleases; } /** - * @param overWriteReleases The overWriteReleases to set. + * @param overWriteReleases the overWriteReleases to set */ public void setOverWriteReleases(boolean overWriteReleases) { this.overWriteReleases = overWriteReleases; } /** - * @return Returns the overWriteSnapshots. + * @return returns the overWriteSnapshots */ public boolean isOverWriteSnapshots() { return this.overWriteSnapshots; } /** - * @param overWriteSnapshots The overWriteSnapshots to set. + * @param overWriteSnapshots the overWriteSnapshots to set */ public void setOverWriteSnapshots(boolean overWriteSnapshots) { this.overWriteSnapshots = overWriteSnapshots; } /** - * @return Returns the overWriteIfNewer. + * @return returns the overWriteIfNewer */ public boolean isOverWriteIfNewer() { return this.overWriteIfNewer; } /** - * @param overWriteIfNewer The overWriteIfNewer to set. + * @param overWriteIfNewer the overWriteIfNewer to set */ public void setOverWriteIfNewer(boolean overWriteIfNewer) { this.overWriteIfNewer = overWriteIfNewer; } /** - * @return Returns the outputFileDirectory. + * @return returns the outputFileDirectory */ public File getOutputFileDirectory() { return this.outputFileDirectory; } /** - * @param outputFileDirectory The outputFileDirectory to set. + * @param outputFileDirectory the outputFileDirectory to set */ public void setOutputFileDirectory(File outputFileDirectory) { this.outputFileDirectory = outputFileDirectory; } /** - * @return Returns the removeVersion. + * @return returns the removeVersion */ public boolean isRemoveVersion() { return this.removeVersion; } /** - * @param removeType The removeType to set. + * @param removeType the removeType to set */ public void setRemoveType(boolean removeType) { this.removeType = removeType; } /** - * @return Returns the removeType. + * @return returns the removeType */ public boolean isRemoveType() { return this.removeType; } /** - * @param removeVersion The removeVersion to set. + * @param removeVersion the removeVersion to set */ public void setRemoveVersion(boolean removeVersion) { this.removeVersion = removeVersion; } /** - * @return Returns the removeClassifier. + * @return returns the removeClassifier */ public boolean isRemoveClassifier() { return this.removeClassifier; } /** - * @param removeClassifier The removeClassifier to set. + * @param removeClassifier the removeClassifier to set */ public void setRemoveClassifier(boolean removeClassifier) { this.removeClassifier = removeClassifier; } /** - * @return Returns the useSubDirectoryPerArtifact. + * @return returns the useSubDirectoryPerArtifact */ public boolean isUseSubDirectoryPerArtifact() { return this.useSubDirectoryPerArtifact; } /** - * @param useSubDirectoryPerArtifact The useSubDirectoryPerArtifact to set. + * @param useSubDirectoryPerArtifact the useSubDirectoryPerArtifact to set */ public void setUseSubDirectoryPerArtifact(boolean useSubDirectoryPerArtifact) { this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact; } /** - * @return Returns the useSubDirectoryPerType. + * @return returns the useSubDirectoryPerType */ public boolean isUseSubDirectoryPerType() { return this.useSubDirectoryPerType; } /** - * @param useSubDirectoryPerType The useSubDirectoryPerType to set. + * @param useSubDirectoryPerType the useSubDirectoryPerType to set */ public void setUseSubDirectoryPerType(boolean useSubDirectoryPerType) { this.useSubDirectoryPerType = useSubDirectoryPerType; } /** - * @return Returns the useRepositoryLayout + * @return returns the useRepositoryLayout */ public boolean isUseRepositoryLayout() { return useRepositoryLayout; @@ -299,10 +299,10 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept /** * {@code File.getLastModified} sometimes returns a wrong value. See JDK bug for details. *

      - * https://bugs.openjdk.java.net/browse/JDK-8177809 + * https://bugs.openjdk.java.net/browse/JDK-8177809. * * @param file {@link File} - * @return the last modification time in milliseconds. + * @return the last modification time in milliseconds * @throws ArtifactFilterException in case of an IOException */ private long getLastModified(File file) throws ArtifactFilterException { diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java index f841e6e78..2a3bd5566 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/filters/MarkerFileFilter.java @@ -45,9 +45,9 @@ public class MarkerFileFilter extends AbstractArtifactsFilter implements Artifac protected final MarkerHandler handler; /** - * @param overWriteReleases true/false. - * @param overWriteSnapshots true/false. - * @param overWriteIfNewer true/false. + * @param overWriteReleases true/false + * @param overWriteSnapshots true/false + * @param overWriteIfNewer true/false * @param handler {@link MarkerHandler} */ public MarkerFileFilter( @@ -93,42 +93,42 @@ public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterExcept } /** - * @return Returns the overWriteReleases. + * @return returns the overWriteReleases */ public boolean isOverWriteReleases() { return this.overWriteReleases; } /** - * @param overWriteReleases The overWriteReleases to set. + * @param overWriteReleases the overWriteReleases to set */ public void setOverWriteReleases(boolean overWriteReleases) { this.overWriteReleases = overWriteReleases; } /** - * @return Returns the overWriteSnapshots. + * @return returns the overWriteSnapshots */ public boolean isOverWriteSnapshots() { return this.overWriteSnapshots; } /** - * @param overWriteSnapshots The overWriteSnapshots to set. + * @param overWriteSnapshots the overWriteSnapshots to set */ public void setOverWriteSnapshots(boolean overWriteSnapshots) { this.overWriteSnapshots = overWriteSnapshots; } /** - * @return Returns the overWriteIfNewer. + * @return returns the overWriteIfNewer */ public boolean isOverWriteIfNewer() { return this.overWriteIfNewer; } /** - * @param overWriteIfNewer The overWriteIfNewer to set. + * @param overWriteIfNewer the overWriteIfNewer to set */ public void setOverWriteIfNewer(boolean overWriteIfNewer) { this.overWriteIfNewer = overWriteIfNewer; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java index 27d7e4f6d..bd9a54b28 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/DefaultFileMarkerHandler.java @@ -39,7 +39,7 @@ public class DefaultFileMarkerHandler implements MarkerHandler { protected File markerFilesDirectory; /** - * @param theMarkerFilesDirectory The marker directory. + * @param theMarkerFilesDirectory the marker directory */ public DefaultFileMarkerHandler(File theMarkerFilesDirectory) { this.markerFilesDirectory = theMarkerFilesDirectory; @@ -47,7 +47,7 @@ public DefaultFileMarkerHandler(File theMarkerFilesDirectory) { /** * @param theArtifact {@link Artifact} - * @param theMarkerFilesDirectory The marker directory. + * @param theMarkerFilesDirectory the marker directory */ public DefaultFileMarkerHandler(Artifact theArtifact, File theMarkerFilesDirectory) { this.artifact = theArtifact; @@ -55,9 +55,9 @@ public DefaultFileMarkerHandler(Artifact theArtifact, File theMarkerFilesDirecto } /** - * Returns properly formatted File + * Returns properly formatted File. * - * @return File object for marker. The file is not guaranteed to exist. + * @return file object for marker. The file is not guaranteed to exist. */ protected File getMarkerFile() { return new File(this.markerFilesDirectory, this.artifact.getId().replace(':', '-') + ".marker"); @@ -68,7 +68,7 @@ protected File getMarkerFile() { * * @return true if and only if the file or directory denoted by this abstract pathname exists; * false otherwise - * @throws SecurityException If a security manager exists and its {@link + * @throws SecurityException if a security manager exists and its {@link * java.lang.SecurityManager#checkRead(java.lang.String)} method denies read access to the file or * directory */ @@ -128,7 +128,7 @@ public void setMarker() throws MojoExecutionException { * * @return true if and only if the file or directory is successfully deleted; false * otherwise - * @throws SecurityException If a security manager exists and its {@link + * @throws SecurityException if a security manager exists and its {@link * java.lang.SecurityManager#checkDelete} method denies delete access to the file */ @Override @@ -138,14 +138,14 @@ public boolean clearMarker() throws MojoExecutionException { } /** - * @return Returns the artifact. + * @return returns the artifact */ public Artifact getArtifact() { return this.artifact; } /** - * @param artifact The artifact to set. + * @param artifact the artifact to set */ @Override public void setArtifact(Artifact artifact) { @@ -153,14 +153,14 @@ public void setArtifact(Artifact artifact) { } /** - * @return Returns the markerFilesDirectory. + * @return returns the markerFilesDirectory */ public File getMarkerFilesDirectory() { return this.markerFilesDirectory; } /** - * @param markerFilesDirectory The markerFilesDirectory to set. + * @param markerFilesDirectory the markerFilesDirectory to set */ public void setMarkerFilesDirectory(File markerFilesDirectory) { this.markerFilesDirectory = markerFilesDirectory; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/MarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/MarkerHandler.java index a56aee647..541e9b070 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/MarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/MarkerHandler.java @@ -26,26 +26,26 @@ */ public interface MarkerHandler { /** - * @return true/false. - * @throws MojoExecutionException in case of an error. + * @return true/false + * @throws MojoExecutionException in case of an error */ boolean isMarkerSet() throws MojoExecutionException; /** - * @throws MojoExecutionException in case of an error. + * @throws MojoExecutionException in case of an error */ void setMarker() throws MojoExecutionException; /** - * @return true/false. - * @throws MojoExecutionException in case of an error. + * @return true/false + * @throws MojoExecutionException in case of an error */ boolean clearMarker() throws MojoExecutionException; /** * @param artifact {@link Artifact} - * @return true/false. - * @throws MojoExecutionException in case of an error. + * @return true/false + * @throws MojoExecutionException in case of an error */ boolean isMarkerOlder(Artifact artifact) throws MojoExecutionException; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java index 97638cd45..7cd9cef93 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/SourcesFileMarkerHandler.java @@ -32,7 +32,7 @@ public class SourcesFileMarkerHandler extends DefaultFileMarkerHandler { boolean resolved; /** - * @param markerFilesDirectory the marker files directory. + * @param markerFilesDirectory the marker files directory */ public SourcesFileMarkerHandler(File markerFilesDirectory) { super(markerFilesDirectory); @@ -40,8 +40,8 @@ public SourcesFileMarkerHandler(File markerFilesDirectory) { /** * @param artifact {@link Artifact} - * @param markerFilesDirectory marker files directory. - * @param isResolved true/false. + * @param markerFilesDirectory marker files directory + * @param isResolved true/false */ public SourcesFileMarkerHandler(Artifact artifact, File markerFilesDirectory, boolean isResolved) { super(artifact, markerFilesDirectory); @@ -49,9 +49,9 @@ public SourcesFileMarkerHandler(Artifact artifact, File markerFilesDirectory, bo } /** - * Returns properly formatted File + * Returns properly formatted File. * - * @return File object for marker. The file is not guaranteed to exist. + * @return file object for marker. The file is not guaranteed to exist. */ @Override public File getMarkerFile() { @@ -59,10 +59,10 @@ public File getMarkerFile() { } /** - * Get MarkerFile, exposed for unit testing purposes + * Get MarkerFile, exposed for unit testing purposes. * - * @param res resolved or not. - * @return marker file for this artifact. + * @param res resolved or not + * @return marker file for this artifact */ protected File getMarkerFile(boolean res) { String suffix; @@ -80,7 +80,7 @@ protected File getMarkerFile(boolean res) { * * @return true if and only if the file or directory denoted by this abstract pathname exists; * false otherwise - * @throws MojoExecutionException If a security manager exists and its {@link + * @throws MojoExecutionException if a security manager exists and its {@link * java.lang.SecurityManager#checkRead(java.lang.String)} method denies read access to the file or * directory */ @@ -142,7 +142,7 @@ public void setMarker() throws MojoExecutionException { * * @return true if and only if the file or directory is successfully deleted; false * otherwise - * @throws SecurityException If a security manager exists and its {@link + * @throws SecurityException if a security manager exists and its {@link * java.lang.SecurityManager#checkDelete} method denies delete access to the file */ @Override @@ -155,14 +155,14 @@ public boolean clearMarker() throws MojoExecutionException { } /** - * @return Returns the resolved. + * @return returns the resolved */ public boolean isResolved() { return this.resolved; } /** - * @param isResolved The resolved to set. + * @param isResolved the resolved to set */ public void setResolved(boolean isResolved) { this.resolved = isResolved; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java index 396f39fc5..cae50ab7e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/markers/UnpackFileMarkerHandler.java @@ -32,7 +32,7 @@ public class UnpackFileMarkerHandler extends DefaultFileMarkerHandler { protected ArtifactItem artifactItem; /** - * @param markerFilesDirectory The marker files directory. + * @param markerFilesDirectory the marker files directory */ public UnpackFileMarkerHandler(File markerFilesDirectory) { super(markerFilesDirectory); @@ -40,7 +40,7 @@ public UnpackFileMarkerHandler(File markerFilesDirectory) { /** * @param artifactItem {@link ArtifactItem} - * @param markerFilesDirectory the marker files directory. + * @param markerFilesDirectory the marker files directory */ public UnpackFileMarkerHandler(ArtifactItem artifactItem, File markerFilesDirectory) { this(markerFilesDirectory); diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java index 12f4ed4c0..d2dbd2901 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ArtifactTranslator.java @@ -28,7 +28,7 @@ */ public interface ArtifactTranslator { /** - * @param artifacts set of {@link Artifact}s. + * @param artifacts set of {@link Artifact}s * @param log {@link Log} * @return set of {@link org.eclipse.aether.artifact.Artifact} */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java index 3aec5907b..188f6f3fd 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java @@ -39,9 +39,9 @@ public class ClassifierTypeTranslator implements ArtifactTranslator { private String type; /** - * @param artifactHandlerManager {@link ArtifactHandlerManager}. - * @param theClassifier The classifier to use. - * @param theType The type. + * @param artifactHandlerManager {@link ArtifactHandlerManager} + * @param theClassifier the classifier to use + * @param theType the type */ public ClassifierTypeTranslator( ArtifactHandlerManager artifactHandlerManager, String theClassifier, String theType) { @@ -95,28 +95,28 @@ public Set translate(Set artifac } /** - * @return Returns the type. + * @return returns the type */ public String getType() { return this.type; } /** - * @param theType The type to set. + * @param theType the type to set */ public void setType(String theType) { this.type = theType; } /** - * @return Returns the classifier. + * @return returns the classifier */ public String getClassifier() { return this.classifier; } /** - * @param theClassifier The classifier to set. + * @param theClassifier the classifier to set */ public void setClassifier(String theClassifier) { this.classifier = theClassifier; From 93776499fe324aa31c91c4ae9f0fb48878c8ab35 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 13 Sep 2025 23:28:16 +0200 Subject: [PATCH 273/283] ProjectBuildingRequest should not be modified We should set new properties on copy of ProjectBuildingRequest not on one returned by MavenSession In other case change can have impact on whole MavenSession --- .../fromDependencies/AbstractDependencyFilterMojo.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 0f4def217..992807f98 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -38,9 +38,11 @@ import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.plugins.dependency.utils.translators.ArtifactTranslator; import org.apache.maven.plugins.dependency.utils.translators.ClassifierTypeTranslator; +import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -353,9 +355,10 @@ protected DependencyStatusSets getDependencySets(boolean stopOnFailure, boolean private MavenProject buildProjectFromArtifact(Artifact artifact) throws MojoExecutionException { try { - return projectBuilder - .build(artifact, session.getProjectBuildingRequest().setProcessPlugins(false)) - .getProject(); + ProjectBuildingRequest buildingRequest = + new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + buildingRequest.setProcessPlugins(false); + return projectBuilder.build(artifact, buildingRequest).getProject(); } catch (ProjectBuildingException e) { throw new MojoExecutionException("Coud not build project for " + artifact.getId(), e); } From bc1893f40ddad014bc33d77621068dfd3b145455 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 15 Sep 2025 23:57:23 +0200 Subject: [PATCH 274/283] Use Resolver API in resolve-plugin - change parent class to fewer details - use parameter where is needed - retrieve list of plugins from project reposting / build section --- src/it/projects/resolve-plugins/pom.xml | 51 ++++ .../PluginsIncludeExcludeFilter.java | 65 +++++ .../PluginsReactorExcludeFilter.java | 49 ++++ .../resolvers/ResolvePluginsMojo.java | 253 +++++++++++------- .../dependency/utils/ResolverUtil.java | 67 ++++- 5 files changed, 384 insertions(+), 101 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsIncludeExcludeFilter.java create mode 100644 src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsReactorExcludeFilter.java diff --git a/src/it/projects/resolve-plugins/pom.xml b/src/it/projects/resolve-plugins/pom.xml index 5a20fa27b..c0df89152 100644 --- a/src/it/projects/resolve-plugins/pom.xml +++ b/src/it/projects/resolve-plugins/pom.xml @@ -36,4 +36,55 @@ UTF-8 + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.4 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.commons + commons-lang3 + 3.18.0 + + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.5.4 + + + org.apache.maven.plugins + maven-assembly-plugin + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsIncludeExcludeFilter.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsIncludeExcludeFilter.java new file mode 100644 index 000000000..7de7a7f44 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsIncludeExcludeFilter.java @@ -0,0 +1,65 @@ +/* + * 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.dependency.resolvers; + +import java.util.List; +import java.util.function.Predicate; + +import org.apache.maven.model.Plugin; + +/** + * A filter to include or exclude plugins. + */ +class PluginsIncludeExcludeFilter implements Predicate { + private final List includesGroupId; + + private final List excludesGroupId; + + private final List includesArtifactId; + + private final List excludesArtifactId; + + PluginsIncludeExcludeFilter( + List includeGroupIds, + List excludeGroupIds, + List includeArtifactIds, + List excludeArtifactIds) { + this.includesGroupId = includeGroupIds; + this.excludesGroupId = excludeGroupIds; + this.includesArtifactId = includeArtifactIds; + this.excludesArtifactId = excludeArtifactIds; + } + + @Override + public boolean test(Plugin plugin) { + if (!includesGroupId.isEmpty() && !includesGroupId.contains(plugin.getGroupId())) { + return false; + } + + if (excludesGroupId.contains(plugin.getGroupId())) { + return false; + } + + if (!includesArtifactId.isEmpty() && !includesArtifactId.contains(plugin.getArtifactId())) { + return false; + } + + return !excludesArtifactId.contains(plugin.getArtifactId()); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsReactorExcludeFilter.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsReactorExcludeFilter.java new file mode 100644 index 000000000..42c11c3ac --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/PluginsReactorExcludeFilter.java @@ -0,0 +1,49 @@ +/* + * 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.dependency.resolvers; + +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.model.Plugin; +import org.apache.maven.project.MavenProject; + +/** + * A filter to exclude plugins that are part of the current reactor build. + */ +class PluginsReactorExcludeFilter implements Predicate { + + private final Set reactorArtifactKeys; + + PluginsReactorExcludeFilter(List reactorProjects) { + this.reactorArtifactKeys = new LinkedHashSet<>(reactorProjects.size()); + for (final MavenProject project : reactorProjects) { + this.reactorArtifactKeys.add(ArtifactUtils.key(project.getArtifact())); + } + } + + @Override + public boolean test(Plugin plugin) { + String pluginKey = ArtifactUtils.key(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion()); + return !reactorArtifactKeys.contains(pluginKey); + } +} diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index d9f6a8681..116fef919 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -20,35 +20,34 @@ import javax.inject.Inject; +import java.io.File; import java.io.IOException; -import java.util.HashSet; +import java.util.Collections; import java.util.LinkedHashSet; +import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; -import org.apache.maven.RepositoryUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.ModelBase; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginContainer; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.Reporting; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.AbstractDependencyMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; -import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; -import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.DependencyResolutionException; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -58,8 +57,79 @@ * @since 2.0 */ @Mojo(name = "resolve-plugins", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) -public class ResolvePluginsMojo extends AbstractResolveMojo { +public class ResolvePluginsMojo extends AbstractDependencyMojo { + /** + * If specified, this parameter causes the dependencies to be written to the path specified instead of + * the console. + * + * @since 2.0 + */ + @Parameter(property = "outputFile") + protected File outputFile; + + /** + * If we should exclude transitive dependencies. + * This means only the plugin artifacts itself will be resolved not plugin dependencies. + * + * @since 2.0 + */ + @Parameter(property = "excludeTransitive", defaultValue = "false") + protected boolean excludeTransitive; + + /** + * List of artifact IDs to exclude. + * + * @since 2.0 + */ + @Parameter(property = "excludeArtifactIds", defaultValue = "") + protected List excludeArtifactIds; + + /** + * List of artifact IDs to include. Empty list indicates include everything (default). + * + * @since 2.0 + */ + @Parameter(property = "includeArtifactIds", defaultValue = "") + protected List includeArtifactIds; + + /** + * List of group IDs to exclude. + * + * @since 2.0 + */ + @Parameter(property = "excludeGroupIds", defaultValue = "") + protected List excludeGroupIds; + + /** + * List of group IDs to include. Empty list indicates include everything (default). + * + * @since 2.0 + */ + @Parameter(property = "includeGroupIds", defaultValue = "") + protected List includeGroupIds; + + /** + * Whether to append outputs into the output file or overwrite it. + * + * @since 2.2 + */ + @Parameter(property = "appendOutput", defaultValue = "false") + protected boolean appendOutput; + + /** + * Don't resolve plugins that are in the current reactor. + * + * @since 2.7 + */ + @Parameter(property = "excludeReactor", defaultValue = "true") + protected boolean excludeReactor; + + /** + * The encoding of the output file. + * + * @since 3.2.0 + */ @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") private String outputEncoding; @@ -71,22 +141,14 @@ public class ResolvePluginsMojo extends AbstractResolveMojo { @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false") private boolean outputAbsoluteArtifactFilename; - private final DependencyResolver dependencyResolver; + private final ResolverUtil resolverUtil; @Inject - // CHECKSTYLE_OFF: ParameterNumber public ResolvePluginsMojo( - MavenSession session, - BuildContext buildContext, - MavenProject project, - ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, - ProjectBuilder projectBuilder, - ArtifactHandlerManager artifactHandlerManager) { - super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); - this.dependencyResolver = dependencyResolver; + MavenSession session, BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil) { + super(session, buildContext, project); + this.resolverUtil = resolverUtil; } - // CHECKSTYLE_ON: ParameterNumber /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. @@ -97,7 +159,7 @@ public ResolvePluginsMojo( protected void doExecute() throws MojoExecutionException { try { // ideally this should either be DependencyCoordinates or DependencyNode - final Set plugins = resolvePluginArtifacts(); + final Set plugins = getProjectPlugins(); StringBuilder sb = new StringBuilder(); sb.append(System.lineSeparator()); @@ -107,42 +169,32 @@ protected void doExecute() throws MojoExecutionException { sb.append(" none"); sb.append(System.lineSeparator()); } else { - for (Artifact plugin : plugins) { + for (Plugin plugin : plugins) { + Artifact pluginArtifact = resolverUtil.resolvePlugin(plugin); String artifactFilename = null; if (outputAbsoluteArtifactFilename) { - try { - // we want to print the absolute file name here - artifactFilename = - plugin.getFile().getAbsoluteFile().getPath(); - } catch (NullPointerException e) { - // ignore the null pointer, we'll output a null string - artifactFilename = null; - } + // we want to print the absolute file name here + artifactFilename = Optional.ofNullable(pluginArtifact.getFile()) + .map(File::getAbsoluteFile) + .map(File::getPath) + .orElse(null); } - String id = plugin.toString(); + String id = pluginArtifact.toString(); sb.append(" ") .append(id) .append(outputAbsoluteArtifactFilename ? ":" + artifactFilename : "") .append(System.lineSeparator()); if (!excludeTransitive) { - DefaultDependableCoordinate pluginCoordinate = new DefaultDependableCoordinate(); - pluginCoordinate.setGroupId(plugin.getGroupId()); - pluginCoordinate.setArtifactId(plugin.getArtifactId()); - pluginCoordinate.setVersion(plugin.getVersion()); - - for (final Artifact artifact : resolveArtifactDependencies(pluginCoordinate)) { + for (Artifact artifact : resolverUtil.resolveDependencies(plugin)) { artifactFilename = null; if (outputAbsoluteArtifactFilename) { - try { - // we want to print the absolute file name here - artifactFilename = - artifact.getFile().getAbsoluteFile().getPath(); - } catch (NullPointerException e) { - // ignore the null pointer, we'll output a null string - artifactFilename = null; - } + // we want to print the absolute file name here + artifactFilename = Optional.ofNullable(artifact.getFile()) + .map(File::getAbsoluteFile) + .map(File::getPath) + .orElse(null); } id = artifact.toString(); @@ -163,70 +215,71 @@ protected void doExecute() throws MojoExecutionException { DependencyUtil.write(output, outputFile, appendOutput, encoding); } } - } catch (IOException - | ArtifactFilterException - | ArtifactResolverException - | DependencyResolverException - | ArtifactResolutionException e) { + } catch (IOException | ArtifactResolutionException | DependencyResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } /** - * This method resolves all transitive dependencies of an artifact. + * This return plugin list of the project after applying the include/exclude filters. * - * @param artifact the artifact used to retrieve dependencies - * @return resolved set of dependencies - * @throws DependencyResolverException in case of error while resolving artifacts + * @return set of project plugin */ - private Set resolveArtifactDependencies(final DependableCoordinate artifact) - throws DependencyResolverException { - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - Iterable artifactResults = - dependencyResolver.resolveDependencies(buildingRequest, artifact, null); + private Set getProjectPlugins() { - Set artifacts = new LinkedHashSet<>(); + Predicate pluginsFilter = new PluginsIncludeExcludeFilter( + includeGroupIds, excludeGroupIds, includeArtifactIds, excludeArtifactIds); - for (final ArtifactResult artifactResult : artifactResults) { - artifacts.add(artifactResult.getArtifact()); + Predicate reactorExclusionFilter = plugin -> true; + if (excludeReactor) { + reactorExclusionFilter = new PluginsReactorExcludeFilter(session.getProjects()); } - return artifacts; - } + List reportPlugins = Optional.ofNullable(getProject().getModel()) + .map(ModelBase::getReporting) + .map(Reporting::getPlugins) + .orElse(Collections.emptyList()) + .stream() + .map(this::toPlugin) + .collect(Collectors.toList()); - /** - * This method resolves the plugin artifacts from the project. - * - * @return set of resolved plugin artifacts - * @throws ArtifactFilterException in case of an error - * @throws ArtifactResolverException in case of an error - */ - private Set resolvePluginArtifacts() - throws ArtifactFilterException, ArtifactResolverException, ArtifactResolutionException { - final Set plugins = getProject().getPluginArtifacts(); - final Set reports = getProject().getReportArtifacts(); + List projectPlugins = getProject().getBuild().getPlugins(); + + return new LinkedHashSet(reportPlugins.size() + projectPlugins.size()) { + { + addAll(reportPlugins); + addAll(projectPlugins); + } + }.stream().filter(reactorExclusionFilter).filter(pluginsFilter).collect(Collectors.toSet()); + } - Set artifacts = new HashSet<>(); - artifacts.addAll(reports); - artifacts.addAll(plugins); + private Plugin toPlugin(ReportPlugin reportPlugin) { + // first look in the pluginManagement section + Plugin plugin = Optional.ofNullable(getProject().getBuild().getPluginManagement()) + .map(PluginContainer::getPluginsAsMap) + .orElseGet(Collections::emptyMap) + .get(reportPlugin.getKey()); - final FilterArtifacts filter = getArtifactsFilter(); - artifacts = filter.filter(artifacts); + if (plugin == null) { + plugin = getProject().getBuild().getPluginsAsMap().get(reportPlugin.getKey()); + } - Set result = new HashSet<>(); - for (final Artifact artifact : new LinkedHashSet<>(artifacts)) { + if (plugin == null) { + plugin = new Plugin(); + plugin.setGroupId(reportPlugin.getGroupId()); + plugin.setArtifactId(reportPlugin.getArtifactId()); + plugin.setVersion(reportPlugin.getVersion()); + } else { + // override the version with the one from the report plugin if specified + if (reportPlugin.getVersion() != null) { + plugin.setVersion(reportPlugin.getVersion()); + } + } - org.eclipse.aether.artifact.Artifact resolveArtifact = getResolverUtil() - .resolveArtifact( - RepositoryUtils.toArtifact(artifact), getProject().getRemotePluginRepositories()); - result.add(RepositoryUtils.toArtifact(resolveArtifact)); + if (plugin.getVersion() == null) { + plugin.setVersion("RELEASE"); } - return result; - } - @Override - protected ArtifactsFilter getMarkedArtifactFilter() { - return null; + return plugin; } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java index 83e31dba1..ad5b356d3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -29,7 +29,9 @@ import java.util.Objects; import java.util.stream.Collectors; +import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Plugin; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -102,6 +104,19 @@ public Artifact resolveArtifact(Artifact artifact, List reposi return result.getArtifact(); } + /** + * Resolve given plugin artifact. + * + * @param plugin a plugin to resolve + * @return resolved artifact + * @throws ArtifactResolutionException if the artifact could not be resolved + */ + public Artifact resolvePlugin(Plugin plugin) throws ArtifactResolutionException { + MavenSession session = mavenSessionProvider.get(); + Artifact artifact = toArtifact(plugin); + return resolveArtifact(artifact, session.getCurrentProject().getRemotePluginRepositories()); + } + /** * Resolve transitive dependencies for artifact. * @@ -113,16 +128,66 @@ public Artifact resolveArtifact(Artifact artifact, List reposi */ public List resolveDependencies(Artifact artifact, List repositories) throws DependencyResolutionException { + return resolveDependencies(artifact, null, repositories); + } + + /** + * Resolve transitive dependencies for artifact. + * + * @param artifact an artifact to resolve + * @param dependencies a list of additional dependencies for artifact + * @param repositories remote repositories list + * @return list of transitive dependencies for artifact + * @throws DependencyResolutionException if the dependency tree could not be built or any dependency artifact could + * not be resolved + */ + public List resolveDependencies( + Artifact artifact, List dependencies, List repositories) + throws DependencyResolutionException { MavenSession session = mavenSessionProvider.get(); - CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, null), repositories); + CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, null), dependencies, repositories); DependencyRequest request = new DependencyRequest(collectRequest, null); + DependencyResult result = repositorySystem.resolveDependencies(session.getRepositorySession(), request); return result.getArtifactResults().stream() .map(ArtifactResult::getArtifact) .collect(Collectors.toList()); } + /** + * Resolve transitive dependencies for plugin. + * + * @param plugin aa plugin to resolve + * @return list of transitive dependencies for plugin + * @throws DependencyResolutionException if the dependency tree could not be built or any dependency artifact could + * not be resolved + */ + public List resolveDependencies(final Plugin plugin) throws DependencyResolutionException { + + MavenSession session = mavenSessionProvider.get(); + + org.eclipse.aether.artifact.Artifact artifact = toArtifact(plugin); + List pluginDependencies = plugin.getDependencies().stream() + .map(d -> RepositoryUtils.toDependency( + d, session.getRepositorySession().getArtifactTypeRegistry())) + .collect(Collectors.toList()); + + return resolveDependencies( + artifact, pluginDependencies, session.getCurrentProject().getRemoteProjectRepositories()); + } + + private Artifact toArtifact(Plugin plugin) { + MavenSession session = mavenSessionProvider.get(); + return new DefaultArtifact( + plugin.getGroupId(), + plugin.getArtifactId(), + null, + "jar", + plugin.getVersion(), + session.getRepositorySession().getArtifactTypeRegistry().get("maven-plugin")); + } + /** * Prepare a remote repositories list for given descriptions. * From 23186d4462bf16ddd566a5e64f1e1c21580e7f51 Mon Sep 17 00:00:00 2001 From: Romain Manni-Bucau Date: Thu, 18 Sep 2025 08:03:22 +0200 Subject: [PATCH 275/283] Fixes #1522, add render-dependencies mojo (#1523) --- pom.xml | 14 +- .../RenderDependenciesMojo.java | 278 ++++++++++++++++++ .../apt/examples/render-dependencies.apt.vm | 77 +++++ src/site/apt/index.apt.vm | 5 + src/site/site.xml | 1 + .../TestRenderDependenciesMojo.java | 153 ++++++++++ .../plugin-config.xml | 37 +++ 7 files changed, 564 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/apache/maven/plugins/dependency/fromDependencies/RenderDependenciesMojo.java create mode 100644 src/site/apt/examples/render-dependencies.apt.vm create mode 100644 src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestRenderDependenciesMojo.java create mode 100644 src/test/resources/unit/render-dependencies-test/plugin-config.xml diff --git a/pom.xml b/pom.xml index 7a8def860..88e651829 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.8.2-SNAPSHOT + 3.9.0-SNAPSHOT maven-plugin Apache Maven Dependency Plugin @@ -277,6 +277,18 @@ under the License. ${slf4jVersion} + + + org.apache.velocity + velocity-engine-core + 2.4.1 + + + org.apache.velocity.tools + velocity-tools-generic + 3.1 + + org.apache.maven.resolver diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/RenderDependenciesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/RenderDependenciesMojo.java new file mode 100644 index 000000000..6a4291480 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/RenderDependenciesMojo.java @@ -0,0 +1,278 @@ +/* + * 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.dependency.fromDependencies; + +import javax.inject.Inject; + +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.tools.generic.CollectionTool; +import org.sonatype.plexus.build.incremental.BuildContext; + +import static java.util.Optional.ofNullable; + +/** + * This goal renders dependencies based on a velocity template. + * + * @since 3.9.0 + */ +@Mojo( + name = "render-dependencies", + requiresDependencyResolution = ResolutionScope.TEST, + defaultPhase = LifecyclePhase.GENERATE_SOURCES, + threadSafe = true) +public class RenderDependenciesMojo extends AbstractDependencyFilterMojo { + /** + * Encoding to write the rendered template. + * @since 3.9.0 + */ + @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") + private String outputEncoding; + + /** + * The file to write the rendered template string. If undefined, it just prints the classpath as [INFO]. + * @since 3.9.0 + */ + @Parameter(property = "mdep.outputFile") + private File outputFile; + + /** + * If not null or empty it will attach the artifact with this classifier. + * @since 3.9.0 + */ + @Parameter(property = "mdep.classifier", defaultValue = "template") + private String classifier; + + /** + * Extension to use for the attached file if classifier is not null/empty. + * @since 3.9.0 + */ + @Parameter(property = "mdep.extension", defaultValue = "txt") + private String extension; + + /** + * Velocity template to use to render the output file. + * It can be inline or a file path. + * @since 3.9.0 + */ + @Parameter(property = "mdep.template", required = true) + private String template; + + private final MavenProjectHelper projectHelper; + + @Inject + protected RenderDependenciesMojo( + MavenSession session, + BuildContext buildContext, + MavenProject project, + ResolverUtil resolverUtil, + ProjectBuilder projectBuilder, + ArtifactHandlerManager artifactHandlerManager, + MavenProjectHelper projectHelper) { + super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); + this.projectHelper = projectHelper; + } + + /** + * Main entry into mojo. + * + * @throws MojoExecutionException with a message if an error occurs + */ + @Override + protected void doExecute() throws MojoExecutionException { + // sort them to ease template work and ensure it is deterministic + final List artifacts = + ofNullable(getResolvedDependencies(true)).orElseGet(Collections::emptySet).stream() + .sorted(Comparator.comparing(Artifact::getGroupId) + .thenComparing(Artifact::getArtifactId) + .thenComparing(Artifact::getBaseVersion) + .thenComparing(orEmpty(Artifact::getClassifier)) + .thenComparing(orEmpty(Artifact::getType))) + .collect(Collectors.toList()); + + if (artifacts.isEmpty()) { + getLog().warn("No dependencies found."); + } + + final String rendered = render(artifacts); + + if (outputFile == null) { + getLog().info(rendered); + } else { + store(rendered, outputFile); + } + if (classifier != null && !classifier.isEmpty()) { + attachFile(rendered); + } + } + + /** + * Do render the template. + * @param artifacts input. + * @return the template rendered. + */ + private String render(final List artifacts) { + final Path templatePath = getTemplatePath(); + final boolean fromFile = templatePath != null && Files.exists(templatePath); + + final Properties props = new Properties(); + props.setProperty("runtime.strict_mode.enable", "true"); + if (fromFile) { + props.setProperty( + "resource.loader.file.path", + templatePath.toAbsolutePath().getParent().toString()); + } + + final VelocityEngine ve = new VelocityEngine(props); + ve.init(); + + final VelocityContext context = new VelocityContext(); + context.put("artifacts", artifacts); + context.put("sorter", new CollectionTool()); + + // Merge template + context + final StringWriter writer = new StringWriter(); + try (StringWriter ignored = writer) { + if (fromFile) { + final Template template = + ve.getTemplate(templatePath.getFileName().toString()); + template.merge(context, writer); + } else { + ve.evaluate(context, writer, "tpl-" + Math.abs(hashCode()), template); + } + } catch (final IOException e) { + // no-op, not possible + } + + return writer.toString(); + } + + private Path getTemplatePath() { + try { + return Paths.get(template); + } catch (final RuntimeException re) { + return null; + } + } + + /** + * Trivial null protection impl for comparing callback. + * @param getter nominal getter. + * @return a comparer of getter defaulting on empty if getter value is null. + */ + private Comparator orEmpty(final Function getter) { + return Comparator.comparing(a -> ofNullable(getter.apply(a)).orElse("")); + } + + /** + * @param content the rendered template + * @throws MojoExecutionException in case of an error + */ + protected void attachFile(final String content) throws MojoExecutionException { + final File attachedFile; + if (outputFile == null) { + attachedFile = new File(getProject().getBuild().getDirectory(), classifier); + store(content, attachedFile); + } else { // already written + attachedFile = outputFile; + } + projectHelper.attachArtifact(getProject(), extension, classifier, attachedFile); + } + + /** + * Stores the specified string into that file. + * + * @param content the string to write into the file + */ + private void store(final String content, final File out) throws MojoExecutionException { + // make sure the parent path exists. + final Path parent = out.toPath().getParent(); + if (parent != null) { + try { + Files.createDirectories(parent); + } catch (final IOException e) { + throw new MojoExecutionException(e); + } + } + + final String encoding = Objects.toString(outputEncoding, StandardCharsets.UTF_8.name()); + try (Writer w = Files.newBufferedWriter(out.toPath(), Charset.forName(encoding))) { + w.write(content); + getLog().info("Wrote file '" + out + "'."); + } catch (final IOException ex) { + throw new MojoExecutionException("Error while writing to file '" + out, ex); + } + } + + @Override + protected ArtifactsFilter getMarkedArtifactFilter() { + return null; + } + + public void setExtension(final String extension) { + this.extension = extension; + } + + public void setOutputEncoding(final String outputEncoding) { + this.outputEncoding = outputEncoding; + } + + public void setOutputFile(final File outputFile) { + this.outputFile = outputFile; + } + + public void setClassifier(final String classifier) { + this.classifier = classifier; + } + + public void setTemplate(final String template) { + this.template = template; + } +} diff --git a/src/site/apt/examples/render-dependencies.apt.vm b/src/site/apt/examples/render-dependencies.apt.vm new file mode 100644 index 000000000..9e2aaae62 --- /dev/null +++ b/src/site/apt/examples/render-dependencies.apt.vm @@ -0,0 +1,77 @@ +~~ 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. + + ------ + Render a Velocity template + ------ + Allan Ramirez + Brian Fox + Stephen Connolly + ------ + 2025-09-17 + ------ + +Render a Velocity template + + You can use <<>> mojo to a render a velocity template, + with the <> (dependencies) as context: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy + process-resources + + render-dependencies + + + + + + + + + + [...] + ++---+ + + Then after executing <<>>, the template will be rendered. + By default it is printed in the console but you can set <> to store it somewhere. + + The resolution uses exactly the same mechanism than for <> mojo. diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 468888d24..b44c07f56 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -106,6 +106,9 @@ ${project.name} *{{{./unpack-dependencies-mojo.html}dependency:unpack-dependencies}} like copy-dependencies but unpacks. + *{{{./render-dependencies-mojo.html}dependency:render-dependencies}} like + build-classpath but with a custom Velocity template. + [] * Usage @@ -152,6 +155,8 @@ ${project.name} * {{{./examples/tree-mojo.html}Tree Mojo}} + * {{{./examples/render-dependencies.html}Render Dependencies}} + [] * Resources diff --git a/src/site/site.xml b/src/site/site.xml index fe973276c..969c6875a 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -43,6 +43,7 @@ under the License. +

      diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestRenderDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestRenderDependenciesMojo.java new file mode 100644 index 000000000..c42da77d8 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestRenderDependenciesMojo.java @@ -0,0 +1,153 @@ +/* + * 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.dependency.fromDependencies; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TestRenderDependenciesMojo extends AbstractDependencyMojoTestCase { + private RenderDependenciesMojo mojo; + + @Override + protected String getTestDirectoryName() { + return "render-dependencies"; + } + + @Override + protected boolean shouldCreateFiles() { + return true; + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + final MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + final MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + + final File testPom = new File( + getBasedir(), "target/test-classes/unit/" + getTestDirectoryName() + "-test/plugin-config.xml"); + mojo = (RenderDependenciesMojo) lookupMojo(getTestDirectoryName(), testPom); + } + + /** + * Tests the rendering. + * Note that this is a real life example of using the mojo to generate a CRD for a SparkApplication. + * It is useful when combined with JIB for example since several versions of the CRD do not support wildcard for + * the classpath(s). + */ + public void testRender() throws Exception { + final File rendered = new File(testDir, "render-dependencies.testRender.txt"); + + setupProject(); + + mojo.setTemplate("deps:\n" + + " jars:\n" + + "#foreach($dep in $sorter.sort($artifacts, [\"artifactId:asc\"]))\n" + + "#set($type = $dep.type)\n" + + "#if(!$type || $type.trim().isEmpty())\n" + + " #set($type = \"jar\")\n" + + "#end\n" + + "#set($classifierSuffix = \"\")\n" + + "#if($dep.classifier && !$dep.classifier.trim().isEmpty())\n" + + " #set($classifierSuffix = \"-$dep.classifier\")\n" + + "#end\n" + + " - local:///opt/test/libs/$dep.artifactId-$dep.baseVersion$classifierSuffix.$type\n" + + "#end"); + mojo.setOutputFile(rendered); + mojo.execute(); + + assertThat(rendered) + .content() + .isEqualTo("deps:\n" + + " jars:\n" + + " - local:///opt/test/libs/compile-1.0.jar\n" + + " - local:///opt/test/libs/provided-1.0.jar\n" + + " - local:///opt/test/libs/release-1.0.jar\n" + + " - local:///opt/test/libs/runtime-1.0.jar\n" + + " - local:///opt/test/libs/snapshot-2.0-SNAPSHOT.jar\n" + + " - local:///opt/test/libs/system-1.0.jar\n" + + " - local:///opt/test/libs/test-1.0.jar\n"); + } + + /** + * Tests the rendering with a file template. + */ + public void testRenderFromFile() throws Exception { + final File rendered = new File(testDir, "render-dependencies.testRenderFromFile.txt"); + final File template = new File(testDir, "render-dependencies.testRenderFromFile.template.vm"); + Files.write( + template.toPath(), + ("deps:\n" + + " jars:\n" + + "#foreach($dep in $sorter.sort($artifacts, [\"artifactId:asc\"]))\n" + + "#set($type = $dep.type)\n" + + "#if(!$type || $type.trim().isEmpty())\n" + + " #set($type = \"jar\")\n" + + "#end\n" + + "#set($classifierSuffix = \"\")\n" + + "#if($dep.classifier && !$dep.classifier.trim().isEmpty())\n" + + " #set($classifierSuffix = \"-$dep.classifier\")\n" + + "#end\n" + + " - local:///opt/test/libs/$dep.artifactId-$dep.baseVersion$classifierSuffix.$type\n" + + "#end") + .getBytes(StandardCharsets.UTF_8)); + + setupProject(); + + mojo.setTemplate(template.getAbsolutePath()); + mojo.setOutputFile(rendered); + mojo.execute(); + + assertThat(rendered) + .content() + .isEqualTo("deps:\n" + + " jars:\n" + + " - local:///opt/test/libs/compile-1.0.jar\n" + + " - local:///opt/test/libs/provided-1.0.jar\n" + + " - local:///opt/test/libs/release-1.0.jar\n" + + " - local:///opt/test/libs/runtime-1.0.jar\n" + + " - local:///opt/test/libs/snapshot-2.0-SNAPSHOT.jar\n" + + " - local:///opt/test/libs/system-1.0.jar\n" + + " - local:///opt/test/libs/test-1.0.jar\n"); + } + + private void setupProject() throws IOException { + final MavenProject project = mojo.getProject(); + final Set artifacts = stubFactory.getScopedArtifacts(); + final Set directArtifacts = stubFactory.getReleaseAndSnapshotArtifacts(); + artifacts.addAll(directArtifacts); + project.setArtifacts(artifacts); + project.setDependencyArtifacts(directArtifacts); + } +} diff --git a/src/test/resources/unit/render-dependencies-test/plugin-config.xml b/src/test/resources/unit/render-dependencies-test/plugin-config.xml new file mode 100644 index 000000000..1a046caeb --- /dev/null +++ b/src/test/resources/unit/render-dependencies-test/plugin-config.xml @@ -0,0 +1,37 @@ + + + + + + maven-dependency-plugin + + + + + + + + org.apache.maven + maven-artifact + 2.0.4 + + + \ No newline at end of file From 752394802bb182db81dc9348540cbae850a0d571 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 17 Sep 2025 22:49:45 +0200 Subject: [PATCH 276/283] Strict check of dependencies usage --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 88e651829..d43ce7031 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,9 @@ under the License. 4.11.0 4.10.1 3.3.0 + + + true 2024-10-18T18:16:14Z From dcd4b7d18a10906c56ad2e4f5a602479d68aa7dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 22:01:05 +0000 Subject: [PATCH 277/283] Bump org.assertj:assertj-core from 3.27.4 to 3.27.5 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.4 to 3.27.5. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.4...assertj-build-3.27.5) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.5 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d43ce7031..6cfdc742e 100644 --- a/pom.xml +++ b/pom.xml @@ -367,7 +367,7 @@ under the License. org.assertj assertj-core - 3.27.4 + 3.27.5 test From d2af78edcf2f8b59fcb6df0f8b02c54a4963d47c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 22 Sep 2025 21:56:29 +0200 Subject: [PATCH 278/283] Ignore Mockito 5.x and SLF4j 2.x by dependabot --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7b7230f1f..afa7b1323 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,6 +24,13 @@ updates: # Jetty >=10 requires Java 11+ - dependency-name: "org.eclipse.jetty:*" versions: [">= 10.0"] + # Mockito >=5 requires Java 11+ + - dependency-name: "org.mockito:*" + versions: [">= 5.0.0"] + # Maven 3 so use SLF4J 1.7.x + - dependency-name: "org.slf4j:*" + versions: [">= 2.0.0"] + - package-ecosystem: "github-actions" directory: "/" schedule: From 8776c61b557b162a364d5d7eef7b2c75069787f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 22:01:34 +0000 Subject: [PATCH 279/283] Bump org.assertj:assertj-core from 3.27.5 to 3.27.6 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.27.5 to 3.27.6. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.27.5...assertj-build-3.27.6) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-version: 3.27.6 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6cfdc742e..b81bb0e93 100644 --- a/pom.xml +++ b/pom.xml @@ -367,7 +367,7 @@ under the License. org.assertj assertj-core - 3.27.5 + 3.27.6 test From 6ed4b1abf463556391e957b1c3201662276ef0b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Sep 2025 22:02:10 +0000 Subject: [PATCH 280/283] Bump org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0 Bumps org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-version: 3.19.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b81bb0e93..7520bd07c 100644 --- a/pom.xml +++ b/pom.xml @@ -177,7 +177,7 @@ under the License. org.apache.commons commons-lang3 - 3.18.0 + 3.19.0 commons-io From e50031a17b4349ddd80c41371fe43f2f2ce8ecfd Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 25 Sep 2025 20:24:53 +0200 Subject: [PATCH 281/283] Use Resolver API in go-offline for plugins resolving - use the same method for generating plugin list as in resolve-plugin - move parameter where is used - move some method where is used - cleanups --- .../dependency/AbstractDependencyMojo.java | 39 ---- .../resolvers/AbstractResolveMojo.java | 48 ----- .../dependency/resolvers/GoOfflineMojo.java | 173 +++++++++++++----- .../resolvers/ResolvePluginsMojo.java | 56 +----- .../dependency/utils/ResolverUtil.java | 61 ++++++ .../AbstractDependencyMojoTest.java | 71 ------- 6 files changed, 195 insertions(+), 253 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 5045f607c..47296eb74 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -20,7 +20,6 @@ import java.util.List; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -28,9 +27,7 @@ import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.utils.DependencySilentLog; -import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -38,18 +35,6 @@ */ public abstract class AbstractDependencyMojo extends AbstractMojo { - /** - * Remote repositories which will be searched for artifacts. - */ - @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) - private List remoteRepositories; - - /** - * Remote repositories which will be searched for plugins. - */ - @Parameter(defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true) - private List remotePluginRepositories; - /** * Contains the full list of projects in the reactor. */ @@ -125,30 +110,6 @@ public final void execute() throws MojoExecutionException, MojoFailureException */ protected abstract void doExecute() throws MojoExecutionException, MojoFailureException; - /** - * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote - * repositories, used to resolve artifacts - */ - public ProjectBuildingRequest newResolveArtifactProjectBuildingRequest() { - return newProjectBuildingRequest(remoteRepositories); - } - - /** - * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote - * repositories, used to resolve plugins - */ - protected ProjectBuildingRequest newResolvePluginProjectBuildingRequest() { - return newProjectBuildingRequest(remotePluginRepositories); - } - - private ProjectBuildingRequest newProjectBuildingRequest(List repositories) { - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - - buildingRequest.setRemoteRepositories(repositories); - - return buildingRequest; - } - /** * @return returns the project */ diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java index 6abcb140e..222af532e 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/AbstractResolveMojo.java @@ -24,16 +24,9 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; -import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; -import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; -import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; -import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; -import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -58,14 +51,6 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { @Parameter(property = "appendOutput", defaultValue = "false") protected boolean appendOutput; - /** - * Don't resolve plugins that are in the current reactor. - * - * @since 2.7 - */ - @Parameter(property = "excludeReactor", defaultValue = "true") - protected boolean excludeReactor; - protected AbstractResolveMojo( MavenSession session, BuildContext buildContext, @@ -75,37 +60,4 @@ protected AbstractResolveMojo( ArtifactHandlerManager artifactHandlerManager) { super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); } - - /** - * @return {@link FilterArtifacts} - */ - protected FilterArtifacts getArtifactsFilter() { - final FilterArtifacts filter = new FilterArtifacts(); - - if (excludeReactor) { - filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); - } - - filter.addFilter(new ScopeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeScope), - DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); - - filter.addFilter(new TypeFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeTypes), - DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); - - filter.addFilter(new ClassifierFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), - DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); - - filter.addFilter(new GroupIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); - - filter.addFilter(new ArtifactIdFilter( - DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), - DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); - - return filter; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index d6adeefb5..9f8c4ea84 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -20,12 +20,15 @@ import javax.inject.Inject; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; @@ -33,22 +36,33 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; +import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; +import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; +import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; +import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.DependencyResolutionException; import org.sonatype.plexus.build.incremental.BuildContext; /** @@ -60,7 +74,21 @@ * @since 2.0 */ @Mojo(name = "go-offline", threadSafe = true) -public class GoOfflineMojo extends AbstractResolveMojo { +public class GoOfflineMojo extends AbstractDependencyFilterMojo { + + /** + * Remote repositories which will be searched for artifacts. + */ + @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) + private List remoteRepositories; + + /** + * Don't resolve plugins and artifacts that are in the current reactor. + * + * @since 2.7 + */ + @Parameter(property = "excludeReactor", defaultValue = "true") + protected boolean excludeReactor; private final DependencyResolver dependencyResolver; @@ -89,25 +117,47 @@ public GoOfflineMojo( protected void doExecute() throws MojoExecutionException { try { - final Set plugins = resolvePluginArtifacts(); + final Set plugins = getProjectPlugins(); + + for (Plugin plugin : plugins) { + org.eclipse.aether.artifact.Artifact artifact = + getResolverUtil().resolvePlugin(plugin); + + logMessage("Resolved plugin: " + + DependencyUtil.getFormattedFileName(RepositoryUtils.toArtifact(artifact), false)); + if (!excludeTransitive) { + logMessage("Resolved plugin dependency:"); + List artifacts = + getResolverUtil().resolveDependencies(plugin); + for (org.eclipse.aether.artifact.Artifact a : artifacts) { + logMessage( + " " + DependencyUtil.getFormattedFileName(RepositoryUtils.toArtifact(a), false)); + } + } + } final Set dependencies = resolveDependencyArtifacts(); - if (!isSilent()) { - for (Artifact artifact : plugins) { - this.getLog().info("Resolved plugin: " + DependencyUtil.getFormattedFileName(artifact, false)); - } - - for (Artifact artifact : dependencies) { - this.getLog().info("Resolved dependency: " + DependencyUtil.getFormattedFileName(artifact, false)); - } + for (Artifact artifact : dependencies) { + logMessage("Resolved dependency: " + DependencyUtil.getFormattedFileName(artifact, false)); } - } catch (DependencyResolverException | ArtifactFilterException e) { + } catch (DependencyResolverException + | ArtifactFilterException + | ArtifactResolutionException + | DependencyResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } + private void logMessage(String message) { + if (isSilent()) { + getLog().debug(message); + } else { + getLog().info(message); + } + } + /** * This method resolves the dependency artifacts from the project. * @@ -164,31 +214,30 @@ private TransformableFilter getTransformableFilter() { } /** - * This method resolves the plugin artifacts from the project. + * This method retrieve plugins list from the project. * - * @return set of resolved plugin artifacts - * @throws ArtifactFilterException - * @throws DependencyResolverException in case of an error while resolving the artifacts + * @return set of plugin used in project */ - protected Set resolvePluginArtifacts() throws DependencyResolverException, ArtifactFilterException { - - Set plugins = getProject().getPluginArtifacts(); - Set reports = getProject().getReportArtifacts(); - - Set artifacts = new LinkedHashSet<>(); - artifacts.addAll(reports); - artifacts.addAll(plugins); - - final FilterArtifacts filter = getArtifactsFilter(); - artifacts = filter.filter(artifacts); + private Set getProjectPlugins() { + Predicate pluginsFilter = new PluginsIncludeExcludeFilter( + toList(includeGroupIds), + toList(excludeGroupIds), + toList(includeArtifactIds), + toList(excludeArtifactIds)); + + Predicate reactorExclusionFilter = plugin -> true; + if (excludeReactor) { + reactorExclusionFilter = new PluginsReactorExcludeFilter(session.getProjects()); + } - Set dependableCoordinates = artifacts.stream() - .map(this::createDependendableCoordinateFromArtifact) + return getResolverUtil().getProjectPlugins(getProject()).stream() + .filter(reactorExclusionFilter) + .filter(pluginsFilter) .collect(Collectors.toSet()); + } - ProjectBuildingRequest buildingRequest = newResolvePluginProjectBuildingRequest(); - - return resolveDependableCoordinate(buildingRequest, dependableCoordinates, "plugins"); + private List toList(String list) { + return Arrays.asList(DependencyUtil.cleanToBeTokenizedString(list).split(",")); } private Collection filterDependencies(Collection deps) throws ArtifactFilterException { @@ -201,17 +250,6 @@ private Collection filterDependencies(Collection deps) t return createDependencySetFromArtifacts(artifacts); } - private DependableCoordinate createDependendableCoordinateFromArtifact(final Artifact artifact) { - final DefaultDependableCoordinate result = new DefaultDependableCoordinate(); - result.setGroupId(artifact.getGroupId()); - result.setArtifactId(artifact.getArtifactId()); - result.setVersion(artifact.getVersion()); - result.setType(artifact.getType()); - result.setClassifier(artifact.getClassifier()); - - return result; - } - private DependableCoordinate createDependendableCoordinateFromDependency(final Dependency dependency) { final DefaultDependableCoordinate result = new DefaultDependableCoordinate(); result.setGroupId(dependency.getGroupId()); @@ -256,6 +294,55 @@ private Collection createDependencySetFromArtifacts(Set ar return dependencies; } + /** + * @return {@link FilterArtifacts} + */ + protected FilterArtifacts getArtifactsFilter() { + final FilterArtifacts filter = new FilterArtifacts(); + + if (excludeReactor) { + filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog())); + } + + filter.addFilter(new ScopeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeScope), + DependencyUtil.cleanToBeTokenizedString(this.excludeScope))); + + filter.addFilter(new TypeFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeTypes), + DependencyUtil.cleanToBeTokenizedString(this.excludeTypes))); + + filter.addFilter(new ClassifierFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), + DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers))); + + filter.addFilter(new GroupIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds))); + + filter.addFilter(new ArtifactIdFilter( + DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), + DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds))); + + return filter; + } + + /** + * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote + * repositories, used to resolve artifacts + */ + public ProjectBuildingRequest newResolveArtifactProjectBuildingRequest() { + return newProjectBuildingRequest(remoteRepositories); + } + + private ProjectBuildingRequest newProjectBuildingRequest(List repositories) { + ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + + buildingRequest.setRemoteRepositories(repositories); + + return buildingRequest; + } + @Override protected ArtifactsFilter getMarkedArtifactFilter() { return null; diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java index 116fef919..2840ae615 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolvePluginsMojo.java @@ -22,8 +22,6 @@ import java.io.File; import java.io.IOException; -import java.util.Collections; -import java.util.LinkedHashSet; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -32,11 +30,7 @@ import java.util.stream.Collectors; import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.ModelBase; import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginContainer; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.Reporting; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -235,51 +229,9 @@ private Set getProjectPlugins() { reactorExclusionFilter = new PluginsReactorExcludeFilter(session.getProjects()); } - List reportPlugins = Optional.ofNullable(getProject().getModel()) - .map(ModelBase::getReporting) - .map(Reporting::getPlugins) - .orElse(Collections.emptyList()) - .stream() - .map(this::toPlugin) - .collect(Collectors.toList()); - - List projectPlugins = getProject().getBuild().getPlugins(); - - return new LinkedHashSet(reportPlugins.size() + projectPlugins.size()) { - { - addAll(reportPlugins); - addAll(projectPlugins); - } - }.stream().filter(reactorExclusionFilter).filter(pluginsFilter).collect(Collectors.toSet()); - } - - private Plugin toPlugin(ReportPlugin reportPlugin) { - // first look in the pluginManagement section - Plugin plugin = Optional.ofNullable(getProject().getBuild().getPluginManagement()) - .map(PluginContainer::getPluginsAsMap) - .orElseGet(Collections::emptyMap) - .get(reportPlugin.getKey()); - - if (plugin == null) { - plugin = getProject().getBuild().getPluginsAsMap().get(reportPlugin.getKey()); - } - - if (plugin == null) { - plugin = new Plugin(); - plugin.setGroupId(reportPlugin.getGroupId()); - plugin.setArtifactId(reportPlugin.getArtifactId()); - plugin.setVersion(reportPlugin.getVersion()); - } else { - // override the version with the one from the report plugin if specified - if (reportPlugin.getVersion() != null) { - plugin.setVersion(reportPlugin.getVersion()); - } - } - - if (plugin.getVersion() == null) { - plugin.setVersion("RELEASE"); - } - - return plugin; + return resolverUtil.getProjectPlugins(getProject()).stream() + .filter(reactorExclusionFilter) + .filter(pluginsFilter) + .collect(Collectors.toSet()); } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java index ad5b356d3..43fc7e5a2 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -25,13 +25,21 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.ModelBase; import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginContainer; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.Reporting; +import org.apache.maven.project.MavenProject; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -298,4 +306,57 @@ private ArtifactType getArtifactType(String packaging) { mavenSessionProvider.get().getRepositorySession().getArtifactTypeRegistry(); return artifactTypeRegistry.get(packaging != null ? packaging : "jar"); } + + /** + * Retrieve all plugins used in project either in build or reporting section. + * + * @param project a maven project + * @return a collection of plugins + */ + public Collection getProjectPlugins(MavenProject project) { + List reportPlugins = Optional.ofNullable(project.getModel()) + .map(ModelBase::getReporting) + .map(Reporting::getPlugins) + .orElse(Collections.emptyList()) + .stream() + .map(p -> toPlugin(p, project)) + .collect(Collectors.toList()); + + List projectPlugins = project.getBuild().getPlugins(); + + LinkedHashSet result = new LinkedHashSet<>(reportPlugins.size() + projectPlugins.size()); + result.addAll(reportPlugins); + result.addAll(projectPlugins); + return result; + } + + private Plugin toPlugin(ReportPlugin reportPlugin, MavenProject project) { + // first look in the pluginManagement section + Plugin plugin = Optional.ofNullable(project.getBuild().getPluginManagement()) + .map(PluginContainer::getPluginsAsMap) + .orElseGet(Collections::emptyMap) + .get(reportPlugin.getKey()); + + if (plugin == null) { + plugin = project.getBuild().getPluginsAsMap().get(reportPlugin.getKey()); + } + + if (plugin == null) { + plugin = new Plugin(); + plugin.setGroupId(reportPlugin.getGroupId()); + plugin.setArtifactId(reportPlugin.getArtifactId()); + plugin.setVersion(reportPlugin.getVersion()); + } else { + // override the version with the one from the report plugin if specified + if (reportPlugin.getVersion() != null) { + plugin.setVersion(reportPlugin.getVersion()); + } + } + + if (plugin.getVersion() == null) { + plugin.setVersion("RELEASE"); + } + + return plugin; + } } diff --git a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java index bb8f728da..6d45e86e1 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java @@ -18,9 +18,7 @@ */ package org.apache.maven.plugins.dependency; -import java.lang.reflect.Field; import java.util.ArrayList; -import java.util.List; import junit.framework.TestCase; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -29,8 +27,6 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.sonatype.plexus.build.incremental.BuildContext; -import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithArtifactRepositories; -import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithPluginRepositories; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -49,30 +45,6 @@ protected ConcreteDependencyMojo(MavenSession session, BuildContext buildContext super(session, buildContext, project); } - static ConcreteDependencyMojo createConcreteDependencyMojoWithArtifactRepositories( - MavenSession mavenSession, List artifactRepos) - throws NoSuchFieldException, IllegalAccessException { - ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(mavenSession, null, null); - - Field par = AbstractDependencyMojo.class.getDeclaredField("remoteRepositories"); - par.setAccessible(true); - par.set(cdm, artifactRepos); - - return cdm; - } - - static ConcreteDependencyMojo createConcreteDependencyMojoWithPluginRepositories( - MavenSession session, List pluginRepos) - throws NoSuchFieldException, IllegalAccessException { - ConcreteDependencyMojo cdm = new ConcreteDependencyMojo(session, null, null); - - Field par = AbstractDependencyMojo.class.getDeclaredField("remotePluginRepositories"); - par.setAccessible(true); - par.set(cdm, pluginRepos); - - return cdm; - } - @Override protected void doExecute() {} } @@ -95,47 +67,4 @@ private static ArtifactRepository newRepositoryWithId(String id) { when(repo.getId()).thenReturn(id); return repo; } - - public void testNewResolveArtifactProjectBuildingRequestRemoteRepositoriesSize() - throws NoSuchFieldException, IllegalAccessException { - AbstractDependencyMojo mojo = createConcreteDependencyMojoWithArtifactRepositories(session, artifactRepos); - - ProjectBuildingRequest pbr = mojo.newResolveArtifactProjectBuildingRequest(); - List rrepos = pbr.getRemoteRepositories(); - - assertEquals(3, rrepos.size()); - } - - public void testNewResolveArtifactProjectBuildingRequestRemoteRepositoriesContents() - throws NoSuchFieldException, IllegalAccessException { - AbstractDependencyMojo mojo = createConcreteDependencyMojoWithArtifactRepositories(session, artifactRepos); - - ProjectBuildingRequest pbr = mojo.newResolveArtifactProjectBuildingRequest(); - List rrepos = pbr.getRemoteRepositories(); - - assertEquals("ar-central", rrepos.get(0).getId()); - assertEquals("ar-snapshots", rrepos.get(1).getId()); - assertEquals("ar-staging", rrepos.get(2).getId()); - } - - public void testNewResolvePluginProjectBuildingRequestRemoteRepositoriesSize() - throws NoSuchFieldException, IllegalAccessException { - AbstractDependencyMojo mojo = createConcreteDependencyMojoWithPluginRepositories(session, pluginRepos); - - ProjectBuildingRequest pbr = mojo.newResolvePluginProjectBuildingRequest(); - List rrepos = pbr.getRemoteRepositories(); - - assertEquals(2, rrepos.size()); - } - - public void testNewResolvePluginProjectBuildingRequestRemoteRepositoriesContents() - throws NoSuchFieldException, IllegalAccessException { - AbstractDependencyMojo mojo = createConcreteDependencyMojoWithPluginRepositories(session, pluginRepos); - - ProjectBuildingRequest pbr = mojo.newResolvePluginProjectBuildingRequest(); - List rrepos = pbr.getRemoteRepositories(); - - assertEquals("pr-central", rrepos.get(0).getId()); - assertEquals("pr-plugins", rrepos.get(1).getId()); - } } From 0db1acc3929ab2b91998d3910078d6f494af8f8b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 29 Sep 2025 00:11:32 +0200 Subject: [PATCH 282/283] Use Resolver API in go-offline for dependencies resolving (#1533) * Use Resolver API in go-offline for dependencies resolving - add assertions in IT test - filters should be rewritten to Resolver API * invoker 3.9.1 --- pom.xml | 3 + src/it/projects/go-offline/pom.xml | 16 +- src/it/projects/go-offline/test.properties | 18 --- src/it/projects/go-offline/verify.groovy | 34 +++++ ...xcludeReactorProjectsDependencyFilter.java | 44 ++---- .../dependency/resolvers/GoOfflineMojo.java | 140 ++++++------------ .../dependency/utils/ResolverUtil.java | 29 ++++ ...deReactorProjectsDependencyFilterTest.java | 79 ++-------- 8 files changed, 149 insertions(+), 214 deletions(-) delete mode 100644 src/it/projects/go-offline/test.properties create mode 100644 src/it/projects/go-offline/verify.groovy diff --git a/pom.xml b/pom.xml index 7520bd07c..f7e8e98a2 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,9 @@ under the License. 4.10.1 3.3.0 + + 3.9.1 + true 2024-10-18T18:16:14Z diff --git a/src/it/projects/go-offline/pom.xml b/src/it/projects/go-offline/pom.xml index fc59fc1e6..b185dc590 100644 --- a/src/it/projects/go-offline/pom.xml +++ b/src/it/projects/go-offline/pom.xml @@ -36,12 +36,24 @@ UTF-8 + org.apache.maven - maven-project - 2.0.6 + maven-core + 3.9.11 + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.5.0 + + + + diff --git a/src/it/projects/go-offline/test.properties b/src/it/projects/go-offline/test.properties deleted file mode 100644 index 2a312e22e..000000000 --- a/src/it/projects/go-offline/test.properties +++ /dev/null @@ -1,18 +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. - -outputFile = target/tree.txt diff --git a/src/it/projects/go-offline/verify.groovy b/src/it/projects/go-offline/verify.groovy new file mode 100644 index 000000000..550cc2caf --- /dev/null +++ b/src/it/projects/go-offline/verify.groovy @@ -0,0 +1,34 @@ +/* + * 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. + */ + +File file = new File(basedir, 'build.log') +assert file.exists() + +String buildLog = file.getText("UTF-8") + +assert buildLog.contains('[INFO] Resolved plugin: maven-clean-plugin-3.5.0.jar') +assert buildLog.contains('[INFO] Resolved plugin dependency:') +assert buildLog.contains('[INFO] maven-clean-plugin-3.5.0.jar') +assert buildLog.contains('[INFO] plexus-utils-4.0.2.jar') + +assert buildLog.contains('[INFO] Resolved dependency: maven-core-3.9.11.jar') +assert buildLog.contains('[INFO] Resolved dependency: maven-model-3.9.11.jar') +assert buildLog.contains('[INFO] Resolved dependency: maven-settings-3.9.11.jar') + + diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java index b796f761c..ef82569fa 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilter.java @@ -20,57 +20,39 @@ import java.util.List; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Dependency; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter; -import org.apache.maven.shared.artifact.filter.resolve.Node; -import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * {@link TransformableFilter} implementation that excludes artifacts found in the Reactor. + * Filter implementation that excludes artifacts found in the Reactor. * * @author Maarten Mulders */ -public class ExcludeReactorProjectsDependencyFilter extends AbstractFilter { - private final Log log; +public class ExcludeReactorProjectsDependencyFilter implements Predicate { + private final Logger log = LoggerFactory.getLogger(ExcludeReactorProjectsDependencyFilter.class); private final Set reactorArtifactKeys; - public ExcludeReactorProjectsDependencyFilter(final List reactorProjects, final Log log) { - this.log = log; + public ExcludeReactorProjectsDependencyFilter(final List reactorProjects) { this.reactorArtifactKeys = reactorProjects.stream() .map(project -> ArtifactUtils.key(project.getArtifact())) .collect(Collectors.toSet()); } @Override - public boolean accept(final Node node, final List parents) { - final Dependency dependency = node.getDependency(); - if (dependency != null) { - final String dependencyArtifactKey = - ArtifactUtils.key(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); - - final boolean result = isDependencyArtifactInReactor(dependencyArtifactKey); - - if (log.isDebugEnabled() && result) { - log.debug("Skipped dependency " + dependencyArtifactKey + " because it is present in the reactor"); + public boolean test(Dependency dependency) { + String key = ArtifactUtils.key(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); + if (reactorArtifactKeys.contains(key)) { + if (log.isDebugEnabled()) { + log.debug("Skipped dependency {} because it is present in the reactor", key); } - - return !result; + return false; } return true; } - - private boolean isDependencyArtifactInReactor(final String dependencyArtifactKey) { - for (final String reactorArtifactKey : this.reactorArtifactKeys) { - // This check only includes GAV. Should we take a look at the types, too? - if (reactorArtifactKey.equals(dependencyArtifactKey)) { - return true; - } - } - return false; - } } diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java index 9f8c4ea84..e86d0f832 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/GoOfflineMojo.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -33,9 +34,9 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -43,10 +44,8 @@ import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.ResolverUtil; -import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; @@ -55,16 +54,13 @@ import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; -import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; -import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.DependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.DependencyResolutionException; import org.sonatype.plexus.build.incremental.BuildContext; +import static java.util.Optional.ofNullable; + /** * Goal that resolves all project dependencies, including plugins and reports and their dependencies. * @@ -76,12 +72,6 @@ @Mojo(name = "go-offline", threadSafe = true) public class GoOfflineMojo extends AbstractDependencyFilterMojo { - /** - * Remote repositories which will be searched for artifacts. - */ - @Parameter(defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true) - private List remoteRepositories; - /** * Don't resolve plugins and artifacts that are in the current reactor. * @@ -90,8 +80,6 @@ public class GoOfflineMojo extends AbstractDependencyFilterMojo { @Parameter(property = "excludeReactor", defaultValue = "true") protected boolean excludeReactor; - private final DependencyResolver dependencyResolver; - @Inject // CHECKSTYLE_OFF: ParameterNumber public GoOfflineMojo( @@ -99,11 +87,9 @@ public GoOfflineMojo( BuildContext buildContext, MavenProject project, ResolverUtil resolverUtil, - DependencyResolver dependencyResolver, ProjectBuilder projectBuilder, ArtifactHandlerManager artifactHandlerManager) { super(session, buildContext, project, resolverUtil, projectBuilder, artifactHandlerManager); - this.dependencyResolver = dependencyResolver; } // CHECKSTYLE_ON: ParameterNumber @@ -136,16 +122,14 @@ protected void doExecute() throws MojoExecutionException { } } - final Set dependencies = resolveDependencyArtifacts(); + final List dependencies = resolveDependencyArtifacts(); - for (Artifact artifact : dependencies) { - logMessage("Resolved dependency: " + DependencyUtil.getFormattedFileName(artifact, false)); + for (org.eclipse.aether.artifact.Artifact artifact : dependencies) { + logMessage("Resolved dependency: " + + DependencyUtil.getFormattedFileName(RepositoryUtils.toArtifact(artifact), false)); } - } catch (DependencyResolverException - | ArtifactFilterException - | ArtifactResolutionException - | DependencyResolutionException e) { + } catch (ArtifactFilterException | ArtifactResolutionException | DependencyResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } @@ -161,56 +145,43 @@ private void logMessage(String message) { /** * This method resolves the dependency artifacts from the project. * - * @return set of resolved dependency artifacts - * @throws ArtifactFilterException - * @throws DependencyResolverException in case of an error while resolving the artifacts + * @return lis of resolved dependency artifacts + * @throws ArtifactFilterException in case of an error while filtering the artifacts + * @throws DependencyResolutionException in case of an error while resolving the artifacts */ - protected Set resolveDependencyArtifacts() throws DependencyResolverException, ArtifactFilterException { + protected List resolveDependencyArtifacts() + throws ArtifactFilterException, DependencyResolutionException { Collection dependencies = getProject().getDependencies(); dependencies = filterDependencies(dependencies); - Set dependableCoordinates = dependencies.stream() - .map(this::createDependendableCoordinateFromDependency) - .collect(Collectors.toSet()); - - ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest(); - - return resolveDependableCoordinate(buildingRequest, dependableCoordinates, "dependencies"); - } - - private Set resolveDependableCoordinate( - final ProjectBuildingRequest buildingRequest, - final Collection dependableCoordinates, - final String type) - throws DependencyResolverException { - final TransformableFilter filter = getTransformableFilter(); - - this.getLog().debug("Resolving '" + type + "' with following repositories:"); - for (ArtifactRepository repo : buildingRequest.getRemoteRepositories()) { - getLog().debug(repo.getId() + " (" + repo.getUrl() + ")"); - } - - final Set results = new HashSet<>(); - - for (DependableCoordinate dependableCoordinate : dependableCoordinates) { - final Iterable artifactResults = - dependencyResolver.resolveDependencies(buildingRequest, dependableCoordinate, filter); - - for (final ArtifactResult artifactResult : artifactResults) { - results.add(artifactResult.getArtifact()); - } - } - - return results; - } - - private TransformableFilter getTransformableFilter() { + Predicate excludeReactorProjectsDependencyFilter = d -> true; if (this.excludeReactor) { - return new ExcludeReactorProjectsDependencyFilter(this.reactorProjects, getLog()); - } else { - return null; + excludeReactorProjectsDependencyFilter = new ExcludeReactorProjectsDependencyFilter(this.reactorProjects); } + + ArtifactTypeRegistry artifactTypeRegistry = + session.getRepositorySession().getArtifactTypeRegistry(); + + List dependableCoordinates = dependencies.stream() + .filter(excludeReactorProjectsDependencyFilter) + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList()); + + List managedDependencies = ofNullable( + getProject().getDependencyManagement()) + .map(DependencyManagement::getDependencies) + .map(list -> list.stream() + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList())) + .orElse(null); + + return getResolverUtil() + .resolveDependenciesForArtifact( + RepositoryUtils.toArtifact(getProject().getArtifact()), + dependableCoordinates, + managedDependencies, + getProject().getRemoteProjectRepositories()); } /** @@ -237,6 +208,9 @@ private Set getProjectPlugins() { } private List toList(String list) { + if (list == null || list.isEmpty()) { + return Collections.emptyList(); + } return Arrays.asList(DependencyUtil.cleanToBeTokenizedString(list).split(",")); } @@ -250,17 +224,6 @@ private Collection filterDependencies(Collection deps) t return createDependencySetFromArtifacts(artifacts); } - private DependableCoordinate createDependendableCoordinateFromDependency(final Dependency dependency) { - final DefaultDependableCoordinate result = new DefaultDependableCoordinate(); - result.setGroupId(dependency.getGroupId()); - result.setArtifactId(dependency.getArtifactId()); - result.setVersion(dependency.getVersion()); - result.setType(dependency.getType()); - result.setClassifier(dependency.getClassifier()); - - return result; - } - private Set createArtifactSetFromDependencies(Collection deps) { Set artifacts = new HashSet<>(); for (Dependency dep : deps) { @@ -297,6 +260,7 @@ private Collection createDependencySetFromArtifacts(Set ar /** * @return {@link FilterArtifacts} */ + // TODO: refactor this to use Resolver API filters protected FilterArtifacts getArtifactsFilter() { final FilterArtifacts filter = new FilterArtifacts(); @@ -327,22 +291,6 @@ protected FilterArtifacts getArtifactsFilter() { return filter; } - /** - * @return returns a new ProjectBuildingRequest populated from the current session and the current project remote - * repositories, used to resolve artifacts - */ - public ProjectBuildingRequest newResolveArtifactProjectBuildingRequest() { - return newProjectBuildingRequest(remoteRepositories); - } - - private ProjectBuildingRequest newProjectBuildingRequest(List repositories) { - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - - buildingRequest.setRemoteRepositories(repositories); - - return buildingRequest; - } - @Override protected ArtifactsFilter getMarkedArtifactFilter() { return null; diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java index 43fc7e5a2..3976abaa3 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java @@ -163,6 +163,35 @@ public List resolveDependencies( .collect(Collectors.toList()); } + /** + * Resolve transitive dependencies for artifact with managed dependencies. + * + * @param rootArtifact a root artifact to resolve + * @param dependencies a list of dependencies for artifact + * @param managedDependencies a list of managed dependencies for artifact + * @param remoteProjectRepositories remote repositories list + * @return Resolved dependencies + * @throws DependencyResolutionException if the dependency tree could not be built or any dependency artifact could + * not be resolved + */ + public List resolveDependenciesForArtifact( + Artifact rootArtifact, + List dependencies, + List managedDependencies, + List remoteProjectRepositories) + throws DependencyResolutionException { + MavenSession session = mavenSessionProvider.get(); + + CollectRequest collectRequest = + new CollectRequest(dependencies, managedDependencies, remoteProjectRepositories); + collectRequest.setRootArtifact(rootArtifact); + DependencyRequest request = new DependencyRequest(collectRequest, null); + DependencyResult result = repositorySystem.resolveDependencies(session.getRepositorySession(), request); + return result.getArtifactResults().stream() + .map(ArtifactResult::getArtifact) + .collect(Collectors.toList()); + } + /** * Resolve transitive dependencies for plugin. * diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java index 26034f6dd..e1460e317 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java @@ -18,22 +18,14 @@ */ package org.apache.maven.plugins.dependency.resolvers; -import java.util.Collections; - import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.stubs.ArtifactStub; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.artifact.filter.resolve.Node; -import org.mockito.ArgumentCaptor; import static java.util.Collections.singletonList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; public class ExcludeReactorProjectsDependencyFilterTest extends AbstractDependencyMojoTestCase { public void testReject() { @@ -50,56 +42,15 @@ public void testReject() { MavenProject project = new MavenProjectStub(); project.setArtifact(artifact1); - Log log = mock(Log.class); - when(log.isDebugEnabled()).thenReturn(false); - ExcludeReactorProjectsDependencyFilter filter = - new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); + new ExcludeReactorProjectsDependencyFilter(singletonList(project)); - Node node = () -> { - final Dependency result = new Dependency(); - result.setGroupId(artifact1.getGroupId()); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - }; + Dependency dependency = new Dependency(); + dependency.setGroupId(artifact1.getGroupId()); + dependency.setArtifactId(artifact1.getArtifactId()); + dependency.setVersion(artifact1.getVersion()); - assertFalse(filter.accept(node, Collections.emptyList())); - } - - public void testRejectWithLogging() { - final Artifact artifact1 = new ArtifactStub(); - artifact1.setGroupId("org.apache.maven.plugins"); - artifact1.setArtifactId("maven-dependency-plugin-dummy"); - artifact1.setVersion("1.0"); - - Artifact artifact2 = new ArtifactStub(); - artifact2.setGroupId("org.apache.maven.plugins"); - artifact2.setArtifactId("maven-dependency-plugin-other-dummy"); - artifact2.setVersion("1.0"); - - MavenProject project = new MavenProjectStub(); - project.setArtifact(artifact1); - - Log log = mock(Log.class); - when(log.isDebugEnabled()).thenReturn(true); - - ExcludeReactorProjectsDependencyFilter filter = - new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); - - Node node = () -> { - final Dependency result = new Dependency(); - result.setGroupId(artifact1.getGroupId()); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - }; - - filter.accept(node, Collections.emptyList()); - - ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - verify(log).debug(captor.capture()); - assertTrue(captor.getValue().contains("Skipped dependency")); + assertFalse(filter.test(dependency)); } public void testAccept() { @@ -116,20 +67,14 @@ public void testAccept() { MavenProject project = new MavenProjectStub(); project.setArtifact(artifact1); - Log log = mock(Log.class); - when(log.isDebugEnabled()).thenReturn(false); - ExcludeReactorProjectsDependencyFilter filter = - new ExcludeReactorProjectsDependencyFilter(singletonList(project), log); + new ExcludeReactorProjectsDependencyFilter(singletonList(project)); - Node node = () -> { - final Dependency result = new Dependency(); - result.setGroupId("something-else"); - result.setArtifactId(artifact1.getArtifactId()); - result.setVersion(artifact1.getVersion()); - return result; - }; + Dependency dependency = new Dependency(); + dependency.setGroupId("something-else"); + dependency.setArtifactId(artifact1.getArtifactId()); + dependency.setVersion(artifact1.getVersion()); - assertTrue(filter.accept(node, Collections.emptyList())); + assertTrue(filter.test(dependency)); } } From 826e5f064fb023b3b714280e9d2007dec1fae189 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 29 Sep 2025 07:54:34 +0200 Subject: [PATCH 283/283] [maven-release-plugin] prepare release maven-dependency-plugin-3.9.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index f7e8e98a2..fa13cef1f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-dependency-plugin - 3.9.0-SNAPSHOT + 3.9.0 maven-plugin Apache Maven Dependency Plugin @@ -71,7 +71,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git - HEAD + maven-dependency-plugin-3.9.0 https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag} @@ -104,7 +104,7 @@ under the License. true - 2024-10-18T18:16:14Z + 2025-09-29T05:53:29Z