maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] asfgit closed pull request #18: MRELEASE-985
Date Thu, 01 Jan 1970 00:00:00 GMT
asfgit closed pull request #18: MRELEASE-985
URL: https://github.com/apache/maven-release/pull/18
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
index 522fef4a..65d325f1 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
@@ -103,6 +103,8 @@ public static ReleaseDescriptor merge( ReleaseDescriptor mergeInto, ReleaseDescr
         mergeInto.setPushChanges( toBeMerged.isPushChanges() );
         mergeInto.setWaitBeforeTagging( toBeMerged.getWaitBeforeTagging() );
 
+        mergeInto.setResolvedSnapshotDependencies( toBeMerged.getResolvedSnapshotDependencies()
);
+
         // If the user specifies versions, these should be override the existing versions
         if ( toBeMerged.getReleaseVersions() != null )
         {
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 dd3c85f2..444b470e 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
@@ -110,7 +110,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro
         }
         else
         {
-            logInfo( result, "Ignoring SNAPSHOT depenedencies and plugins ..." );
+            logInfo( result, "Ignoring SNAPSHOT dependencies and plugins ..." );
         }
         result.setResultCode( ReleaseResult.SUCCESS );
 
@@ -131,7 +131,7 @@ private void checkProject( MavenProject project, Map<String, String>
originalVer
                 usedSnapshotDependencies.add( project.getParentArtifact() );
             }
         }
-        
+
         try
         {
             @SuppressWarnings( "unchecked" )
@@ -156,7 +156,7 @@ private void checkProject( MavenProject project, Map<String, String>
originalVer
         @SuppressWarnings( "unchecked" )
         Set<Artifact> extensionArtifacts = project.getExtensionArtifacts();
         checkExtensions( originalVersions, releaseDescriptor, artifactMap, extensionArtifacts
);
-        
+
         //@todo check profiles
 
         if ( !usedSnapshotDependencies.isEmpty() || !usedSnapshotReports.isEmpty()
@@ -315,13 +315,21 @@ private static Artifact getArtifactFromMap( Artifact artifact, Map<String,
Artif
     private static boolean checkArtifact( Artifact artifact, Map<String, String> originalVersions,
                                           ReleaseDescriptor releaseDescriptor )
     {
+
         String versionlessArtifactKey = ArtifactUtils.versionlessKey( artifact.getGroupId(),
artifact.getArtifactId() );
 
+        if ( releaseDescriptor.getResolvedSnapshotDependencies().containsKey( versionlessArtifactKey
) )
+        {
+            artifact.setVersion( ( String ) ( ( Map ) releaseDescriptor.getResolvedSnapshotDependencies()
+                                                                       .get( versionlessArtifactKey
) )
+                            .get( ReleaseDescriptor.RELEASE_KEY ) );
+        }
+
         // 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( originalVersions.get( versionlessArtifactKey
) );
+                            && !artifact.getBaseVersion().equals( originalVersions.get(
versionlessArtifactKey ) );
 
         // If we have a snapshot but allowTimestampedSnapshots is true, accept the artifact
if the version
         // indicates that it is a timestamped snapshot.
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 e0035144..8324eca7 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
@@ -22,14 +22,18 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.release.ReleaseExecutionException;
 import org.apache.maven.shared.release.ReleaseFailureException;
+import org.apache.maven.shared.release.ReleaseResult;
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 import org.apache.maven.shared.release.env.DefaultReleaseEnvironment;
 import org.codehaus.plexus.components.interactivity.Prompter;
 import org.codehaus.plexus.components.interactivity.PrompterException;
+import org.junit.Test;
+
 import static org.mockito.Mockito.*;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -108,6 +112,42 @@ public void testSnapshotDependenciesInProjectOnly()
         assertTrue( true );
     }
 
+    // MRELEASE-985
+    public void testSnapshotDependenciesInProjectAndResolveFromCommandLine() throws Exception
{
+        ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
+        List<MavenProject> reactorProjects = createDescriptorFromProjects( "internal-snapshot-dependencies-no-reactor"
);
+        releaseDescriptor.setInteractive( false );
+
+        final Map resolvedSnapshotDependencies = new HashMap();
+        Map releaseKeys = new HashMap();
+        releaseKeys.put( ReleaseDescriptor.RELEASE_KEY, "1.0" );
+        releaseKeys.put( ReleaseDescriptor.DEVELOPMENT_KEY, "1.1" );
+
+        resolvedSnapshotDependencies.put( "groupId:test", releaseKeys );
+
+        releaseDescriptor.setResolvedSnapshotDependencies( resolvedSnapshotDependencies );
+
+        try
+        {
+            phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects
);
+            assertTrue( true );
+        }
+        catch ( ReleaseFailureException e )
+        {
+            fail( "There should be no failed execution" );
+        }
+
+        try
+        {
+            phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects
);
+            assertTrue( true );
+        }
+        catch ( ReleaseFailureException e )
+        {
+            fail( "There should be no failed execution" );
+        }
+    }
+
     public void testSnapshotReleasePluginNonInteractive()
         throws Exception
     {
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 00000000..2dbefc5b
--- /dev/null
+++ b/maven-release-manager/src/test/resources/projects/check-dependencies/internal-snapshot-dependencies-no-reactor/pom.xml
@@ -0,0 +1,31 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ 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.
+  -->
+
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>groupId</groupId>
+    <artifactId>artifactId</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>groupId</groupId>
+            <artifactId>test</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
index ba96aeab..6d999b31 100644
--- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
+++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
@@ -315,5 +315,9 @@ protected void mergeCommandLineConfig( ReleaseDescriptor config, ReleaseDescript
         {
             config.getDevelopmentVersions().putAll( sysPropertiesConfig.getDevelopmentVersions()
);
         }
+        if ( sysPropertiesConfig.getResolvedSnapshotDependencies() != null )
+        {
+            config.getResolvedSnapshotDependencies().putAll( sysPropertiesConfig.getResolvedSnapshotDependencies()
);
+        }
     }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message