maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pg...@apache.org
Subject svn commit: r651435 - 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-plug...
Date Thu, 24 Apr 2008 21:46:38 GMT
Author: pgier
Date: Thu Apr 24 14:46:34 2008
New Revision: 651435

URL: http://svn.apache.org/viewvc?rev=651435&view=rev
Log:
[MRELEASE-173] Adding simplified parameters for setting the version numbers to use during
the release.

Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
    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/MapVersionsPhase.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/PrepareReleaseMojo.java
    maven/release/trunk/maven-release-plugin/src/site/apt/examples/non-interactive-release.apt

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java?rev=651435&r1=651434&r2=651435&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java
Thu Apr 24 14:46:34 2008
@@ -30,7 +30,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -85,68 +84,7 @@
             IOUtil.close( inStream );
         }
         
-        // Command line properties should be able to override the props in the release.properties
file.
-        properties.putAll( System.getProperties() );
-
-        ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
-        releaseDescriptor.setCompletedPhase( properties.getProperty( "completedPhase" ) );
-        releaseDescriptor.setScmSourceUrl( properties.getProperty( "scm.url" ) );
-        releaseDescriptor.setScmUsername( properties.getProperty( "scm.username" ) );
-        releaseDescriptor.setScmPassword( properties.getProperty( "scm.password" ) );
-        releaseDescriptor.setScmPrivateKey( properties.getProperty( "scm.privateKey" ) );
-        releaseDescriptor.setScmPrivateKeyPassPhrase( properties.getProperty( "scm.passphrase"
) );
-        releaseDescriptor.setScmTagBase( properties.getProperty( "scm.tagBase" ) );
-        releaseDescriptor.setScmReleaseLabel( properties.getProperty( "scm.tag" ) );
-        releaseDescriptor.setScmCommentPrefix( properties.getProperty( "scm.commentPrefix"
) );
-        releaseDescriptor.setAdditionalArguments( properties.getProperty( "exec.additionalArguments"
) );
-        releaseDescriptor.setPomFileName( properties.getProperty( "exec.pomFileName" ) );
-        releaseDescriptor.setPreparationGoals( properties.getProperty( "preparationGoals"
) );
-
-        loadResolvedDependencies( properties, releaseDescriptor );
-
-        // boolean properties are not written to the properties file because the value from
the caller is always used
-
-        for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
-        {
-            String property = (String) i.next();
-            if ( property.startsWith( "project.rel." ) )
-            {
-                releaseDescriptor.mapReleaseVersion( property.substring( "project.rel.".length()
),
-                                                     properties.getProperty( property ) );
-            }
-            else if ( property.startsWith( "project.dev." ) )
-            {
-                releaseDescriptor.mapDevelopmentVersion( property.substring( "project.dev.".length()
),
-                                                         properties.getProperty( property
) );
-            }
-            else if ( property.startsWith( "project.scm." ) )
-            {
-                int index = property.lastIndexOf( '.' );
-                if ( index > "project.scm.".length() )
-                {
-                    String key = property.substring( "project.scm.".length(), index );
-
-                    if ( !releaseDescriptor.getOriginalScmInfo().containsKey( key ) )
-                    {
-                        if ( properties.getProperty( "project.scm." + key + ".empty" ) !=
null )
-                        {
-                            releaseDescriptor.mapOriginalScmInfo( key, null );
-                        }
-                        else
-                        {
-                            Scm scm = new Scm();
-                            scm.setConnection( properties.getProperty( "project.scm." + key
+ ".connection" ) );
-                            scm.setDeveloperConnection(
-                                properties.getProperty( "project.scm." + key + ".developerConnection"
) );
-                            scm.setUrl( properties.getProperty( "project.scm." + key + ".url"
) );
-                            scm.setTag( properties.getProperty( "project.scm." + key + ".tag"
) );
-
-                            releaseDescriptor.mapOriginalScmInfo( key, scm );
-                        }
-                    }
-                }
-            }
-        }
+        ReleaseDescriptor releaseDescriptor = ReleaseUtils.copyPropertiesToReleaseDescriptor(
properties );
 
         if ( mergeDescriptor != null )
         {
@@ -312,58 +250,4 @@
         return new File( mergeDescriptor.getWorkingDirectory(), "release.properties" );
     }
 
-    private void loadResolvedDependencies( Properties prop, ReleaseDescriptor descriptor
)
-    {
-        Map resolvedDependencies = new HashMap();
-
-        Set entries = prop.entrySet();
-        Iterator iterator = entries.iterator();
-        String propertyName;
-        Entry currentEntry;
-
-        while ( iterator.hasNext() )
-        {
-            currentEntry = (Entry) iterator.next();
-            propertyName = (String) currentEntry.getKey();
-
-            if ( propertyName.startsWith( "dependency." ) )
-            {
-                Map versionMap;
-                String artifactVersionlessKey;
-                int startIndex;
-                int endIndex;
-                String versionType;
-
-                versionMap = new HashMap();
-                startIndex = propertyName.lastIndexOf( "dependency." );
-
-                if ( propertyName.indexOf( ".development" ) != -1 )
-                {
-                    endIndex = propertyName.indexOf( ".development" );
-                    versionType = ReleaseDescriptor.DEVELOPMENT_KEY;
-                }
-                else
-                {
-                    endIndex = propertyName.indexOf( ".release" );
-                    versionType = ReleaseDescriptor.RELEASE_KEY;
-                }
-
-                artifactVersionlessKey = propertyName.substring( startIndex, endIndex );
-
-                if ( resolvedDependencies.containsKey( artifactVersionlessKey ) )
-                {
-                    versionMap = (Map) resolvedDependencies.get( artifactVersionlessKey );
-                }
-                else
-                {
-                    versionMap = new HashMap();
-                    resolvedDependencies.put( artifactVersionlessKey, versionMap );
-                }
-
-                versionMap.put( versionType, currentEntry.getValue() );
-            }
-        }
-
-        descriptor.setResolvedSnapshotDependencies( resolvedDependencies );
-    }
 }

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=651435&r1=651434&r2=651435&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
Thu Apr 24 14:46:34 2008
@@ -1,5 +1,14 @@
 package org.apache.maven.shared.release.config;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.maven.model.Scm;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -75,7 +84,11 @@
         mergeInto.setUpdateVersionsToSnapshot( toBeMerged.isUpdateVersionsToSnapshot() );
         mergeInto.setAllowTimestampedSnapshots( toBeMerged.isAllowTimestampedSnapshots()
);
         mergeInto.setAutoVersionSubmodules( toBeMerged.isAutoVersionSubmodules() );
-
+        mergeInto.setDefaultReleaseVersion( mergeOverride( mergeInto.getDefaultReleaseVersion(),

+                                                           toBeMerged.getDefaultReleaseVersion()
) );
+        mergeInto.setDefaultDevelopmentVersion( mergeOverride( mergeInto.getDefaultDevelopmentVersion(),
+                                                               toBeMerged.getDefaultDevelopmentVersion()
) );
+        
         // These must be overridden, as they are not stored
         mergeInto.setWorkingDirectory(
             mergeOverride( mergeInto.getWorkingDirectory(), toBeMerged.getWorkingDirectory()
) );
@@ -97,4 +110,124 @@
     {
         return thisValue != null ? thisValue : mergeValue;
     }
+    
+    public static ReleaseDescriptor copyPropertiesToReleaseDescriptor( Properties properties
)
+    {
+        ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
+        releaseDescriptor.setCompletedPhase( properties.getProperty( "completedPhase" ) );
+        releaseDescriptor.setScmSourceUrl( properties.getProperty( "scm.url" ) );
+        releaseDescriptor.setScmUsername( properties.getProperty( "scm.username" ) );
+        releaseDescriptor.setScmPassword( properties.getProperty( "scm.password" ) );
+        releaseDescriptor.setScmPrivateKey( properties.getProperty( "scm.privateKey" ) );
+        releaseDescriptor.setScmPrivateKeyPassPhrase( properties.getProperty( "scm.passphrase"
) );
+        releaseDescriptor.setScmTagBase( properties.getProperty( "scm.tagBase" ) );
+        releaseDescriptor.setScmReleaseLabel( properties.getProperty( "scm.tag" ) );
+        releaseDescriptor.setScmCommentPrefix( properties.getProperty( "scm.commentPrefix"
) );
+        releaseDescriptor.setAdditionalArguments( properties.getProperty( "exec.additionalArguments"
) );
+        releaseDescriptor.setPomFileName( properties.getProperty( "exec.pomFileName" ) );
+        releaseDescriptor.setPreparationGoals( properties.getProperty( "preparationGoals"
) );
+
+        loadResolvedDependencies( properties, releaseDescriptor );
+
+        // boolean properties are not written to the properties file because the value from
the caller is always used
+
+        for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
+        {
+            String property = (String) i.next();
+            if ( property.startsWith( "project.rel." ) )
+            {
+                releaseDescriptor.mapReleaseVersion( property.substring( "project.rel.".length()
),
+                                                     properties.getProperty( property ) );
+            }
+            else if ( property.startsWith( "project.dev." ) )
+            {
+                releaseDescriptor.mapDevelopmentVersion( property.substring( "project.dev.".length()
),
+                                                         properties.getProperty( property
) );
+            }
+            else if ( property.startsWith( "project.scm." ) )
+            {
+                int index = property.lastIndexOf( '.' );
+                if ( index > "project.scm.".length() )
+                {
+                    String key = property.substring( "project.scm.".length(), index );
+
+                    if ( !releaseDescriptor.getOriginalScmInfo().containsKey( key ) )
+                    {
+                        if ( properties.getProperty( "project.scm." + key + ".empty" ) !=
null )
+                        {
+                            releaseDescriptor.mapOriginalScmInfo( key, null );
+                        }
+                        else
+                        {
+                            Scm scm = new Scm();
+                            scm.setConnection( properties.getProperty( "project.scm." + key
+ ".connection" ) );
+                            scm.setDeveloperConnection(
+                                properties.getProperty( "project.scm." + key + ".developerConnection"
) );
+                            scm.setUrl( properties.getProperty( "project.scm." + key + ".url"
) );
+                            scm.setTag( properties.getProperty( "project.scm." + key + ".tag"
) );
+
+                            releaseDescriptor.mapOriginalScmInfo( key, scm );
+                        }
+                    }
+                }
+            }
+        }
+        return releaseDescriptor;
+    }
+
+    private static void loadResolvedDependencies( Properties prop, ReleaseDescriptor descriptor
)
+    {
+        Map resolvedDependencies = new HashMap();
+
+        Set entries = prop.entrySet();
+        Iterator iterator = entries.iterator();
+        String propertyName;
+        Entry currentEntry;
+
+        while ( iterator.hasNext() )
+        {
+            currentEntry = (Entry) iterator.next();
+            propertyName = (String) currentEntry.getKey();
+
+            if ( propertyName.startsWith( "dependency." ) )
+            {
+                Map versionMap;
+                String artifactVersionlessKey;
+                int startIndex;
+                int endIndex;
+                String versionType;
+
+                versionMap = new HashMap();
+                startIndex = propertyName.lastIndexOf( "dependency." );
+
+                if ( propertyName.indexOf( ".development" ) != -1 )
+                {
+                    endIndex = propertyName.indexOf( ".development" );
+                    versionType = ReleaseDescriptor.DEVELOPMENT_KEY;
+                }
+                else
+                {
+                    endIndex = propertyName.indexOf( ".release" );
+                    versionType = ReleaseDescriptor.RELEASE_KEY;
+                }
+
+                artifactVersionlessKey = propertyName.substring( startIndex, endIndex );
+
+                if ( resolvedDependencies.containsKey( artifactVersionlessKey ) )
+                {
+                    versionMap = (Map) resolvedDependencies.get( artifactVersionlessKey );
+                }
+                else
+                {
+                    versionMap = new HashMap();
+                    resolvedDependencies.put( artifactVersionlessKey, versionMap );
+                }
+
+                versionMap.put( versionType, currentEntry.getValue() );
+            }
+        }
+
+        descriptor.setResolvedSnapshotDependencies( resolvedDependencies );
+    }
+
 }

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java?rev=651435&r1=651434&r2=651435&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java
Thu Apr 24 14:46:34 2008
@@ -180,6 +180,10 @@
             releaseVersionInfo = currentVersionInfo;
             
             // Check if the user specified a release version
+            if ( releaseDescriptor.getDefaultReleaseVersion() != null )
+            {
+                releaseVersionInfo = new DefaultVersionInfo( releaseDescriptor.getDefaultReleaseVersion()
);
+            }
             if ( releaseDescriptor.getReleaseVersions() != null )
             {
                 String releaseVersion = ( String ) releaseDescriptor.getReleaseVersions().get(
projectId );
@@ -195,6 +199,10 @@
             }
             
             // Check if the user specified a new snapshot version
+            if ( releaseDescriptor.getDefaultDevelopmentVersion() != null )
+            {
+                nextSnapshotVersionInfo = new DefaultVersionInfo( releaseDescriptor.getDefaultDevelopmentVersion()
);
+            }
             if ( releaseDescriptor.getDevelopmentVersions() != null )
             {
                 String nextDevVersion = ( String ) releaseDescriptor.getDevelopmentVersions().get(
projectId );

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=651435&r1=651434&r2=651435&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 Thu Apr
24 14:46:34 2008
@@ -361,6 +361,22 @@
               dependency is found.
           </description>
         </field>
+        <field>
+          <name>defaultReleaseVersion</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <description>
+            Default version to use for the tagged release or the new branch.
+          </description>
+        </field>
+        <field>
+          <name>defaultDevelopmentVersion</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <description>
+            Default version to use for new working copy.
+          </description>
+        </field>
 
         <!-- Announcement Information
 

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=651435&r1=651434&r2=651435&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
Thu Apr 24 14:46:34 2008
@@ -24,6 +24,7 @@
 import org.apache.maven.shared.release.ReleaseExecutionException;
 import org.apache.maven.shared.release.ReleaseFailureException;
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
+import org.apache.maven.shared.release.config.ReleaseUtils;
 
 /**
  * Prepare for a release in SCM.
@@ -117,6 +118,20 @@
      */
     private boolean allowTimestampedSnapshots;
 
+    /**
+     * Default version to use when preparing a release or a branch.
+     *
+     * @parameter expression="${releaseVersion}"
+     */
+    private String releaseVersion;
+    
+    /**
+     * Default version to use for new local working copy.
+     *
+     * @parameter expression="${developmentVersion}"
+     */
+    private String developmentVersion;
+    
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -131,6 +146,13 @@
         config.setUpdateDependencies( updateDependencies );
         config.setAutoVersionSubmodules( autoVersionSubmodules );
         config.setAllowTimestampedSnapshots( allowTimestampedSnapshots );
+        config.setDefaultReleaseVersion( releaseVersion );
+        config.setDefaultDevelopmentVersion( developmentVersion );
+        
+        // Create a config containing values from the system properties (command line properties).
+        ReleaseDescriptor sysPropertiesConfig = ReleaseUtils.copyPropertiesToReleaseDescriptor(
System.getProperties() );
+        mergeCommandLineConfig( config, sysPropertiesConfig );
+        
         try
         {
             releaseManager.prepare( config, settings, reactorProjects, resume, dryRun );
@@ -142,6 +164,26 @@
         catch ( ReleaseFailureException e )
         {
             throw new MojoFailureException( e.getMessage() );
+        }
+    }
+
+    /**
+     * This method takes some of the release configuration picked up from the command line
+     * system properties and copies it into the release config object.
+     * 
+     * @param config
+     * @param sysPropertiesConfig
+     */
+    private void mergeCommandLineConfig( ReleaseDescriptor config, ReleaseDescriptor sysPropertiesConfig
)
+    {
+        // If the user specifies versions on the 
+        if ( sysPropertiesConfig.getReleaseVersions() != null )
+        {
+            config.getReleaseVersions().putAll( sysPropertiesConfig.getReleaseVersions()
);
+        }
+        if ( sysPropertiesConfig.getDevelopmentVersions() != null )
+        {
+            config.getDevelopmentVersions().putAll( sysPropertiesConfig.getDevelopmentVersions()
);
         }
     }
 

Modified: maven/release/trunk/maven-release-plugin/src/site/apt/examples/non-interactive-release.apt
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/site/apt/examples/non-interactive-release.apt?rev=651435&r1=651434&r2=651435&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/site/apt/examples/non-interactive-release.apt
(original)
+++ maven/release/trunk/maven-release-plugin/src/site/apt/examples/non-interactive-release.apt
Thu Apr 24 14:46:34 2008
@@ -47,14 +47,20 @@
   for the release version, the scm tag, and the next development version.  These values can
also
   be set from the command line.
 
-  The scm tag name can be set using the <<<tag>>> property.
+  The scm tag name can be set using the <<<tag>>> property.  And default
values for the release version
+  and new development version can be set using the properties <<<releaseVersion>>>
and
+  <<<developmentVersion>>> respectively.
   
 -----------
-mvn --batch-mode -Dtag=my-proj-1.2 release:prepare
+mvn --batch-mode -Dtag=my-proj-1.2 release:prepare \
+                 -DreleaseVersion=1.2 \
+                 -DdevelopmentVersion=2.0-SNAPSHOT
 -----------
 
+* Multi-module releases
+
   Because there is the possibility that a release will include multiple release versions
and 
-  snapshot versions (for a multi-module project), there is a special format for setting these

+  snapshot versions (for a multi-module project), there is a specific format for setting
these 
   values.  The property name should start with <<<project.rel>>> for release
versions and 
   <<<project.dev>>> for the new development version.  These prefixes are
followed by the 
   maven groupId and artifactId (separated by a colon).  So the result looks something like

@@ -67,6 +73,11 @@
 
   Using this convention, multiple release versions and snapshot versions (one for each
   project module) can be specified on the command line.
+  
+  These properties can be used in combination with the <<<releaseVersion>>>
and
+  <<<developmentVersion>>>.  In the case where both are used, <<<releaseVersion>>>
and
+  <<<developmentVersion>>> act as defaults for modules that have not been
given specific
+  values using the <<<groupId:artifactId>>> format.
   
   
 * Using a properties file



Mime
View raw message