You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2010/09/29 16:25:02 UTC
svn commit: r1002649 - in /maven/release/trunk:
maven-release-manager/src/main/java/org/apache/maven/shared/release/config/
maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/
maven-release-manager/src/main/mdo/ maven-release-plu...
Author: brett
Date: Wed Sep 29 14:25:02 2010
New Revision: 1002649
URL: http://svn.apache.org/viewvc?rev=1002649&view=rev
Log:
[MRELEASE-554] Allow custom files to be modified before doing a prepare or branch
Both 'prepare' and 'branch' now have a configuration value checkModificationExcludes/checkModificationExcludeList
Submitted by: Lars Corneliussen
Modified:
maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java
maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo
maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java
maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java?rev=1002649&r1=1002648&r2=1002649&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java (original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java Wed Sep 29 14:25:02 2010
@@ -72,6 +72,7 @@ public class ReleaseUtils
mergeOverride( mergeInto.getPreparationGoals(), toBeMerged.getPreparationGoals() ) );
mergeInto.setPerformGoals( mergeOverride( mergeInto.getPerformGoals(), toBeMerged.getPerformGoals() ) );
mergeInto.setPomFileName( mergeOverride( mergeInto.getPomFileName(), toBeMerged.getPomFileName() ) );
+ mergeInto.setCheckModificationExcludes( toBeMerged.getCheckModificationExcludes() );
mergeInto.setScmUseEditMode( toBeMerged.isScmUseEditMode() );
mergeInto.setAddSchema( toBeMerged.isAddSchema() );
mergeInto.setGenerateReleasePoms( toBeMerged.isGenerateReleasePoms() );
@@ -146,7 +147,7 @@ public class ReleaseUtils
releaseDescriptor.setRemoteTagging( remoteTaggingStr == null ? false : Boolean.valueOf( remoteTaggingStr ).booleanValue() );
String pushChanges = properties.getProperty( "pushChanges" );
releaseDescriptor.setPushChanges( pushChanges == null ? true : Boolean.valueOf( pushChanges ).booleanValue() );
-
+
loadResolvedDependencies( properties, releaseDescriptor );
// boolean properties are not written to the properties file because the value from the caller is always used
Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java?rev=1002649&r1=1002648&r2=1002649&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java (original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java Wed Sep 29 14:25:02 2010
@@ -19,6 +19,7 @@ package org.apache.maven.shared.release.
* under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileSet;
@@ -72,7 +73,20 @@ public class ScmCheckModificationsPhase
{
ReleaseResult relResult = new ReleaseResult();
+ List additionalExcludes = releaseDescriptor.getCheckModificationExcludes();
+
+ if ( additionalExcludes != null )
+ {
+ for ( int i1 = 0, additionalExcludesSize = additionalExcludes.size(); i1 < additionalExcludesSize; i1++ )
+ {
+ // fail fast if it is not a string
+ String exclude = (String) additionalExcludes.get( i1 );
+ excludedFiles.add( exclude );
+ }
+ }
+
logInfo( relResult, "Verifying that there are no local modifications..." );
+ logInfo( relResult, " ignoring changes on: " + StringUtils.join(excludedFiles, ", "));
ScmRepository repository;
ScmProvider provider;
Modified: maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo?rev=1002649&r1=1002648&r2=1002649&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo (original)
+++ maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo Wed Sep 29 14:25:02 2010
@@ -305,6 +305,19 @@
</description>
</field>
<field>
+ <name>checkModificationExcludes</name>
+ <version>2.1.0+</version>
+ <type>List</type>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ In some exceptions you want to allow changes to the working copy. Changes
+ to files listed here will not make the ScmCheckModificationsPhase fail.
+ </description>
+ </field>
+ <field>
<name>preparationGoals</name>
<version>1.0.0+</version>
<type>String</type>
@@ -456,7 +469,7 @@
<!-- Code Segments -->
<codeSegments>
<codeSegment>
- <version>1.0.0+</version>
+ <version>2.1.0+</version>
<code><![CDATA[
public static final String DEVELOPMENT_KEY = "dev";
@@ -653,6 +666,16 @@
{
return false;
}
+ if ( ( checkModificationExcludes == null || ( checkModificationExcludes != null && checkModificationExcludes.size() == 0) ) &&
+ ( that.checkModificationExcludes == null || ( that.checkModificationExcludes != null && that.checkModificationExcludes.size() == 0) ) ) {
+ // Do nothing. This is a Modello workaround
+ } else {
+ if ( checkModificationExcludes != null ? !checkModificationExcludes.equals( that.checkModificationExcludes )
+ : that.checkModificationExcludes != null )
+ {
+ return false;
+ }
+ }
if ( ( developmentVersions == null || ( developmentVersions != null && developmentVersions.size() == 0) ) &&
( that.developmentVersions == null || ( that.developmentVersions != null && that.developmentVersions.size() == 0) ) ) {
// Do nothing. This is a Modello workaround
@@ -798,6 +821,7 @@
result = 29 * result + ( additionalArguments != null ? additionalArguments.hashCode() : 0 );
result = 29 * result + ( preparationGoals != null ? preparationGoals.hashCode() : 0 );
result = 29 * result + ( pomFileName != null ? pomFileName.hashCode() : 0 );
+ result = 29 * result + ( checkModificationExcludes != null ? checkModificationExcludes.hashCode() : 0 );
result = 29 * result + ( scmTagBase != null ? scmTagBase.hashCode() : 0 );
result = 29 * result + ( scmBranchBase != null ? scmBranchBase.hashCode() : 0 );
result = 29 * result + ( scmUsername != null ? scmUsername.hashCode() : 0 );
Modified: maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java?rev=1002649&r1=1002648&r2=1002649&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java (original)
+++ maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java Wed Sep 29 14:25:02 2010
@@ -19,6 +19,7 @@ package org.apache.maven.plugins.release
* under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.shared.release.ReleaseExecutionException;
@@ -26,6 +27,8 @@ import org.apache.maven.shared.release.R
import org.apache.maven.shared.release.config.ReleaseDescriptor;
import org.apache.maven.shared.release.config.ReleaseUtils;
+import java.util.Arrays;
+
/**
* Branch a project in SCM, using the same steps as the <tt>release:prepare</tt> goal, creating a branch instead of a tag.
* For more info see <a href="http://maven.apache.org/plugins/maven-release-plugin/examples/branch.html">http://maven.apache.org/plugins/maven-release-plugin/examples/branch.html</a>.
@@ -151,6 +154,27 @@ public class BranchReleaseMojo
*/
private boolean remoteTagging;
+ /**
+ * Additional files that will skipped when checking for
+ * modifications on the working copy.
+ *
+ * Is ignored, when checkModificationExcludes is set.
+ *
+ *
+ * @parameter
+ * @since 2.1
+ */
+ private String[] checkModificationExcludes;
+
+ /**
+ * Command-line version of checkModificationExcludes
+ *
+ *
+ * @parameter expression="${checkModificationExcludeList}"
+ * @since 2.1
+ */
+ private String checkModificationExcludeList;
+
/**
* Default version to use when preparing a release or a branch.
*
@@ -194,7 +218,17 @@ public class BranchReleaseMojo
// Create a config containing values from the session properties (ie command line properties with cli).
ReleaseDescriptor sysPropertiesConfig
= ReleaseUtils.copyPropertiesToReleaseDescriptor( session.getExecutionProperties() );
- mergeCommandLineConfig( config, sysPropertiesConfig );
+ mergeCommandLineConfig( config, sysPropertiesConfig );
+
+ if ( checkModificationExcludeList != null )
+ {
+ checkModificationExcludes = checkModificationExcludeList.replaceAll( "\\s", "" ).split( "," );
+ }
+
+ if ( checkModificationExcludes != null )
+ {
+ config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
+ }
try
{
Modified: maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=1002649&r1=1002648&r2=1002649&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java (original)
+++ maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java Wed Sep 29 14:25:02 2010
@@ -27,6 +27,8 @@ import org.apache.maven.shared.release.R
import org.apache.maven.shared.release.config.ReleaseDescriptor;
import org.apache.maven.shared.release.config.ReleaseUtils;
+import java.util.Arrays;
+
/**
* Prepare for a release in SCM. Steps through several phases to ensure the POM is ready to be
* released and then prepares SCM to eventually contain a tagged version of the release and a record
@@ -134,6 +136,27 @@ public class PrepareReleaseMojo
*/
private boolean allowReleasePluginSnapshot;
+ /**
+ * Additional files that will skipped when checking for
+ * modifications on the working copy.
+ *
+ * Is ignored, when checkModificationExcludes is set.
+ *
+ *
+ * @parameter
+ * @since 2.1
+ */
+ private String[] checkModificationExcludes;
+
+ /**
+ * Command-line version of checkModificationExcludes
+ *
+ *
+ * @parameter expression="${checkModificationExcludeList}"
+ * @since 2.1
+ */
+ private String checkModificationExcludeList;
+
/**
* Default version to use when preparing a release or a branch.
*
@@ -234,7 +257,17 @@ public class PrepareReleaseMojo
config.setDefaultDevelopmentVersion( developmentVersion );
config.setRemoteTagging( remoteTagging );
config.setUpdateWorkingCopyVersions( updateWorkingCopyVersions );
- config.setSuppressCommitBeforeTagOrBranch( suppressCommitBeforeTag );
+ config.setSuppressCommitBeforeTagOrBranch( suppressCommitBeforeTag );
+
+ if ( checkModificationExcludeList != null )
+ {
+ checkModificationExcludes = checkModificationExcludeList.replaceAll( "\\s", "" ).split( "," );
+ }
+
+ if ( checkModificationExcludes != null )
+ {
+ config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
+ }
// Create a config containing values from the session properties (ie command line properties with cli).
ReleaseDescriptor sysPropertiesConfig