From d456cbe75b0b445dc6d984452a5dc18778a69e7f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 9 Jun 2024 17:33:14 +0200 Subject: [PATCH] Don't pull in transitive artifacts With https://github.com/apache/maven-resolver/commit/f31b36ec29136c242556e13a6bb800343655d774 MavenProject#getArtifacts() now contains all (incl. transitive) deps. Use direct deps only otherwise it will even pull in trans test ones. --- .../shared/release/phase/GenerateReleasePomsPhase.java | 8 +++++++- .../subproject4/expected-release-pom.xml | 6 ------ .../subproject4/subsubproject/expected-release-pom.xml | 6 ------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java index 1261b2547..122a49bd9 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java @@ -459,7 +459,7 @@ private Scm createReleaseScm(Scm scm, ScmTranslator scmTranslator, ReleaseDescri private List createReleaseDependencies(ReleaseDescriptor releaseDescriptor, MavenProject project) throws ReleaseFailureException { - Set artifacts = project.getArtifacts(); + Set artifacts = project.getDependencyArtifacts(); List releaseDependencies = null; @@ -471,6 +471,12 @@ private List createReleaseDependencies(ReleaseDescriptor releaseDesc releaseDependencies = new ArrayList<>(); for (Artifact artifact : orderedArtifacts) { + if (artifact.getVersion() == null) { + artifact.setVersion(project.getArtifactMap() + .get(ArtifactUtils.versionlessKey(artifact)) + .getVersion()); + } + Dependency releaseDependency = new Dependency(); releaseDependency.setGroupId(artifact.getGroupId()); diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml index bf4aba3fb..d2309452a 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml @@ -68,12 +68,6 @@ under the License. - - groupId - subproject1 - 1.0 - compile - groupId subproject2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml index eaa57e88d..39fc6b8db 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml @@ -64,12 +64,6 @@ under the License. - - groupId - subproject1 - 1.0 - compile - groupId subproject2