diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
index a6d03c2bd..804400492 100644
--- a/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
+++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
@@ -464,4 +464,21 @@ public interface ReleaseDescriptor
void setScmRelativePathProjectDirectory( String scmRelativePathProjectDirectory );
void setScmSourceUrl( String scmUrl );
+
+ /**
+ * Returns whether unresolved SNAPSHOT dependencies should automatically be resolved.
+ * If this is set, then this specifies the default answer to be used when unresolved SNAPSHOT
+ * dependencies should automatically be resolved ( 0:All 1:Project Dependencies 2:Plugins
+ * 3:Reports 4:Extensions ). Possible values are:
+ *
+ * - "all" or "0": resolve all kinds of snapshots, ie. project, plugin, report and extension dependencies
+ * - "dependencies" or "1": resolve project dependencies
+ * - "plugins" or "2": resolve plugin dependencis
+ * - "reports" or "3": resolve report dependencies
+ * - "extensions" or "4": resolve extension dependencies
+ *
+ *
+ * @return String
+ */
+ String getAutoResolveSnapshots();
}
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
index 262b21d4a..f1272de62 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
@@ -256,6 +256,11 @@ public void write( BuilderReleaseDescriptor config, File file )
properties.setProperty( "workItem", config.getWorkItem() );
}
+ if ( config.getAutoResolveSnapshots() != null )
+ {
+ properties.setProperty( "autoResolveSnapshots", config.getAutoResolveSnapshots() );
+ }
+
// others boolean properties are not written to the properties file because the value from the caller is always
// used
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
index 745dc4da6..629a897d9 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
@@ -440,6 +440,12 @@ public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependen
return this;
}
+ public ReleaseDescriptorBuilder setAutoResolveSnapshots( String autoResolveSnapshots )
+ {
+ releaseDescriptor.setAutoResolveSnapshots( autoResolveSnapshots );
+ return this;
+ }
+
BuilderReleaseDescriptor build()
{
return releaseDescriptor;
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 bc48cc563..bcaf75813 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
@@ -170,6 +170,11 @@ public static void copyPropertiesToReleaseDescriptor( Properties properties, Rel
{
builder.setWorkItem( properties.getProperty( "workItem" ) );
}
+ if ( properties.containsKey( "autoResolveSnapshots" ) )
+ {
+ String resolve = properties.getProperty( "autoResolveSnapshots" );
+ builder.setAutoResolveSnapshots( resolve );
+ }
loadResolvedDependencies( properties, builder );
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 b19b44635..55821c083 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
@@ -144,7 +144,7 @@ private void checkProject( MavenProject project, ReleaseDescriptor releaseDescri
if ( !usedSnapshotDependencies.isEmpty() || !usedSnapshotReports.isEmpty()
|| !usedSnapshotExtensions.isEmpty() || !usedSnapshotPlugins.isEmpty() )
{
- if ( releaseDescriptor.isInteractive() )
+ if ( releaseDescriptor.isInteractive() || null != releaseDescriptor.getAutoResolveSnapshots() )
{
resolveSnapshots( usedSnapshotDependencies, usedSnapshotReports, usedSnapshotExtensions,
usedSnapshotPlugins, releaseDescriptor );
@@ -365,10 +365,19 @@ private void resolveSnapshots( Set projectDependencies, Set
{
try
{
+ String autoResolveSnapshots = releaseDescriptor.getAutoResolveSnapshots();
if ( resolveSnapshot == null )
{
prompter.showMessage( RESOLVE_SNAPSHOT_MESSAGE );
- resolveSnapshot = prompter.prompt( RESOLVE_SNAPSHOT_PROMPT, Arrays.asList( "yes", "no" ), "no" );
+ if ( autoResolveSnapshots != null )
+ {
+ resolveSnapshot = "yes";
+ prompter.showMessage( RESOLVE_SNAPSHOT_PROMPT + " " + resolveSnapshot );
+ }
+ else
+ {
+ resolveSnapshot = prompter.prompt( RESOLVE_SNAPSHOT_PROMPT, Arrays.asList( "yes", "no" ), "no" );
+ }
}
if ( resolveSnapshot.toLowerCase( Locale.ENGLISH ).startsWith( "y" ) )
@@ -376,38 +385,81 @@ private void resolveSnapshots( Set projectDependencies, Set
if ( resolveSnapshotType == null )
{
prompter.showMessage( RESOLVE_SNAPSHOT_TYPE_MESSAGE );
- resolveSnapshotType =
- prompter.prompt( RESOLVE_SNAPSHOT_TYPE_PROMPT, Arrays.asList( "0", "1", "2", "3" ), "1" );
+ int defaultAnswer = -1;
+ if ( autoResolveSnapshots != null )
+ {
+ if ( "all".equalsIgnoreCase( autoResolveSnapshots ) )
+ {
+ defaultAnswer = 0;
+ }
+ else if ( "dependencies".equalsIgnoreCase( autoResolveSnapshots ) )
+ {
+ defaultAnswer = 1;
+ }
+ else if ( "plugins".equalsIgnoreCase( autoResolveSnapshots ) )
+ {
+ defaultAnswer = 2;
+ }
+ else if ( "reports".equalsIgnoreCase( autoResolveSnapshots ) )
+ {
+ defaultAnswer = 3;
+ }
+ else if ( "extensions".equalsIgnoreCase( autoResolveSnapshots ) )
+ {
+ defaultAnswer = 4;
+ }
+ else
+ {
+ try
+ {
+ defaultAnswer = Integer.parseInt( autoResolveSnapshots );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new ReleaseExecutionException( e.getMessage(), e );
+ }
+ }
+ }
+ if ( defaultAnswer >= 0 && defaultAnswer <= 4 )
+ {
+ prompter.showMessage( RESOLVE_SNAPSHOT_TYPE_PROMPT + " " + autoResolveSnapshots );
+ resolveSnapshotType = Integer.toString( defaultAnswer );
+ }
+ else
+ {
+ resolveSnapshotType =
+ prompter.prompt( RESOLVE_SNAPSHOT_TYPE_PROMPT, Arrays.asList( "0", "1", "2", "3" ), "1" );
+ }
}
switch ( Integer.parseInt( resolveSnapshotType.toLowerCase( Locale.ENGLISH ) ) )
{
// all
case 0:
- processSnapshot( projectDependencies, releaseDescriptor );
- processSnapshot( pluginDependencies, releaseDescriptor );
- processSnapshot( reportDependencies, releaseDescriptor );
- processSnapshot( extensionDependencies, releaseDescriptor );
+ processSnapshot( projectDependencies, releaseDescriptor, autoResolveSnapshots );
+ processSnapshot( pluginDependencies, releaseDescriptor, autoResolveSnapshots );
+ processSnapshot( reportDependencies, releaseDescriptor, autoResolveSnapshots );
+ processSnapshot( extensionDependencies, releaseDescriptor, autoResolveSnapshots );
break;
// project dependencies
case 1:
- processSnapshot( projectDependencies, releaseDescriptor );
+ processSnapshot( projectDependencies, releaseDescriptor, autoResolveSnapshots );
break;
// plugins
case 2:
- processSnapshot( pluginDependencies, releaseDescriptor );
+ processSnapshot( pluginDependencies, releaseDescriptor, autoResolveSnapshots );
break;
// reports
case 3:
- processSnapshot( reportDependencies, releaseDescriptor );
+ processSnapshot( reportDependencies, releaseDescriptor, autoResolveSnapshots );
break;
// extensions
case 4:
- processSnapshot( extensionDependencies, releaseDescriptor );
+ processSnapshot( extensionDependencies, releaseDescriptor, autoResolveSnapshots );
break;
default:
@@ -420,7 +472,8 @@ private void resolveSnapshots( Set projectDependencies, Set
}
}
- private void processSnapshot( Set snapshotSet, ReleaseDescriptor releaseDescriptor )
+ private void processSnapshot( Set snapshotSet, ReleaseDescriptor releaseDescriptor,
+ String autoResolveSnapshots )
throws PrompterException, VersionParseException
{
Iterator iterator = snapshotSet.iterator();
@@ -435,8 +488,17 @@ private void processSnapshot( Set snapshotSet, ReleaseDescriptor relea
prompter.showMessage(
"Dependency '" + versionlessKey + "' is a snapshot (" + currentArtifact.getVersion() + ")\n" );
- String result = prompter.prompt( "Which release version should it be set to?",
- versionInfo.getReleaseVersionString() );
+ String message = "Which release version should it be set to?";
+ String result;
+ if ( null != autoResolveSnapshots )
+ {
+ result = versionInfo.getReleaseVersionString();
+ prompter.showMessage( message + " " + result );
+ }
+ else
+ {
+ result = prompter.prompt( message, versionInfo.getReleaseVersionString() );
+ }
releaseDescriptor.addDependencyReleaseVersion( versionlessKey, result );
@@ -456,7 +518,16 @@ private void processSnapshot( Set snapshotSet, ReleaseDescriptor relea
nextVersion = versionInfo.toString();
}
- result = prompter.prompt( "What version should the dependency be reset to for development?", nextVersion );
+ message = "What version should the dependency be reset to for development?";
+ if ( null != autoResolveSnapshots )
+ {
+ result = nextVersion;
+ prompter.showMessage( message + " " + result );
+ }
+ else
+ {
+ result = prompter.prompt( message, nextVersion );
+ }
releaseDescriptor.addDependencyDevelopmentVersion( versionlessKey, result );
}
diff --git a/maven-release-manager/src/main/mdo/release-descriptor.mdo b/maven-release-manager/src/main/mdo/release-descriptor.mdo
index b63c4b455..6bf44f2ca 100644
--- a/maven-release-manager/src/main/mdo/release-descriptor.mdo
+++ b/maven-release-manager/src/main/mdo/release-descriptor.mdo
@@ -563,6 +563,26 @@
+
+ autoResolveSnapshots
+ 3.0.0+
+ String
+
+
+ "all" or "0": resolve all kinds of snapshots, ie. project, plugin, report and extension dependencies
+ "dependencies" or "1": resolve project dependencies
+ "plugins" or "2": resolve plugin dependencies
+ "reports" or "3": resolve report dependencies
+ "extensions" or "4": resolve extension dependencies
+
+ Additionally this implies that the default values for the dependency's release and next
+ development version are used.]]>
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.plugins.release.its
+ mrelease-835
+ 1.0-SNAPSHOT
+ pom
+
+
+ scm:dummy|nul
+ scm:dummy|nul
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ @project.version@
+
+ dependencies
+ -Dflag -Dfoo=bar
+ invoker
+ validate
+ validate
+ verify
+
+
+
+ org.apache.maven.its.release
+ maven-scm-provider-dummy
+ 1.0
+
+
+
+
+
+
+
+
+ test
+ dependency
+ 1.2.3-SNAPSHOT
+
+
+ test
+ dependency.test
+ 2.3.4-SNAPSHOT
+ test
+
+
+
diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-835/verify.groovy b/maven-release-plugin/src/it/projects/prepare/MRELEASE-835/verify.groovy
new file mode 100644
index 000000000..027cc503b
--- /dev/null
+++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-835/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 buildLog = new File( basedir, 'build.log' )
+assert buildLog.exists()
+
+assert 1 == buildLog.getText().count("[DEBUG] (f) autoResolveSnapshots = dependencies")
+
+File pomXmlNext = new File( basedir, 'pom.xml.next' )
+assert pomXmlNext.exists()
+assert 1 == pomXmlNext.getText().count("1.2.3")
+assert 1 == pomXmlNext.getText().count("2.3.4")
diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
index 1c3e057d5..9e601c026 100644
--- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
+++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
@@ -280,6 +280,27 @@ public class PrepareReleaseMojo
property = "scmDevelopmentCommitComment" )
private String scmDevelopmentCommitComment = "@{prefix} prepare for next development iteration";
+ /**
+ * Specifies whether unresolved SNAPSHOT dependencies should automatically be resolved.
+ * If this is set, then this specifies the default answer to be used when unresolved SNAPSHOT
+ * dependencies should automatically be resolved ( 0:All 1:Project Dependencies 2:Plugins
+ * 3:Reports 4:Extensions ). Possible values are:
+ *
+ * - "all" or "0": resolve all kinds of snapshots, ie. project, plugin, report and extension dependencies
+ * - "dependencies" or "1": resolve project dependencies
+ * - "plugins" or "2": resolve plugin dependencis
+ * - "reports" or "3": resolve report dependencies
+ * - "extensions" or "4": resolve extension dependencies
+ *
+ *
+ * @since 3.0.0
+ */
+ @Parameter( property = "autoResolveSnapshots" )
+ private String autoResolveSnapshots;
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute()
throws MojoExecutionException, MojoFailureException
@@ -321,6 +342,7 @@ protected void prepareRelease( boolean generateReleasePoms )
config.setProjectNamingPolicyId( projectTagNamingPolicyId );
config.setScmDevelopmentCommitComment( scmDevelopmentCommitComment );
config.setScmReleaseCommitComment( scmReleaseCommitComment );
+ config.setAutoResolveSnapshots( autoResolveSnapshots );
if ( checkModificationExcludeList != null )
{