diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java index 2eb77d6b2..6ee6c9a0d 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java @@ -108,22 +108,42 @@ private void prepare( ReleasePrepareRequest prepareRequest, ReleaseResult result // Create a config containing values from the session properties (ie command line properties with cli). ReleaseUtils.copyPropertiesToReleaseDescriptor( prepareRequest.getUserProperties(), - new ReleaseDescriptorBuilder() - { - public ReleaseDescriptorBuilder addDevelopmentVersion( String key, - String value ) - { - builder.addDevelopmentVersion( key, value ); - return this; - } - - public ReleaseDescriptorBuilder addReleaseVersion( String key, - String value ) - { - builder.addReleaseVersion( key, value ); - return this; - }; - } ); + new ReleaseDescriptorBuilder() + { + public ReleaseDescriptorBuilder addDevelopmentVersion( String key, + String value ) + { + builder.addDevelopmentVersion( key, value ); + return this; + } + + public ReleaseDescriptorBuilder addReleaseVersion( String key, + String value ) + { + builder.addReleaseVersion( key, value ); + return this; + } + + public ReleaseDescriptorBuilder addDependencyOriginalVersion( String dependencyKey, String version ) + { + builder.addDependencyOriginalVersion( dependencyKey, version ); + return this; + } + + public ReleaseDescriptorBuilder addDependencyReleaseVersion( String dependencyKey, + String version ) + { + builder.addDependencyReleaseVersion( dependencyKey, version ); + return this; + } + + public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependencyKey, + String version ) + { + builder.addDependencyDevelopmentVersion( dependencyKey, version ); + return this; + } + } ); BuilderReleaseDescriptor config; if ( BooleanUtils.isNotFalse( prepareRequest.getResume() ) ) @@ -132,7 +152,7 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, } else { - config = ReleaseUtils.buildReleaseDescriptor( prepareRequest.getReleaseDescriptorBuilder() ); + config = ReleaseUtils.buildReleaseDescriptor( builder ); } Strategy releaseStrategy = getStrategy( config.getReleaseStrategyId() ); @@ -667,4 +687,4 @@ private void captureException( ReleaseResult result, ReleaseManagerListener list result.setResultCode( ReleaseResult.ERROR ); } -} \ No newline at end of file +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java index 4dd43b720..1768a1cb6 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java @@ -309,7 +309,8 @@ private static boolean checkArtifact( Artifact artifact, ReleaseDescriptor relea // We are only looking at dependencies external to the project - ignore anything found in the reactor as // it's version will be updated boolean result = artifact.isSnapshot() - && !artifact.getBaseVersion().equals( releaseDescriptor.getProjectOriginalVersion( versionlessKey ) ); + && !artifact.getBaseVersion().equals( releaseDescriptor.getProjectOriginalVersion( versionlessKey ) ) + && releaseDescriptor.getDependencyReleaseVersion( versionlessKey ) == null; // If we have a snapshot but allowTimestampedSnapshots is true, accept the artifact if the version // indicates that it is a timestamped snapshot. @@ -456,4 +457,4 @@ private void processSnapshot( Set snapshotSet, ReleaseDescriptor relea releaseDescriptor.addDependencyDevelopmentVersion( versionlessKey, result ); } } -} \ No newline at end of file +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java index 2b0edf66d..2b0dff2a6 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java @@ -30,7 +30,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import org.apache.maven.project.MavenProject; @@ -108,6 +110,35 @@ public void testNoSnapshotRangeDependencies() assertTrue( true ); } + // MRELEASE-985 + @Test + public void testSnapshotDependenciesInProjectAndResolveFromCommandLine() throws Exception { + List reactorProjects = createDescriptorFromProjects( "internal-snapshot-dependencies-no-reactor" ); + ReleaseDescriptorBuilder builder = createReleaseDescriptorBuilder( reactorProjects ); + builder.addDependencyReleaseVersion("groupId:test", "1.0"); + builder.addDependencyDevelopmentVersion("groupId:test", "1.1"); + + try + { + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + assertTrue( true ); + } + catch ( ReleaseFailureException e ) + { + fail( "There should be no failed execution" ); + } + + try + { + phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + assertTrue( true ); + } + catch ( ReleaseFailureException e ) + { + fail( "There should be no failed execution" ); + } + } + @Test public void testSnapshotDependenciesInProjectOnly() throws Exception @@ -498,10 +529,10 @@ public void testSnapshotDependenciesOutsideProjectOnlyInteractiveWithSnapshotsRe new VersionPair( "1.0", "1.0" ) ) ); phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); - + // validate ReleaseDescriptor descriptor = ReleaseUtils.buildReleaseDescriptor( builder ); - + assertEquals( "1.0", descriptor.getDependencyReleaseVersion( "external:artifactId" ) ); assertEquals( "1.1-SNAPSHOT", descriptor.getDependencyDevelopmentVersion( "external:artifactId" ) ); diff --git a/maven-release-manager/src/test/resources/projects/check-dependencies/internal-snapshot-dependencies-no-reactor/pom.xml b/maven-release-manager/src/test/resources/projects/check-dependencies/internal-snapshot-dependencies-no-reactor/pom.xml new file mode 100644 index 000000000..c62fbfabd --- /dev/null +++ b/maven-release-manager/src/test/resources/projects/check-dependencies/internal-snapshot-dependencies-no-reactor/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + groupId + artifactId + 1.0-SNAPSHOT + jar + + + + groupId + test + 1.0-SNAPSHOT + + +