You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/08/03 04:36:23 UTC

svn commit: r227148 [1/2] - in /maven/components/trunk/maven-plugins/maven-release-plugin: ./ src/main/java/org/apache/maven/plugin/release/ src/main/java/org/apache/maven/plugin/scm/ src/main/java/org/apache/maven/plugin/transformer/ src/main/java/org...

Author: jdcasey
Date: Tue Aug  2 19:36:14 2005
New Revision: 227148

URL: http://svn.apache.org/viewcvs?rev=227148&view=rev
Log:
Working on: MNG-662

o Moved release.properties management to a helper class
o Created a helper class for caching/prompting for project-versions
o Created a helper class for managing SCM info updates during the release:prepare process
o Moved as many of the shared fields out of AbstractReleaseMojo as possible, given the refactor to reactorized processing
o Refactored the PrepareReleaseMojo to process a list of projects, and resolve inter-dependencies during transforms, etc.
o Refactored the PerformReleaseMojo to adjust to the new helper classes.
o Removed the old transformers, since MavenProject.writeOriginalModel() can be used instead, using the modello writer
o Bumped the maven-scm versions up to 1.0-alpha-2-SNAPSHOT, and added maven-scm-manager-plexus.


Added:
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/
      - copied from r226726, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
      - copied, changed from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/AbstractReleaseMojo.java
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
      - copied, changed from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PerformReleaseMojo.java
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
      - copied, changed from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PrepareReleaseMojo.java
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java   (with props)
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java   (with props)
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java   (with props)
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java   (with props)
Removed:
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/scm/ScmBean.java
    maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/transformer/
Modified:
    maven/components/trunk/maven-plugins/maven-release-plugin/pom.xml

Modified: maven/components/trunk/maven-plugins/maven-release-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/pom.xml?rev=227148&r1=227147&r2=227148&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/pom.xml Tue Aug  2 19:36:14 2005
@@ -13,33 +13,38 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0-beta-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact-manager</artifactId>
+      <version>2.0-beta-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
       <version>2.0-beta-1-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
       <artifactId>maven-scm-api</artifactId>
-      <version>1.0-alpha-1</version>
+      <version>1.0-alpha-2-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
-      <artifactId>maven-scm-provider-cvs</artifactId>
-      <version>1.0-alpha-1</version>
+      <artifactId>maven-scm-manager-plexus</artifactId>
+      <version>1.0-alpha-2-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
-      <artifactId>maven-scm-provider-svn</artifactId>
-      <version>1.0-alpha-1</version>
-    </dependency>
-    <dependency>
-      <groupId>dom4j</groupId>
-      <artifactId>dom4j</artifactId>
-      <version>1.4-dev-8</version>
+      <artifactId>maven-scm-provider-cvs</artifactId>
+      <version>1.0-alpha-2-SNAPSHOT</version>
     </dependency>
     <dependency>
-      <groupId>jaxen</groupId>
-      <artifactId>jaxen</artifactId>
-      <version>1.0-FCS</version>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-provider-svn</artifactId>
+      <version>1.0-alpha-2-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>plexus</groupId>

Copied: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java (from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/AbstractReleaseMojo.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java?p2=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java&p1=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/AbstractReleaseMojo.java&r1=227145&r2=227148&rev=227148&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/AbstractReleaseMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java Tue Aug  2 19:36:14 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.release;
+package org.apache.maven.plugins.release;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -18,147 +18,59 @@
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.scm.ScmBean;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
+import org.apache.maven.plugins.release.helpers.ScmHelper;
 import org.apache.maven.scm.manager.ScmManager;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-
 /**
  * 
+ * @author <a href="mailto:jdcasey@apache.org">John Casey</a>
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
- * @version $Id: DoxiaMojo.java 169372 2005-05-09 22:47:34Z evenisse $
+ * @version $Id$
  */
 public abstract class AbstractReleaseMojo
     extends AbstractMojo
 {
-    public static final String RELEASE_PROPS = "release.properties";
-
-    public static final String USERNAME = "maven.username";
-
-    public static final String TAG = "tag";
-
-    public static final String SCM_URL = "scm.url";
-
-    /**
-     * @parameter expression="${project.build.directory}/checkout"
-     * @required
-     */
-    protected String workingDirectory;
-
-    /**
-     * @parameter expression="${project.scm.developerConnection}"
-     * @required
-     */
-    protected String urlScm;
-
-    /**
-     * @parameter expression="${maven.username}"
-     */
-    protected String username;
-
-    /**
-     * @parameter expression="${password}"
-     */
-    protected String password;
-
-    /**
-     * @parameter expression="${tagBase}"
-     */
-    protected String tagBase = "../tags";
-
-    /**
-     * @parameter expression="${tag}"
-     */
-    protected String tag;
-
-    /**
-     * @parameter expression="${project}"
-     * @required
-     * @readonly
-     */
-    protected MavenProject project;
-
     /**
      * @parameter expression="${org.apache.maven.scm.manager.ScmManager}"
      * @required
      * @readonly
      */
-    protected ScmManager scmManager;
+    private ScmManager scmManager;
 
-    private Properties releaseProperties;
+    private ScmHelper scmHelper;
 
-    protected ScmBean getScm()
-    {
-        ScmBean scm = new ScmBean();
-
-        scm.setScmManager( scmManager );
+    protected abstract ReleaseProgressTracker getReleaseProgress()
+        throws MojoExecutionException;
 
-        if ( releaseProperties != null )
+    protected ScmHelper getScm()
+        throws MojoExecutionException
+    {
+        if ( scmHelper == null )
         {
-            urlScm = releaseProperties.getProperty( SCM_URL );
-        }
-
-        scm.setUrl( urlScm );
+            scmHelper = new ScmHelper();
 
-        if ( releaseProperties != null )
-        {
-            tag = releaseProperties.getProperty( TAG );
-        }
+            scmHelper.setScmManager( scmManager );
 
-        scm.setTag( tag );
+            ReleaseProgressTracker releaseProgress = getReleaseProgress();
 
-        scm.setTagBase( tagBase );
+            scmHelper.setUrl( releaseProgress.getScmUrl() );
 
-        if ( releaseProperties != null )
-        {
-            username = releaseProperties.getProperty( USERNAME );
-        }
+            scmHelper.setTag( releaseProgress.getScmTag() );
 
-        scm.setUsername( username );
+            scmHelper.setTagBase( releaseProgress.getScmTagBase() );
 
-        scm.setPassword( password );
+            scmHelper.setUsername( releaseProgress.getUsername() );
 
-        scm.setWorkingDirectory( workingDirectory );
+            scmHelper.setPassword( releaseProgress.getPassword() );
+        }
 
-        return scm;
+        return scmHelper;
     }
 
     public void execute()
         throws MojoExecutionException
     {
-        try
-        {
-            if ( username == null )
-            {
-                username = System.getProperty( "user.name" );
-            }
-
-            // ----------------------------------------------------------------------
-            // The release properties file has been created by the prepare phase and
-            // wants to be shared with the perform.
-            // ----------------------------------------------------------------------
-
-            File releasePropertiesFile = new File( project.getFile().getParentFile(), RELEASE_PROPS );
-
-            if ( releasePropertiesFile.exists() )
-            {
-
-                releaseProperties = new Properties();
-
-                InputStream is = new FileInputStream( releasePropertiesFile );
-
-                releaseProperties.load( is );
-            }
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "Can't initialize ReleaseMojo.", e );
-        }
-
         executeTask();
     }
 

Copied: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java (from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PerformReleaseMojo.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java?p2=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java&p1=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PerformReleaseMojo.java&r1=227145&r2=227148&rev=227148&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PerformReleaseMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java Tue Aug  2 19:36:14 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.release;
+package org.apache.maven.plugins.release;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -17,15 +17,20 @@
  */
 
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
+import org.apache.maven.plugins.release.helpers.ScmHelper;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.DefaultConsumer;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
+import java.io.IOException;
+
 /**
  * Perform a release from SCM
  *
+ * @aggregator
  * @goal perform
  *
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -35,10 +40,25 @@
     extends AbstractReleaseMojo
 {
     /**
+     * @parameter expression="${basedir}"
+     * @required
+     * @readonly
+     */
+    private String basedir;
+
+    /**
      * @parameter expression="${goals}"
      */
     private String goals = "deploy";
 
+    /**
+     * @parameter expression="${project.build.directory}/checkout"
+     * @required
+     */
+    protected String workingDirectory;
+
+    private ReleaseProgressTracker releaseProgress;
+
     protected void executeTask()
         throws MojoExecutionException
     {
@@ -50,11 +70,15 @@
     private void checkout()
         throws MojoExecutionException
     {
-        System.out.println( "Checking out the project to perform the release ..." );
+        getLog().info( "Checking out the project to perform the release ..." );
 
         try
         {
-            getScm().checkout();
+            ScmHelper scm = getScm();
+
+            scm.setWorkingDirectory( workingDirectory );
+
+            scm.checkout();
         }
         catch ( Exception e )
         {
@@ -78,7 +102,7 @@
         cl.createArgument().setLine( goals );
 
         cl.createArgument().setLine( "-DupdateReleaseInfo=true" );
-        
+
         cl.createArgument().setLine( "--no-plugin-updates" );
 
         StreamConsumer consumer = new DefaultConsumer();
@@ -91,5 +115,24 @@
         {
             throw new MojoExecutionException( "Can't run goal " + goals, e );
         }
+    }
+
+    protected ReleaseProgressTracker getReleaseProgress()
+        throws MojoExecutionException
+    {
+        if ( releaseProgress == null )
+        {
+            try
+            {
+                releaseProgress = ReleaseProgressTracker.load( basedir );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Failed to load release information from file: "
+                    + ReleaseProgressTracker.getReleaseProgressFilename(), e );
+            }
+        }
+
+        return releaseProgress;
     }
 }

Copied: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java (from r227145, maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PrepareReleaseMojo.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?p2=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java&p1=maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PrepareReleaseMojo.java&r1=227145&r2=227148&rev=227148&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugin/release/PrepareReleaseMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java Tue Aug  2 19:36:14 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.release;
+package org.apache.maven.plugins.release;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -21,14 +21,19 @@
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.scm.ScmBean;
-import org.apache.maven.plugin.transformer.PomTransformer;
-import org.apache.maven.plugin.transformer.VersionTransformer;
+import org.apache.maven.plugins.release.helpers.ProjectScmRewriter;
+import org.apache.maven.plugins.release.helpers.ProjectVersionResolver;
+import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
+import org.apache.maven.plugins.release.helpers.ScmHelper;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFile;
@@ -38,23 +43,25 @@
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
+import java.util.Set;
 
 /**
  * Prepare for a release in SCM
  *
+ * @author <a href="mailto:jdcasey@apache.org">John Casey</a>
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id: DoxiaMojo.java 169372 2005-05-09 22:47:34Z evenisse $
+ * @version $Id$
+ * @aggregator
  * @goal prepare
  * @requiresDependencyResolution test
  * @todo check how this works with version ranges
@@ -62,6 +69,10 @@
 public class PrepareReleaseMojo
     extends AbstractReleaseMojo
 {
+    private static final String SNAPSHOT = "-SNAPSHOT";
+
+    private static final String RELEASE_POM = "release-pom.xml";
+
     /**
      * @parameter expression="${basedir}"
      * @required
@@ -96,73 +107,330 @@
      */
     private ArtifactRepository localRepository;
 
-    private static final String SNAPSHOT = "-SNAPSHOT";
+    /**
+     * @parameter expression="${reactorProjects}"
+     * @required
+     * @readonly
+     */
+    private List reactorProjects;
 
-    private static final String RELEASE_POM = "release-pom.xml";
+    /**
+     * @parameter expression="${project.scm.developerConnection}"
+     * @required
+     * @readonly
+     */
+    private String urlScm;
+
+    /**
+     * @parameter expression="${maven.username}"
+     */
+    private String username = System.getProperty( "user.name" );
 
-    private String projectVersion;
+    /**
+     * @parameter expression="${password}"
+     */
+    private String password;
 
-    private Model model;
+    /**
+     * @parameter expression="${tag}"
+     */
+    private String tag;
+
+    /**
+     * @parameter expression="${tagBase}"
+     */
+    private String tagBase = "../tags";
+
+    /**
+     * @parameter expression="${resume}"
+     */
+    private boolean resume = false;
 
     private String userTag;
 
-    private String currentTag;
+    private ReleaseProgressTracker releaseProgress;
 
-    private String currentScmConnection;
+    private ProjectVersionResolver versionResolver;
 
-    private String currentScmDeveloperConnection;
+    private ProjectScmRewriter scmRewriter;
 
     protected void executeTask()
         throws MojoExecutionException
     {
-        model = project.getModel();
+        try
+        {
+            getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_INITIALIZED );
+        }
+        catch ( IOException e )
+        {
+            getLog().warn( "Error writing checkpoint.", e );
+        }
 
-        checkForLocalModifications();
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_PREPARED_RELEASE ) )
+        {
+            checkForLocalModifications();
 
-        checkForPresenceOfSnapshots();
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
 
-        transformPomToReleaseVersionPom();
+                getVersionResolver().resolveVersion( project );
 
-        generateReleasePropertiesFile();
+                getScmRewriter().rewriteScmInfo( project, getTagLabel() );
+            }
 
-        generateReleasePom();
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
 
-        checkInReleaseVersionPom();
+                checkForPresenceOfSnapshots( project );
 
-        tagRelease();
+                transformPomToReleaseVersionPom( project );
 
-        transformPomToSnapshotVersionPom();
+                generateReleasePom( project );
+            }
 
-        new File( basedir, RELEASE_POM ).delete();
+            checkInRelease();
 
-        checkInSnapshotVersionPom();
+            tagRelease();
+
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
+
+                getVersionResolver().incrementVersion( project );
+
+                getScmRewriter().restoreScmInfo( project );
+            }
+
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
+
+                transformPomToSnapshotVersionPom( project );
+            }
+
+            removeReleasePoms();
+
+            checkInNextSnapshot();
+
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_PREPARED_RELEASE );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
+        }
     }
 
-    private void generateReleasePropertiesFile()
+    private void transformPomToSnapshotVersionPom( MavenProject project )
         throws MojoExecutionException
     {
-        try
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_POM_TRANSORMED_FOR_DEVELOPMENT ) )
         {
-            Properties releaseProperties = new Properties();
+            if ( isSnapshot( project.getVersion() ) )
+            {
+                throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion()
+                    + "). It appears that the release version has not been committed." );
+            }
 
-            releaseProperties.setProperty( "version", projectVersion );
+            Model model = project.getOriginalModel();
 
-            releaseProperties.setProperty( USERNAME, username );
+            ProjectVersionResolver versionResolver = getVersionResolver();
 
-            releaseProperties.setProperty( TAG, getTagLabel() );
+            Parent parent = model.getParent();
 
-            releaseProperties.setProperty( SCM_URL, urlScm );
+            //Rewrite parent version
+            if ( parent != null )
+            {
+                String incrementedVersion = versionResolver.getResolvedVersion( parent.getGroupId(), parent
+                    .getArtifactId() );
+
+                if ( incrementedVersion != null )
+                {
+                    parent.setVersion( incrementedVersion );
+                }
+            }
+
+            //Rewrite dependencies section
+            List dependencies = model.getDependencies();
+
+            if ( dependencies != null )
+            {
+                for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+                {
+                    Dependency dep = (Dependency) i.next();
+
+                    String version = versionResolver.getResolvedVersion( dep.getGroupId(), dep.getArtifactId() );
+
+                    if ( version != null )
+                    {
+                        dep.setVersion( version );
+                    }
+                }
+            }
 
-            FileOutputStream os = new FileOutputStream( new File( project.getFile().getParentFile(), RELEASE_PROPS ) );
+            //Rewrite plugins section
+            Build build = model.getBuild();
+
+            if ( build != null )
+            {
+                List plugins = build.getPlugins();
+
+                if ( plugins != null )
+                {
+                    for ( Iterator i = plugins.iterator(); i.hasNext(); )
+                    {
+                        Plugin plugin = (Plugin) i.next();
+
+                        String version = versionResolver.getResolvedVersion( plugin.getGroupId(), plugin
+                            .getArtifactId() );
+
+                        if ( version != null )
+                        {
+                            plugin.setVersion( version );
+                        }
+                    }
+                }
+
+                //Rewrite extensions section
+                List extensions = build.getExtensions();
+
+                for ( Iterator i = extensions.iterator(); i.hasNext(); )
+                {
+                    Extension ext = (Extension) i.next();
 
-            releaseProperties.store( os, "maven release plugin info" );
+                    String version = versionResolver.getResolvedVersion( ext.getGroupId(), ext.getArtifactId() );
+
+                    if ( version != null )
+                    {
+                        ext.setVersion( version );
+                    }
+                }
+            }
+
+            Reporting reporting = model.getReporting();
+
+            if ( reporting != null )
+            {
+                //Rewrite reports section
+                List reports = reporting.getPlugins();
+
+                if ( reports != null )
+                {
+                    for ( Iterator i = reports.iterator(); i.hasNext(); )
+                    {
+                        ReportPlugin plugin = (ReportPlugin) i.next();
+
+                        String version = versionResolver.getResolvedVersion( plugin.getGroupId(), plugin
+                            .getArtifactId() );
+
+                        if ( version != null )
+                        {
+                            plugin.setVersion( version );
+                        }
+                    }
+                }
+            }
+
+            Writer writer = null;
+
+            try
+            {
+                writer = new FileWriter( project.getFile() );
+
+                project.writeOriginalModel( writer );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Cannot write development version of pom to: " + project.getFile(), e );
+            }
+            finally
+            {
+                IOUtil.close( writer );
+            }
 
-            os.close();
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_POM_TRANSORMED_FOR_DEVELOPMENT );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
         }
-        catch ( IOException e )
+    }
+
+    protected ReleaseProgressTracker getReleaseProgress()
+        throws MojoExecutionException
+    {
+        if ( releaseProgress == null )
         {
-            throw new MojoExecutionException( "Cannote write release-version file.", e );
+            if ( resume )
+            {
+                try
+                {
+                    releaseProgress = ReleaseProgressTracker.load( basedir );
+
+                    releaseProgress.verifyResumeCapable();
+                }
+                catch ( IOException e )
+                {
+                    throw new MojoExecutionException( "Cannot read existing release progress file from directory: "
+                        + basedir + ". Cannot resume." );
+                }
+            }
+            else
+            {
+                try
+                {
+                    releaseProgress = ReleaseProgressTracker.loadOrCreate( basedir );
+                }
+                catch ( IOException e )
+                {
+                    getLog().warn(
+                                   "Cannot read existing release progress file from directory: " + basedir
+                                       + ". Creating new instance." );
+                }
+
+                releaseProgress.setUsername( username );
+
+                if ( password != null )
+                {
+                    releaseProgress.setPassword( password );
+                }
+
+                releaseProgress.setScmTag( getTagLabel() );
+
+                releaseProgress.setScmTagBase( tagBase );
+
+                releaseProgress.setScmUrl( urlScm );
+            }
         }
+
+        return releaseProgress;
+    }
+
+    protected ProjectVersionResolver getVersionResolver()
+    {
+        if ( versionResolver == null )
+        {
+            versionResolver = new ProjectVersionResolver( getLog(), inputHandler, interactive );
+        }
+
+        return versionResolver;
+    }
+
+    protected ProjectScmRewriter getScmRewriter()
+    {
+        if ( scmRewriter == null )
+        {
+            scmRewriter = new ProjectScmRewriter();
+        }
+
+        return scmRewriter;
     }
 
     private boolean isSnapshot( String version )
@@ -173,47 +441,62 @@
     private void checkForLocalModifications()
         throws MojoExecutionException
     {
-        getLog().info( "Verifying there are no local modifications ..." );
-
-        List changedFiles;
-
-        try
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_LOCAL_MODIFICATIONS_CHECKED ) )
         {
-            ScmBean scm = getScm();
+            getLog().info( "Verifying there are no local modifications ..." );
 
-            scm.setWorkingDirectory( basedir );
+            List changedFiles;
 
-            changedFiles = scm.getStatus();
-        }
-        catch ( ScmException e )
-        {
-            throw new MojoExecutionException( "An error is occurred in the status process.", e );
-        }
+            try
+            {
+                ScmHelper scm = getScm();
 
-        for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
-        {
-            ScmFile f = (ScmFile) i.next();
-            if ( f.getPath().equals( "pom.xml.backup" ) || f.getPath().equals( RELEASE_PROPS ) )
+                scm.setWorkingDirectory( basedir );
+
+                changedFiles = scm.getStatus();
+            }
+            catch ( ScmException e )
             {
-                i.remove();
+                throw new MojoExecutionException( "An error is occurred in the status process.", e );
             }
-        }
 
-        if ( !changedFiles.isEmpty() )
-        {
-            StringBuffer message = new StringBuffer();
+            String releaseProgressFilename = ReleaseProgressTracker.getReleaseProgressFilename();
 
             for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
             {
-                ScmFile file = (ScmFile) i.next();
+                ScmFile f = (ScmFile) i.next();
+                if ( f.getPath().equals( "pom.xml.backup" ) || f.getPath().equals( releaseProgressFilename ) )
+                {
+                    i.remove();
+                }
+            }
+
+            if ( !changedFiles.isEmpty() )
+            {
+                StringBuffer message = new StringBuffer();
 
-                message.append( file.toString() );
+                for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
+                {
+                    ScmFile file = (ScmFile) i.next();
+
+                    message.append( file.toString() );
+
+                    message.append( "\n" );
+                }
 
-                message.append( "\n" );
+                throw new MojoExecutionException(
+                                                  "Cannot prepare the release because you have local modifications : \n"
+                                                      + message.toString() );
             }
 
-            throw new MojoExecutionException(
-                "Cannot prepare the release because you have local modifications : \n" + message.toString() );
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_LOCAL_MODIFICATIONS_CHECKED );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
         }
     }
 
@@ -226,405 +509,538 @@
      *
      * @throws MojoExecutionException
      */
-    private void checkForPresenceOfSnapshots()
+    private void checkForPresenceOfSnapshots( MavenProject project )
         throws MojoExecutionException
     {
-        MavenProject currentProject = project;
-
-        getLog().info( "Checking lineage for snapshots ..." );
-
-        while ( currentProject.hasParent() )
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_SNAPSHOTS_CHECKED ) )
         {
-            Artifact parentArtifact = currentProject.getParentArtifact();
+            getLog().info( "Checking lineage for snapshots ..." );
 
-            if ( isSnapshot( parentArtifact.getVersion() ) )
+            MavenProject currentProject = project;
+
+            while ( currentProject.hasParent() )
             {
-                throw new MojoExecutionException( "Can't release project due to non released parent." );
-            }
+                MavenProject parentProject = currentProject.getParent();
 
-            currentProject = currentProject.getParent();
-        }
+                String parentVersion = getVersionResolver().getResolvedVersion( parentProject.getGroupId(),
+                                                                                parentProject.getArtifactId() );
 
-        getLog().info( "Checking dependencies for snapshots ..." );
+                if ( isSnapshot( parentVersion ) )
+                {
+                    throw new MojoExecutionException( "Can't release project due to non released parent." );
+                }
 
-        List snapshotDependencies = new ArrayList();
+                currentProject = parentProject;
+            }
 
-        for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
-        {
-            Artifact artifact = (Artifact) i.next();
+            getLog().info( "Checking dependencies for snapshots ..." );
 
-            if ( isSnapshot( artifact.getVersion() ) )
+            Set snapshotDependencies = new HashSet();
+
+            for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
             {
-                snapshotDependencies.add( artifact );
-            }
-        }
+                Artifact artifact = (Artifact) i.next();
 
-        getLog().info( "Checking plugins for snapshots ..." );
+                String artifactVersion = getVersionResolver().getResolvedVersion( artifact.getGroupId(),
+                                                                                  artifact.getArtifactId() );
 
-        for ( Iterator i = project.getPluginArtifacts().iterator(); i.hasNext(); )
-        {
-            Artifact artifact = (Artifact) i.next();
+                if ( artifactVersion == null )
+                {
+                    artifactVersion = artifact.getVersion();
+                }
 
-            if ( isSnapshot( artifact.getVersion() ) )
-            {
-                snapshotDependencies.add( artifact );
+                if ( isSnapshot( artifactVersion ) )
+                {
+                    snapshotDependencies.add( artifact );
+                }
             }
-        }
 
-        if ( !snapshotDependencies.isEmpty() )
-        {
-            Collections.sort( snapshotDependencies );
-
-            StringBuffer message = new StringBuffer();
+            getLog().info( "Checking plugins for snapshots ..." );
 
-            for ( Iterator i = snapshotDependencies.iterator(); i.hasNext(); )
+            for ( Iterator i = project.getPluginArtifacts().iterator(); i.hasNext(); )
             {
                 Artifact artifact = (Artifact) i.next();
 
-                message.append( "    " );
+                String artifactVersion = getVersionResolver().getResolvedVersion( artifact.getGroupId(),
+                                                                                  artifact.getArtifactId() );
 
-                message.append( artifact.getGroupId() );
+                if ( artifactVersion == null )
+                {
+                    artifactVersion = artifact.getVersion();
+                }
 
-                message.append( ":" );
+                if ( isSnapshot( artifactVersion ) )
+                {
+                    snapshotDependencies.add( artifact );
+                }
+            }
 
-                message.append( artifact.getArtifactId() );
+            if ( !snapshotDependencies.isEmpty() )
+            {
+                List snapshotsList = new ArrayList( snapshotDependencies );
 
-                message.append( ":" );
+                Collections.sort( snapshotsList );
+
+                StringBuffer message = new StringBuffer();
+
+                for ( Iterator i = snapshotsList.iterator(); i.hasNext(); )
+                {
+                    Artifact artifact = (Artifact) i.next();
 
-                message.append( artifact.getVersion() );
+                    message.append( "    " );
 
-                message.append( "\n" );
+                    message.append( artifact.getId() );
+
+                    message.append( "\n" );
+                }
+
+                throw new MojoExecutionException( "Can't release project due to non released dependencies :\n"
+                    + message.toString() );
             }
 
-            throw new MojoExecutionException(
-                "Can't release project due to non released dependencies :\n" + message.toString() );
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_SNAPSHOTS_CHECKED );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
         }
     }
 
-    private void transformPomToReleaseVersionPom()
+    private void transformPomToReleaseVersionPom( MavenProject project )
         throws MojoExecutionException
     {
-        if ( !isSnapshot( model.getVersion() ) )
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_POM_TRANSFORMED_FOR_RELEASE ) )
         {
-            throw new MojoExecutionException( "This project isn't a snapshot (" + model.getVersion() + ")." );
-        }
+            if ( !isSnapshot( project.getVersion() ) )
+            {
+                throw new MojoExecutionException( "This project isn't a snapshot (" + project.getVersion() + ")." );
+            }
 
-        //Rewrite project version
-        projectVersion = model.getVersion().substring( 0, model.getVersion().length() - SNAPSHOT.length() );
+            Model model = project.getOriginalModel();
 
-        try
-        {
-            getLog().info( "What is the new version? [" + projectVersion + "]" );
+            //Rewrite parent version
+            if ( project.hasParent() )
+            {
+                Artifact parentArtifact = project.getParentArtifact();
 
-            String inputVersion = inputHandler.readLine();
+                if ( isSnapshot( parentArtifact.getBaseVersion() ) )
+                {
+                    String version = resolveVersion( parentArtifact, "parent", project );
 
-            if ( !StringUtils.isEmpty( inputVersion ) )
-            {
-                projectVersion = inputVersion;
+                    model.getParent().setVersion( version );
+                }
             }
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "Can't read user input.", e );
-        }
 
-        model.setVersion( projectVersion );
+            //Rewrite dependencies section
+            Map artifactMap = project.getArtifactMap();
 
-        currentTag = model.getScm().getTag();
+            List dependencies = model.getDependencies();
 
-        currentScmConnection = model.getScm().getConnection();
+            if ( dependencies != null )
+            {
+                for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+                {
+                    Dependency dep = (Dependency) i.next();
 
-        currentScmDeveloperConnection = model.getScm().getDeveloperConnection();
+                    String conflictId = ArtifactUtils.artifactId( dep.getGroupId(), dep.getArtifactId(), dep.getType(),
+                                                                  dep.getClassifier(), dep.getVersion() );
 
-        if ( model.getScm() != null )
-        {
-            model.getScm().setTag( getTagLabel() );
+                    Artifact artifact = (Artifact) artifactMap.get( conflictId );
 
-            model.getScm().setConnection( rewriteScmConnection( model.getScm().getConnection(), getTagLabel() ) );
+                    String version = resolveVersion( artifact, "dependency", project );
 
-            model.getScm().setDeveloperConnection(
-                rewriteScmConnection( model.getScm().getDeveloperConnection(), getTagLabel() ) );
-        }
+                    dep.setVersion( version );
+                }
+            }
 
-        //Rewrite parent version
-        if ( project.hasParent() )
-        {
-            Artifact parentArtifact = project.getParentArtifact();
+            Build build = model.getBuild();
 
-            if ( isSnapshot( parentArtifact.getBaseVersion() ) )
+            if ( build != null )
             {
-                String version = resolveVersion( parentArtifact, "parent" );
+                //Rewrite plugins section
+                Map pluginArtifactMap = project.getPluginArtifactMap();
+
+                List plugins = build.getPlugins();
 
-                model.getParent().setVersion( version );
+                for ( Iterator i = plugins.iterator(); i.hasNext(); )
+                {
+                    Plugin plugin = (Plugin) i.next();
+
+                    String pluginId = plugin.getKey();
+
+                    Artifact artifact = (Artifact) pluginArtifactMap.get( pluginId );
+
+                    String version = resolveVersion( artifact, "plugin", project );
+
+                    plugin.setVersion( version );
+                }
+
+                //Rewrite extensions section
+                Map extensionArtifactMap = project.getExtensionArtifactMap();
+
+                List extensions = build.getExtensions();
+
+                for ( Iterator i = extensions.iterator(); i.hasNext(); )
+                {
+                    Extension ext = (Extension) i.next();
+
+                    String pluginId = ArtifactUtils.versionlessKey( ext.getGroupId(), ext.getArtifactId() );
+
+                    Artifact artifact = (Artifact) extensionArtifactMap.get( pluginId );
+
+                    String version = resolveVersion( artifact, "extension", project );
+
+                    ext.setVersion( version );
+                }
             }
-        }
 
-        //Rewrite dependencies section
-        Map artifactMap = ArtifactUtils.artifactMapByArtifactId( project.getArtifacts() );
+            Reporting reporting = model.getReporting();
 
-        for ( Iterator i = model.getDependencies().iterator(); i.hasNext(); )
-        {
-            Dependency dep = (Dependency) i.next();
+            if ( reporting != null )
+            {
+                //Rewrite reports section
+                Map reportArtifactMap = project.getReportArtifactMap();
 
-            String conflictId = ArtifactUtils.artifactId( dep.getGroupId(), dep.getArtifactId(), dep.getType(),
-                                                          dep.getClassifier(), dep.getVersion() );
+                List reports = reporting.getPlugins();
 
-            Artifact artifact = (Artifact) artifactMap.get( conflictId );
+                for ( Iterator i = reports.iterator(); i.hasNext(); )
+                {
+                    ReportPlugin plugin = (ReportPlugin) i.next();
 
-            dep.setVersion( artifact.getVersion() );
-        }
+                    String pluginId = plugin.getKey();
 
-        try
-        {
-            PomTransformer transformer = new VersionTransformer();
+                    Artifact artifact = (Artifact) reportArtifactMap.get( pluginId );
 
-            transformer.setOutputFile( project.getFile() );
+                    String version = resolveVersion( artifact, "report", project );
 
-            transformer.setProject( project.getFile() );
+                    plugin.setVersion( version );
+                }
+            }
 
-            transformer.setUpdatedModel( model );
+            Writer writer = null;
 
-            transformer.transformNodes();
+            try
+            {
+                writer = new FileWriter( project.getFile() );
 
-            transformer.write();
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "Can't transform pom to its release version form.", e );
+                project.writeOriginalModel( writer );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Cannot write released version of pom to: " + project.getFile(), e );
+            }
+            finally
+            {
+                IOUtil.close( writer );
+            }
+
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_POM_TRANSFORMED_FOR_RELEASE );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
         }
     }
 
-    private void generateReleasePom()
+    private void generateReleasePom( MavenProject project )
         throws MojoExecutionException
     {
-        MavenProject releaseProject = new MavenProject( project );
-        Model releaseModel = releaseProject.getModel();
-
-        //Rewrite parent version
-        if ( project.hasParent() )
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_GENERATED_RELEASE_POM ) )
         {
-            Artifact parentArtifact = project.getParentArtifact();
+            MavenProject releaseProject = new MavenProject( project );
+            Model releaseModel = releaseProject.getModel();
 
-            if ( isSnapshot( parentArtifact.getBaseVersion() ) )
+            //Rewrite parent version
+            if ( project.hasParent() )
             {
-                String version = resolveVersion( parentArtifact, "parent" );
+                Artifact parentArtifact = project.getParentArtifact();
 
-                model.getParent().setVersion( version );
+                if ( isSnapshot( parentArtifact.getBaseVersion() ) )
+                {
+                    String version = resolveVersion( parentArtifact, "parent", releaseProject );
+
+                    releaseModel.getParent().setVersion( version );
+                }
             }
-        }
 
-        //Rewrite dependencies section
-        List newdeps = new ArrayList();
+            Set artifacts = releaseProject.getArtifacts();
 
-        for ( Iterator i = releaseProject.getArtifacts().iterator(); i.hasNext(); )
-        {
-            Artifact artifact = (Artifact) i.next();
+            if ( artifacts != null )
+            {
+                //Rewrite dependencies section
+                List newdeps = new ArrayList();
 
-            Dependency newdep = new Dependency();
+                for ( Iterator i = releaseProject.getArtifacts().iterator(); i.hasNext(); )
+                {
+                    Artifact artifact = (Artifact) i.next();
 
-            newdep.setArtifactId( artifact.getArtifactId() );
-            newdep.setGroupId( artifact.getGroupId() );
-            newdep.setVersion( artifact.getVersion() );
-            newdep.setType( artifact.getType() );
-            newdep.setScope( artifact.getScope() );
-            newdep.setClassifier( artifact.getClassifier() );
+                    Dependency newdep = new Dependency();
 
-            newdeps.add( newdep );
-        }
+                    newdep.setArtifactId( artifact.getArtifactId() );
+                    newdep.setGroupId( artifact.getGroupId() );
+                    newdep.setVersion( artifact.getVersion() );
+                    newdep.setType( artifact.getType() );
+                    newdep.setScope( artifact.getScope() );
+                    newdep.setClassifier( artifact.getClassifier() );
 
-        releaseModel.setDependencies( newdeps );
+                    newdeps.add( newdep );
+                }
 
-        //Rewrite plugins version
-        for ( Iterator i = releaseProject.getPluginArtifacts().iterator(); i.hasNext(); )
-        {
-            Artifact artifact = (Artifact) i.next();
-            if ( isSnapshot( artifact.getBaseVersion() ) )
+                releaseModel.setDependencies( newdeps );
+            }
+
+            List plugins = releaseProject.getBuildPlugins();
+
+            if ( plugins != null )
             {
-                for ( Iterator j = releaseModel.getBuild().getPlugins().iterator(); j.hasNext(); )
+                //Rewrite plugins version
+                Map pluginArtifacts = releaseProject.getPluginArtifactMap();
+
+                for ( Iterator i = plugins.iterator(); i.hasNext(); )
                 {
-                    Plugin plugin = (Plugin) j.next();
-                    if ( ArtifactUtils.versionlessKey( artifact ).equals( plugin.getKey() ) )
-                    {
-                        String version = resolveVersion( artifact, "plugin" );
+                    Plugin plugin = (Plugin) i.next();
 
-                        plugin.setGroupId( artifact.getGroupId() );
-                        plugin.setVersion( version );
-                    }
+                    Artifact artifact = (Artifact) pluginArtifacts.get( plugin.getKey() );
+
+                    String version = resolveVersion( artifact, "plugin", releaseProject );
+
+                    plugin.setVersion( version );
                 }
             }
-        }
 
-        //Rewrite report version
-        for ( Iterator i = releaseProject.getReportArtifacts().iterator(); i.hasNext(); )
-        {
-            Artifact artifact = (Artifact) i.next();
-            if ( isSnapshot( artifact.getBaseVersion() ) )
+            List reports = releaseProject.getReportPlugins();
+
+            if ( reports != null )
             {
-                List reportPlugins = releaseProject.getReportPlugins();
+                //Rewrite report version
+                Map reportArtifacts = releaseProject.getReportArtifactMap();
 
-                if ( reportPlugins != null )
+                for ( Iterator i = reports.iterator(); i.hasNext(); )
                 {
-                    for ( Iterator j = reportPlugins.iterator(); j.hasNext(); )
-                    {
-                        ReportPlugin plugin = (ReportPlugin) j.next();
-                        if ( ArtifactUtils.versionlessKey( artifact ).equals( plugin.getKey() ) )
-                        {
-                            String version = resolveVersion( artifact, "report" );
+                    ReportPlugin plugin = (ReportPlugin) i.next();
 
-                            plugin.setGroupId( artifact.getGroupId() );
-                            plugin.setVersion( version );
-                        }
-                    }
+                    Artifact artifact = (Artifact) reportArtifacts.get( plugin.getKey() );
+
+                    String version = resolveVersion( artifact, "report", releaseProject );
+
+                    plugin.setVersion( version );
                 }
             }
-        }
 
-        File releasePomFile = new File( basedir, RELEASE_POM );
+            List extensions = releaseProject.getBuildExtensions();
 
-        Writer writer = null;
+            if ( extensions != null )
+            {
+                //Rewrite extension version
+                Map extensionArtifacts = releaseProject.getExtensionArtifactMap();
 
-        try
-        {
-            writer = new FileWriter( releasePomFile );
+                for ( Iterator i = extensions.iterator(); i.hasNext(); )
+                {
+                    Extension ext = (Extension) i.next();
 
-            releaseProject.writeModel( writer );
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "Cannot write release-pom to: " + releasePomFile, e );
-        }
-        finally
-        {
-            IOUtil.close( writer );
-        }
+                    String extensionId = ArtifactUtils.versionlessKey( ext.getGroupId(), ext.getArtifactId() );
 
-        try
-        {
-            ScmBean scm = getScm();
+                    Artifact artifact = (Artifact) extensionArtifacts.get( extensionId );
 
-            scm.setWorkingDirectory( basedir );
+                    String version = resolveVersion( artifact, "extension", releaseProject );
+
+                    ext.setVersion( version );
+                }
+            }
 
-            List scmChanges = scm.getStatus();
+            File releasePomFile = new File( basedir, RELEASE_POM );
 
-            for ( Iterator i = scmChanges.iterator(); i.hasNext(); )
+            Writer writer = null;
+
+            try
             {
-                ScmFile f = (ScmFile) i.next();
+                writer = new FileWriter( releasePomFile );
 
-                if ( f.getPath().equals( "release-pom.xml" ) && f.getStatus() != ScmFileStatus.MODIFIED )
+                releaseProject.writeModel( writer );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Cannot write release-pom to: " + releasePomFile, e );
+            }
+            finally
+            {
+                IOUtil.close( writer );
+            }
+
+            try
+            {
+                ScmHelper scm = getScm();
+
+                scm.setWorkingDirectory( basedir );
+
+                List scmChanges = scm.getStatus();
+
+                for ( Iterator i = scmChanges.iterator(); i.hasNext(); )
                 {
-                    getScm().add( RELEASE_POM );
+                    ScmFile f = (ScmFile) i.next();
+
+                    if ( f.getPath().equals( "release-pom.xml" ) && f.getStatus() != ScmFileStatus.MODIFIED )
+                    {
+                        getScm().add( RELEASE_POM );
+                    }
                 }
             }
+            catch ( ScmException e )
+            {
+                throw new MojoExecutionException( "Error updating the release-pom.xml.", e );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Error updating the release-pom.xml.", e );
+            }
+
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_GENERATED_RELEASE_POM );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
         }
-        catch ( ScmException e )
-        {
-            throw new MojoExecutionException( "Error updating the release-pom.xml.", e );
-        }
-        catch ( IOException e )
+    }
+
+    private String resolveVersion( Artifact artifact, String artifactUsage, MavenProject project )
+        throws MojoExecutionException
+    {
+        String resolvedVersion = getVersionResolver().getResolvedVersion( artifact.getGroupId(),
+                                                                          artifact.getArtifactId() );
+
+        if ( resolvedVersion == null )
         {
-            throw new MojoExecutionException( "Error updating the release-pom.xml.", e );
+            if ( artifact.getFile() == null )
+            {
+                try
+                {
+                    artifactMetadataSource
+                        .retrieve( artifact, localRepository, project.getPluginArtifactRepositories() );
+                }
+                catch ( ArtifactMetadataRetrievalException e )
+                {
+                    throw new MojoExecutionException( "Cannot resolve " + artifactUsage + ": " + artifact.getId(), e );
+                }
+            }
+
+            resolvedVersion = artifact.getVersion();
         }
+
+        return resolvedVersion;
     }
 
-    private String resolveVersion( Artifact artifact, String artifactUsage )
+    /**
+     * Check in the POM to SCM after it has been transformed where the version has been
+     * set to the release version.
+     *
+     * @throws MojoExecutionException
+     */
+    private void checkInRelease()
         throws MojoExecutionException
     {
-        if ( artifact.getFile() == null )
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_CHECKED_IN_RELEASE_VERSION ) )
         {
+            checkIn( "**/pom.xml,**/release-pom.xml", "[maven-release-plugin] prepare release" );
+
             try
             {
-                artifactMetadataSource.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() );
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_CHECKED_IN_RELEASE_VERSION );
             }
-            catch ( ArtifactMetadataRetrievalException e )
+            catch ( IOException e )
             {
-                throw new MojoExecutionException( "Cannot resolve " + artifactUsage + ": " + artifact.getId(), e );
+                getLog().warn( "Error writing checkpoint.", e );
             }
         }
-
-        return artifact.getVersion();
     }
 
-    private void transformPomToSnapshotVersionPom()
+    private void removeReleasePoms()
         throws MojoExecutionException
     {
-        // TODO: we will need to incorporate versioning strategies here because it is unlikely
-        // that everyone will be able to agree on a standard. This is extremely limited right
-        // now and really only works for the way maven is versioned.
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_REMOVED_RELEASE_POM ) )
+        {
+            File currentReleasePomFile = null;
 
-        // releaseVersion = 1.0-beta-4
-        // snapshotVersion = 1.0-beta-5-SNAPSHOT
+            try
+            {
+                String canonicalBasedir = trimPathForScmCalculation( new File( basedir ) );
 
-        String nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "-" ) + 1 );
+                for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+                {
+                    MavenProject project = (MavenProject) it.next();
 
-        try
-        {
-            nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 );
+                    currentReleasePomFile = new File( project.getFile().getParentFile(), RELEASE_POM );
 
-            projectVersion = projectVersion.substring( 0, projectVersion.lastIndexOf( "-" ) + 1 ) + nextVersionString +
-                SNAPSHOT;
-        }
-        catch ( NumberFormatException e )
-        {
-            projectVersion = "";
-        }
+                    String releasePom = trimPathForScmCalculation( currentReleasePomFile );
 
-        try
-        {
-            getLog().info( "What is the new version? [" + projectVersion + "]" );
+                    releasePom = releasePom.substring( canonicalBasedir.length() );
 
-            String inputVersion = inputHandler.readLine();
+                    getScm().remove( "Removing for next development iteration.", releasePom );
 
-            if ( !StringUtils.isEmpty( inputVersion ) )
+                    currentReleasePomFile.delete();
+                }
+            }
+            catch ( ScmException e )
             {
-                projectVersion = inputVersion;
+                throw new MojoExecutionException( "Cannot remove " + currentReleasePomFile + " from development HEAD.",
+                                                  e );
             }
-
-            model.setVersion( projectVersion );
-
-            if ( model.getScm() != null )
+            catch ( IOException e )
             {
-                model.getScm().setTag( currentTag );
-
-                model.getScm().setConnection( currentScmConnection );
-
-                model.getScm().setDeveloperConnection( currentScmDeveloperConnection );
+                throw new MojoExecutionException( "Cannot remove " + currentReleasePomFile + " from development HEAD.",
+                                                  e );
             }
 
-            PomTransformer transformer = new VersionTransformer();
-
-            transformer.setOutputFile( project.getFile() );
-
-            transformer.setProject( project.getFile() );
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_REMOVED_RELEASE_POM );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
+        }
+    }
 
-            transformer.setUpdatedModel( model );
+    private String trimPathForScmCalculation( File file )
+        throws IOException
+    {
+        String path = file.getCanonicalPath();
 
-            transformer.transformNodes();
+        path.replace( File.separatorChar, '/' );
 
-            transformer.write();
-        }
-        catch ( Exception e )
+        if ( path.endsWith( "/" ) )
         {
-            throw new MojoExecutionException( "Can't transform pom to its snapshot version form.", e );
+            path = path.substring( path.length() - 1 );
         }
-    }
-
 
-    /**
-     * Check in the POM to SCM after it has been transformed where the version has been
-     * set to the release version.
-     *
-     * @throws MojoExecutionException
-     */
-    private void checkInReleaseVersionPom()
-        throws MojoExecutionException
-    {
-        checkIn( "pom.xml,release-pom.xml", "[maven-release-plugin] prepare release " + projectVersion );
+        return path;
     }
 
-    private void checkInSnapshotVersionPom()
+    private void checkInNextSnapshot()
         throws MojoExecutionException
     {
-        checkIn( "pom.xml", "[maven-release-plugin] prepare for development " + projectVersion );
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_CHECKED_IN_DEVELOPMENT_VERSION ) )
+        {
+            checkIn( "**/pom.xml", "[maven-release-plugin] prepare for next development iteration" );
+
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_CHECKED_IN_DEVELOPMENT_VERSION );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
+        }
     }
 
     private void checkIn( String includePattern, String message )
@@ -632,7 +1048,7 @@
     {
         try
         {
-            ScmBean scm = getScm();
+            ScmHelper scm = getScm();
 
             scm.setWorkingDirectory( basedir );
 
@@ -651,31 +1067,16 @@
         }
     }
 
-    private String getDefaultTagLabel()
-    {
-        String tag = project.getArtifactId().toUpperCase() + "_" + projectVersion.toUpperCase();
-
-        tag = tag.replace( '-', '_' );
-
-        tag = tag.replace( '.', '_' );
-
-        return tag;
-    }
-
     private String getTagLabel()
         throws MojoExecutionException
     {
         if ( userTag == null )
         {
-            userTag = getDefaultTagLabel();
-
             try
             {
-                ScmBean scm = getScm();
-
-                if ( scm.getTag() == null && interactive )
+                if ( tag == null && interactive )
                 {
-                    getLog().info( "What tag name should be used? [ " + tag + " ]" );
+                    getLog().info( "What tag name should be used? " );
 
                     String inputTag = inputHandler.readLine();
 
@@ -686,7 +1087,7 @@
                 }
                 else
                 {
-                    userTag = scm.getTag();
+                    userTag = tag;
                 }
             }
             catch ( Exception e )
@@ -712,44 +1113,36 @@
     private void tagRelease()
         throws MojoExecutionException
     {
-        String tag = getTagLabel();
-
-        try
+        if ( !getReleaseProgress().reachedCheckpoint( ReleaseProgressTracker.CP_TAGGED_RELEASE ) )
         {
-            ScmBean scm = getScm();
+            String tag = getTagLabel();
 
-            scm.setWorkingDirectory( basedir );
+            try
+            {
+                ScmHelper scm = getScm();
 
-            scm.setTag( tag );
+                scm.setWorkingDirectory( basedir );
 
-            getLog().info( "Tagging release with the label " + tag + "." );
+                scm.setTag( tag );
 
-            scm.tag();
-        }
-        catch ( Exception e )
-        {
-            throw new MojoExecutionException( "An error is occurred in the tag process.", e );
-        }
-    }
+                getLog().info( "Tagging release with the label " + tag + "." );
 
-    private String rewriteScmConnection( String scmConnection, String tag )
-    {
-        if ( scmConnection != null )
-        {
-            if ( scmConnection.startsWith( "svn" ) )
+                scm.tag();
+            }
+            catch ( Exception e )
             {
-                if ( scmConnection.endsWith( "trunk/" ) )
-                {
-                    scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() );
-                }
-                if ( scmConnection.endsWith( "branches/" ) )
-                {
-                    scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() );
-                }
-                scmConnection += "tags/" + tag;
+                throw new MojoExecutionException( "An error is occurred in the tag process.", e );
             }
-        }
 
-        return scmConnection;
+            try
+            {
+                getReleaseProgress().checkpoint( basedir, ReleaseProgressTracker.CP_TAGGED_RELEASE );
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( "Error writing checkpoint.", e );
+            }
+        }
     }
+
 }

Added: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java?rev=227148&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java (added)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java Tue Aug  2 19:36:14 2005
@@ -0,0 +1,122 @@
+package org.apache.maven.plugins.release.helpers;
+
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Scm;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ProjectScmRewriter
+{
+
+    private Map originalScmInformation = new HashMap();
+
+    public void rewriteScmInfo( MavenProject project, String tagLabel )
+        throws MojoExecutionException
+    {
+        String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+        if ( originalScmInformation.containsKey( projectId ) )
+        {
+            throw new IllegalArgumentException( "Project: " + projectId
+                + " already has it's original SCM info cached. Each project should only be resolved once." );
+        }
+
+        Model model = project.getModel();
+
+        Scm scm = model.getScm();
+
+        if ( scm == null )
+        {
+            throw new MojoExecutionException( "Project: " + projectId
+                + " does not have a SCM section! Cannot proceed with release." );
+        }
+
+        String tag = model.getScm().getTag();
+
+        String connection = model.getScm().getConnection();
+
+        String developerConnection = model.getScm().getDeveloperConnection();
+
+        ScmInfo info = new ScmInfo( tag, connection, developerConnection );
+
+        originalScmInformation.put( projectId, info );
+
+        scm.setTag( tagLabel );
+
+        scm.setConnection( rewriteScmConnection( connection, tagLabel ) );
+
+        scm.setDeveloperConnection( rewriteScmConnection( developerConnection, tagLabel ) );
+    }
+
+    public void restoreScmInfo( MavenProject project )
+    {
+        String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+        ScmInfo original = (ScmInfo) originalScmInformation.get( projectId );
+
+        if ( original == null )
+        {
+            throw new IllegalArgumentException( "Project \'" + projectId
+                + "\' has not had its SCM info cached. Cannot restore uncached SCM info." );
+        }
+
+        original.modify( project );
+    }
+
+    // TODO: Add other SCM types for rewriting...
+    private String rewriteScmConnection( String scmConnection, String tag )
+    {
+        if ( scmConnection != null )
+        {
+            if ( scmConnection.startsWith( "svn" ) )
+            {
+                if ( scmConnection.endsWith( "trunk/" ) )
+                {
+                    scmConnection = scmConnection.substring( 0, scmConnection.length() - "trunk/".length() );
+                }
+                if ( scmConnection.endsWith( "branches/" ) )
+                {
+                    scmConnection = scmConnection.substring( 0, scmConnection.length() - "branches/".length() );
+                }
+                scmConnection += "tags/" + tag;
+            }
+        }
+
+        return scmConnection;
+    }
+
+    private static class ScmInfo
+    {
+        private String tag;
+
+        private String connection;
+
+        private String developerConnection;
+
+        ScmInfo( String tag, String connection, String developerConnection )
+        {
+            this.tag = tag;
+            this.connection = connection;
+            this.developerConnection = developerConnection;
+        }
+
+        void modify( MavenProject project )
+        {
+            Model model = project.getModel();
+
+            if ( model.getScm() != null )
+            {
+                model.getScm().setTag( tag );
+
+                model.getScm().setConnection( connection );
+
+                model.getScm().setDeveloperConnection( developerConnection );
+            }
+        }
+    }
+
+}

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java?rev=227148&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java (added)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java Tue Aug  2 19:36:14 2005
@@ -0,0 +1,143 @@
+package org.apache.maven.plugins.release.helpers;
+
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.components.inputhandler.InputHandler;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ProjectVersionResolver
+{
+
+    private static final String SNAPSHOT_CLASSIFIER = "-SNAPSHOT";
+
+    private Map resolvedVersions = new HashMap();
+
+    private final Log log;
+
+    private final InputHandler inputHandler;
+
+    private final boolean interactive;
+
+    public ProjectVersionResolver( Log log, InputHandler inputHandler, boolean interactive )
+    {
+        this.log = log;
+        this.inputHandler = inputHandler;
+        this.interactive = interactive;
+    }
+
+    public void resolveVersion( MavenProject project )
+        throws MojoExecutionException
+    {
+        String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+        if ( resolvedVersions.containsKey( projectId ) )
+        {
+            throw new IllegalArgumentException( "Project: " + projectId
+                + " is already resolved. Each project should only be resolved once." );
+        }
+
+        //Rewrite project version
+        String projectVersion = project.getVersion();
+
+        projectVersion = projectVersion.substring( 0, projectVersion.length() - SNAPSHOT_CLASSIFIER.length() );
+
+        if ( interactive )
+        {
+            try
+            {
+                log.info( "What is the release version for \'" + projectId + "\'? [" + projectVersion + "]" );
+
+                String inputVersion = inputHandler.readLine();
+
+                if ( !StringUtils.isEmpty( inputVersion ) )
+                {
+                    projectVersion = inputVersion;
+                }
+            }
+            catch ( Exception e )
+            {
+                throw new MojoExecutionException( "Can't read release version from user input.", e );
+            }
+        }
+
+        project.setVersion( projectVersion );
+
+        resolvedVersions.put( projectId, projectVersion );
+    }
+
+    public String getResolvedVersion( String groupId, String artifactId )
+    {
+        String projectId = ArtifactUtils.versionlessKey( groupId, artifactId );
+
+        return (String) resolvedVersions.get( projectId );
+    }
+
+    public void incrementVersion( MavenProject project )
+        throws MojoExecutionException
+    {
+        String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+        String projectVersion = (String) resolvedVersions.get( projectId );
+
+        if ( projectVersion == null )
+        {
+            throw new IllegalArgumentException( "Project \'" + projectId
+                + "\' has not been resolved. Cannot increment an unresolved version." );
+        }
+
+        // TODO: we will need to incorporate versioning strategies here because it is unlikely
+        // that everyone will be able to agree on a standard. This is extremely limited right
+        // now and really only works for the way maven is versioned.
+
+        // releaseVersion = 1.0-beta-4
+        // snapshotVersion = 1.0-beta-5-SNAPSHOT
+
+        String nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "-" ) + 1 );
+
+        try
+        {
+            nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 );
+
+            projectVersion = projectVersion.substring( 0, projectVersion.lastIndexOf( "-" ) + 1 ) + nextVersionString
+                + SNAPSHOT_CLASSIFIER;
+        }
+        catch ( NumberFormatException e )
+        {
+            projectVersion = "";
+        }
+
+        if ( interactive )
+        {
+            try
+            {
+                log.info( "What is the new development version for \'" + projectId + "\'? [" + projectVersion + "]" );
+
+                String inputVersion = inputHandler.readLine();
+
+                if ( !StringUtils.isEmpty( inputVersion ) )
+                {
+                    projectVersion = inputVersion;
+                }
+
+                project.setVersion( projectVersion );
+
+                resolvedVersions.put( projectId, projectVersion );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Can't read next development version from user input.", e );
+            }
+        }
+        else if ( "".equals( projectVersion ) )
+        {
+            throw new MojoExecutionException( "Cannot determine incremented development version for: " + projectId );
+        }
+    }
+
+}

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java?rev=227148&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java (added)
+++ maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java Tue Aug  2 19:36:14 2005
@@ -0,0 +1,240 @@
+package org.apache.maven.plugins.release.helpers;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Properties;
+
+public class ReleaseProgressTracker
+{
+
+    private static final String RELEASE_PROPERTIES = "release.properties";
+
+    private static final String USERNAME = "maven.username";
+
+    private static final String SCM_TAG = "scm.tag";
+
+    private static final String SCM_URL = "scm.url";
+
+    private static final String SCM_TAG_BASE = "scm.tag-base";
+
+    private static final String SCM_PASSWORD = "scm.password";
+
+    private static final String CHECKPOINT_PREFIX = "checkpoint.";
+
+    public static final String CP_INITIALIZED = "initialized";
+
+    public static final String CP_LOCAL_MODIFICATIONS_CHECKED = "local-modifications-checked";
+
+    public static final String CP_SNAPSHOTS_CHECKED = "snapshots-checked";
+
+    public static final String CP_POM_TRANSFORMED_FOR_RELEASE = "transformed-pom-for-release";
+
+    public static final String CP_GENERATED_RELEASE_POM = "generated-release-pom";
+
+    public static final String CP_CHECKED_IN_RELEASE_VERSION = "checked-in-release-version";
+
+    public static final String CP_TAGGED_RELEASE = "tagged-release";
+
+    public static final String CP_POM_TRANSORMED_FOR_DEVELOPMENT = "transform-pom-for-development";
+
+    public static final String CP_REMOVED_RELEASE_POM = "removed-release-pom";
+
+    public static final String CP_CHECKED_IN_DEVELOPMENT_VERSION = "check-in-development-version";
+
+    public static final String CP_PREPARED_RELEASE = "prepared-release";
+
+    private Properties releaseProperties;
+
+    private ReleaseProgressTracker()
+    {
+    }
+
+    public static ReleaseProgressTracker loadOrCreate( String basedir )
+        throws IOException
+    {
+        ReleaseProgressTracker tracker = null;
+
+        if ( new File( basedir, RELEASE_PROPERTIES ).exists() )
+        {
+            tracker = load( basedir );
+        }
+        else
+        {
+            tracker = new ReleaseProgressTracker();
+        }
+
+        return tracker;
+    }
+
+    public static ReleaseProgressTracker load( String basedir )
+        throws IOException
+    {
+        File releasePropertiesFile = new File( basedir, RELEASE_PROPERTIES );
+
+        ReleaseProgressTracker tracker = new ReleaseProgressTracker();
+
+        InputStream inStream = null;
+
+        try
+        {
+            inStream = new FileInputStream( releasePropertiesFile );
+
+            Properties rp = new Properties();
+
+            rp.load( inStream );
+
+            tracker.releaseProperties = rp;
+        }
+        finally
+        {
+            IOUtil.close( inStream );
+        }
+
+        return tracker;
+    }
+
+    public static String getReleaseProgressFilename()
+    {
+        return RELEASE_PROPERTIES;
+    }
+
+    private void checkInitialized()
+    {
+        if ( releaseProperties == null )
+        {
+            releaseProperties = new Properties();
+        }
+    }
+
+    private void checkLoaded()
+    {
+        if ( releaseProperties == null )
+        {
+            throw new IllegalStateException( "You must load this instance before reading from it." );
+        }
+    }
+
+    public void setUsername( String username )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( USERNAME, username );
+    }
+
+    public String getUsername()
+    {
+        checkLoaded();
+
+        return releaseProperties.getProperty( USERNAME );
+    }
+
+    public void setScmTag( String scmTag )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( SCM_TAG, scmTag );
+    }
+
+    public String getScmTag()
+    {
+        checkLoaded();
+
+        return releaseProperties.getProperty( SCM_TAG );
+    }
+
+    public void setScmUrl( String scmUrl )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( SCM_URL, scmUrl );
+    }
+
+    public String getScmUrl()
+    {
+        checkLoaded();
+
+        return releaseProperties.getProperty( SCM_URL );
+    }
+
+    public void setScmTagBase( String tagBase )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( SCM_TAG_BASE, tagBase );
+    }
+
+    public String getScmTagBase()
+    {
+        checkLoaded();
+
+        return releaseProperties.getProperty( SCM_TAG_BASE );
+    }
+
+    public void setPassword( String password )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( SCM_PASSWORD, password );
+    }
+
+    public String getPassword()
+    {
+        checkInitialized();
+
+        return releaseProperties.getProperty( SCM_PASSWORD );
+    }
+
+    public void verifyResumeCapable()
+        throws MojoExecutionException
+    {
+        if ( getUsername() == null || getScmTag() == null || getScmTagBase() == null || getScmUrl() == null )
+        {
+            throw new MojoExecutionException( "Missing release preparation information. Failed to resume" );
+        }
+    }
+
+    public void checkpoint( String basedir, String pointName )
+        throws IOException
+    {
+        setCheckpoint( pointName );
+
+        File releasePropertiesFile = new File( basedir, RELEASE_PROPERTIES );
+
+        FileOutputStream outStream = null;
+
+        try
+        {
+            outStream = new FileOutputStream( releasePropertiesFile );
+
+            releaseProperties.store( outStream, "Generated by Release Plugin on: " + new Date() );
+        }
+        finally
+        {
+            IOUtil.close( outStream );
+        }
+    }
+
+    private void setCheckpoint( String pointName )
+    {
+        checkInitialized();
+
+        releaseProperties.setProperty( CHECKPOINT_PREFIX + pointName, "OK" );
+    }
+
+    public boolean reachedCheckpoint( String pointName )
+    {
+        checkLoaded();
+
+        return "OK".equals( releaseProperties.getProperty( CHECKPOINT_PREFIX + pointName ) );
+    }
+
+}

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org