[GitHub] hboutemy closed pull request #4: [MRELEASE-798] Commit additional files with release plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] hboutemy closed pull request #4: [MRELEASE-798] Commit additional files with release plugin

GitBox
hboutemy closed pull request #4: [MRELEASE-798] Commit additional files with release plugin
URL: https://github.com/apache/maven-release/pull/4
 
 
   

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/pom.xml b/maven-release-manager/pom.xml
index bd209a31..eba20925 100644
--- a/maven-release-manager/pom.xml
+++ b/maven-release-manager/pom.xml
@@ -234,7 +234,7 @@
           </execution>
         </executions>
         <configuration>
-          <version>2.3.0</version>
+          <version>2.3.1</version>
           <packageWithVersion>false</packageWithVersion>
           <useJava5>true</useJava5>
           <models>
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 32be254e..99cf4523 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
@@ -36,6 +36,7 @@
 import org.apache.maven.shared.release.scm.IdentifiedScm;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
 import org.sonatype.plexus.components.cipher.PlexusCipherException;
 import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
@@ -135,6 +136,10 @@ public void write( ReleaseDescriptor config, File file )
         {
             properties.setProperty( "commitByProject", "true" );
         }
+        if ( config.getAdditionalCommittedIncludes() != null )
+        {
+            properties.setProperty( "additionalCommittedIncludes", config.getAdditionalCommittedIncludes() );
+        }
         properties.setProperty( "scm.url", config.getScmSourceUrl() );
         if ( config.getScmId() != null )
         {
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 3f705909..096e9ade 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
@@ -27,6 +27,7 @@
 import java.util.Set;
 
 import org.apache.maven.shared.release.scm.IdentifiedScm;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Class providing utility methods used during the release process
@@ -120,6 +121,7 @@ public static ReleaseDescriptor merge( ReleaseDescriptor mergeInto, ReleaseDescr
         // Not overridden - not configured from caller
         mergeInto.setCompletedPhase( mergeDefault( mergeInto.getCompletedPhase(), toBeMerged.getCompletedPhase() ) );
 
+        mergeInto.setAdditionalCommittedIncludes(mergeOverride(mergeInto.getAdditionalCommittedIncludes(), toBeMerged.getAdditionalCommittedIncludes()));
         return mergeInto;
     }
 
@@ -169,6 +171,12 @@ public static ReleaseDescriptor copyPropertiesToReleaseDescriptor( Properties pr
         String pushChanges = properties.getProperty( "pushChanges" );
         releaseDescriptor.setPushChanges( pushChanges == null ? true : Boolean.valueOf( pushChanges ).booleanValue() );
 
+        String additionalCommitedIncludes = properties.getProperty( "additionalCommittedIncludes" ) ;
+        if ( StringUtils.isNotBlank(additionalCommitedIncludes) )
+        {
+            releaseDescriptor.setAdditionalCommittedIncludes(additionalCommitedIncludes);
+        }
+        
         loadResolvedDependencies( properties, releaseDescriptor );
 
         // 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/phase/AbstractScmCommitPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java
index 65800aef..f79940b7 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java
@@ -37,6 +37,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
 import org.apache.maven.shared.release.util.ReleaseUtil;
+import org.codehaus.plexus.util.DirectoryScanner;
 
 import java.io.File;
 import java.text.MessageFormat;
@@ -132,7 +133,11 @@ protected void performCheckins( ReleaseDescriptor releaseDescriptor, ReleaseEnvi
             for ( MavenProject project : reactorProjects )
             {
                 List<File> pomFiles = createPomFiles( releaseDescriptor, project );
-                ScmFileSet fileSet = new ScmFileSet( project.getFile().getParentFile(), pomFiles );
+                List<File> additionalFiles = createAdditionalFiles(releaseDescriptor, project) ;
+                List<File> files = new ArrayList<File>() ;
+                files.addAll(pomFiles);
+                files.addAll(additionalFiles) ;
+                ScmFileSet fileSet = new ScmFileSet( project.getFile().getParentFile(), files );
 
                 checkin( provider, repository, fileSet, releaseDescriptor, message );
             }
@@ -140,7 +145,11 @@ protected void performCheckins( ReleaseDescriptor releaseDescriptor, ReleaseEnvi
         else
         {
             List<File> pomFiles = createPomFiles( releaseDescriptor, reactorProjects );
-            ScmFileSet fileSet = new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ), pomFiles );
+            List<File> additionalFiles = createAdditionalFiles(releaseDescriptor, reactorProjects) ;
+            List<File> files = new ArrayList<File>() ;
+            files.addAll(pomFiles);
+            files.addAll(additionalFiles) ;
+            ScmFileSet fileSet = new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ), files );
 
             checkin( provider, repository, fileSet, releaseDescriptor, message );
         }
@@ -174,7 +183,11 @@ protected void simulateCheckins( ReleaseDescriptor releaseDescriptor, List<Maven
                                      String message )
     {
         Collection<File> pomFiles = createPomFiles( releaseDescriptor, reactorProjects );
-        logInfo( result, "Full run would be commit " + pomFiles.size() + " files with message: '" + message + "'" );
+        Collection<File> additionalFiles = createAdditionalFiles(releaseDescriptor, reactorProjects) ;
+        Collection<File> files = new ArrayList<File>() ;
+        files.addAll(pomFiles) ;
+        files.addAll(additionalFiles) ;
+        logInfo( result, "Full run would be commit " + files.size() + " files with message: '" + message + "'" );
     }
 
     protected void validateConfiguration( ReleaseDescriptor releaseDescriptor )
@@ -215,4 +228,43 @@ protected String createMessage( ReleaseDescriptor releaseDescriptor )
         }
         return pomFiles;
     }
+    
+    protected static List<File> createAdditionalFiles( ReleaseDescriptor releaseDescriptor, MavenProject project )
+    {
+        
+     List<File> additionalFiles = new ArrayList<File>();
+     if(releaseDescriptor.getAdditionalCommittedIncludes() != null) {
+     String[] additionalIncludes = releaseDescriptor.getAdditionalCommittedIncludes().replaceAll( "\\s", "" ).split( "," ); ;
+    
+     if(additionalIncludes != null && additionalIncludes.length !=0) {
+    
+        File baseDir = project.getBasedir() ;
+        
+        DirectoryScanner scanner = new DirectoryScanner();
+        scanner.setBasedir(baseDir);
+        scanner.setIncludes(additionalIncludes);
+        
+        scanner.scan();
+        
+        if(scanner.getIncludedFiles() != null) {
+         for(String file : scanner.getIncludedFiles()) {
+         additionalFiles.add(new File(baseDir, file)) ;
+         }
+        }
+        
+     }
+     }
+
+        return additionalFiles;
+    }
+
+    protected static List<File> createAdditionalFiles( ReleaseDescriptor releaseDescriptor, List<MavenProject> reactorProjects )
+    {
+        List<File> additionalFiles = new ArrayList<File>();
+        for ( MavenProject project : reactorProjects )
+        {
+            additionalFiles.addAll( createAdditionalFiles( releaseDescriptor, project ) );
+        }
+        return additionalFiles;
+    }
 }
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java
index 889b9c35..0ddc789f 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.text.MessageFormat;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -83,8 +84,12 @@ protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment
             if ( simulating )
             {
                 Collection<File> pomFiles = createPomFiles( releaseDescriptor, reactorProjects );
+                Collection<File> additionalFiles = createAdditionalFiles(releaseDescriptor, reactorProjects) ;
+                Collection<File> files = new ArrayList<File>() ;
+                files.addAll(pomFiles) ;
+                files.addAll(additionalFiles) ;
                 logInfo( result,
-                         "Full run would be commit " + pomFiles.size() + " files with message: '" + message + "'" );
+                         "Full run would be commit " + files.size() + " files with message: '" + message + "'" );
             }
             else
             {
diff --git a/maven-release-manager/src/main/mdo/release-descriptor.mdo b/maven-release-manager/src/main/mdo/release-descriptor.mdo
index 1dfc3f71..73c9e16b 100644
--- a/maven-release-manager/src/main/mdo/release-descriptor.mdo
+++ b/maven-release-manager/src/main/mdo/release-descriptor.mdo
@@ -489,6 +489,16 @@
             with @{ and }
           </description>
         </field>
+        
+ <field>
+          <name>additionalCommittedIncludes</name>
+          <version>2.3.1+</version>
+          <type>String</type>
+          <description>
+            In some exceptions you want to commit some changes to the repository in addition to pom files. Changes
+            to files listed here will be committed.
+          </description>
+        </field>        
 
         <!-- Announcement Information
 
@@ -819,6 +829,11 @@
         {
             return false;
         }
+        if ( !safeEquals( additionalCommittedIncludes, that.additionalCommittedIncludes ) )
+        {
+            return false;
+        }
+        
 
         return true;
     }
@@ -939,6 +954,7 @@
         result = 29 * result + ( performGoals != null ? performGoals.hashCode() : 0 );
         result = 29 * result + ( defaultReleaseVersion != null ? defaultReleaseVersion.hashCode() : 0 );
         result = 29 * result + ( scmReleasedPomRevision != null ? scmReleasedPomRevision.hashCode() : 0 );
+ result = 29 * result + ( additionalCommittedIncludes != null ? additionalCommittedIncludes.hashCode() : 0 );
 
         return result;
     }
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 841206b2..526d46ec 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
@@ -21,6 +21,7 @@
 
 import java.util.Arrays;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -218,6 +219,22 @@
     private int waitBeforeTagging;
 
     /**
+     * A list of additional include filters that will be commited with pom files.
+     *
+     * @since 2.4.2
+     */
+    @Parameter
+    private String[] additionalCommittedIncludes;
+    
+    /**
+     * Command-line version of additionalCommittedIncludes.
+     *
+     * @since 2.4.2
+     */
+    @Parameter( property = "additionalCommittedIncludeList" )
+    private String additionalCommittedIncludeList;  
+    
+    /**
      * {@inheritDoc}
      */
     public void execute()
@@ -266,6 +283,16 @@ protected void prepareRelease( boolean generateReleasePoms )
         {
             config.setCheckModificationExcludes( Arrays.asList( checkModificationExcludes ) );
         }
+        
+        if ( additionalCommittedIncludeList != null )
+        {
+         additionalCommittedIncludes = additionalCommittedIncludeList.replaceAll( "\\s", "" ).split( "," );
+        }
+
+        if ( additionalCommittedIncludes != null )
+        {
+            config.setAdditionalCommittedIncludes(StringUtils.join( additionalCommittedIncludes,"," ) );
+        }
 
         // Create a config containing values from the session properties (ie command line properties with cli).
         ReleaseDescriptor sysPropertiesConfig =


 

----------------------------------------------------------------
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:
[hidden email]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]