maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r345919 - in /maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release: ./ helpers/
Date Mon, 21 Nov 2005 15:59:19 GMT
Author: evenisse
Date: Mon Nov 21 07:59:12 2005
New Revision: 345919

URL: http://svn.apache.org/viewcvs?rev=345919&view=rev
Log:
PR: MNG-887
Submitted by: David Hawkins

The user is now prompted with a default release tag name. The default tag name is the artifactId-releaseVersion
of the first project in reactor projects. The first project is assumed to be the single project
being released or the parent project of a multi-module build.

The release plugin now checks for modified files _before_ prompting the user to enter a tag
name for the release. I found it odd that the plugin would build the project, test it, prompt
you for a release tag and then bomb because of local modifications. Now it will bomb due to
modified files as soon as possible.

developerConnection is now an optional configuration parameter. If developerConnection is
not specified in the Model, the project.scm.connection will be used. If that is also null,
a MojoExecutionException is thrown. This allows a pom to specify a scm.connection and have
the release plugin use that value if a developerConnection is not specified. This could be
a topic of debate but my opinion is that it is probably a very common case where the scm.developerConnection
and the scm.connection are the exact same value. Why force the user to specify both when we
can default to scm.connection if there is no need to differentiate?

release:perform now passes along the -Dmaven.test.skip parameter to the child mvn process
if specified. While its clearly not a recommended pattern to use, the people who need it,
need it here as well.

Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
Mon Nov 21 07:59:12 2005
@@ -84,6 +84,8 @@
     private String releasePom;
 
     private ReleaseProgressTracker releaseProgress;
+    
+    private final static String MAVEN_TEST_SKIP = "maven.test.skip";
 
     public void execute()
         throws MojoExecutionException
@@ -142,6 +144,11 @@
         {
             cl.createArgument().setLine( "--batch-mode" );
         }
+        
+        if ( StringUtils.isNotEmpty( System.getProperty( MAVEN_TEST_SKIP ) ) )
+        {
+            cl.createArgument().setLine( "-D" + MAVEN_TEST_SKIP + "=" + System.getProperty(
MAVEN_TEST_SKIP ) );
+        }
 
         if ( StringUtils.isEmpty( releasePom ) )
         {
@@ -233,7 +240,7 @@
         {
             try
             {
-                releaseProgress = ReleaseProgressTracker.load( basedir.getAbsolutePath()
);
+                releaseProgress = ReleaseProgressTracker.load( basedir );
             }
             catch ( IOException e )
             {

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
Mon Nov 21 07:59:12 2005
@@ -2,13 +2,13 @@
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,6 +42,7 @@
 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.plugins.release.versions.VersionInfo;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ModelUtils;
 import org.apache.maven.project.path.PathTranslator;
@@ -128,7 +129,6 @@
 
     /**
      * @parameter expression="${project.scm.developerConnection}"
-     * @required
      * @readonly
      */
     private String urlScm;
@@ -181,17 +181,42 @@
 
     private ProjectScmRewriter scmRewriter;
 
-    public void execute()
-        throws MojoExecutionException, MojoFailureException
+    private void validateConfiguration()
+        throws MojoExecutionException
+    {
+        if ( StringUtils.isEmpty( urlScm ) )
+        {
+            Model model = ((MavenProject) reactorProjects.get(0)).getModel();
+            if ( model.getScm() != null )
+            {
+                urlScm = model.getScm().getConnection();
+                if ( StringUtils.isEmpty( urlScm ) )
+                {
+                    throw new MojoExecutionException("Missing required setting: scm connection
or developerConnection must be specified.");
+                }
+            }
+        }
+    }
+
+    private void checkpoint( String pointName )
+        throws MojoExecutionException
     {
         try
         {
-            getReleaseProgress().checkpoint( basedir.getAbsolutePath(), ReleaseProgressTracker.CP_INITIALIZED
);
+            getReleaseProgress().checkpoint( pointName );
         }
         catch ( IOException e )
         {
             getLog().warn( "Error writing checkpoint.", e );
         }
+    }
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        validateConfiguration();
+  
+        checkpoint( ReleaseProgressTracker.CP_INITIALIZED );
 
         if ( !getReleaseProgress().verifyCheckpoint( ReleaseProgressTracker.CP_PREPARED_RELEASE
) )
         {
@@ -209,8 +234,8 @@
 
                     if ( !ArtifactUtils.isSnapshot( project.getVersion() ) )
                     {
-                        throw new MojoExecutionException( "The project " + project.getGroupId()
+ ":" +
-                            project.getArtifactId() + " isn't a snapshot (" + project.getVersion()
+ ")." );
+                        throw new MojoExecutionException( "The project " + projectId + "
isn't a snapshot ("
+                            + project.getVersion() + ")." );
                     }
 
                     getVersionResolver().resolveVersion( project.getOriginalModel(), projectId
);
@@ -221,16 +246,7 @@
                                                      project.getPluginArtifactRepositories()
);
                 }
 
-                try
-                {
-                    getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                     ReleaseProgressTracker.CP_POM_TRANSFORMED_FOR_RELEASE
);
-                }
-                catch ( IOException e )
-                {
-                    getLog().warn( "Error writing checkpoint.", e );
-                }
-
+                checkpoint( ReleaseProgressTracker.CP_POM_TRANSFORMED_FOR_RELEASE );
             }
 
             if ( generateReleasePoms )
@@ -258,15 +274,7 @@
                     transformPomToSnapshotVersionPom( model, project.getFile() );
                 }
 
-                try
-                {
-                    getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                     ReleaseProgressTracker.CP_POM_TRANSORMED_FOR_DEVELOPMENT
);
-                }
-                catch ( IOException e )
-                {
-                    getLog().warn( "Error writing checkpoint.", e );
-                }
+                checkpoint( ReleaseProgressTracker.CP_POM_TRANSORMED_FOR_DEVELOPMENT );
             }
 
             if ( generateReleasePoms )
@@ -276,15 +284,7 @@
 
             checkInNextSnapshot();
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                 ReleaseProgressTracker.CP_PREPARED_RELEASE
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_PREPARED_RELEASE );
         }
     }
 
@@ -400,7 +400,7 @@
         {
             try
             {
-                releaseProgress = ReleaseProgressTracker.loadOrCreate( basedir.getAbsolutePath()
);
+                releaseProgress = ReleaseProgressTracker.loadOrCreate( basedir );
             }
             catch ( IOException e )
             {
@@ -408,7 +408,7 @@
                     "Cannot read existing release progress file from directory: " + basedir.getAbsolutePath()
+ "." );
                 getLog().debug( "Cause", e );
 
-                releaseProgress = ReleaseProgressTracker.create();
+                releaseProgress = ReleaseProgressTracker.create( basedir );
             }
 
             if ( resume )
@@ -416,6 +416,11 @@
                 releaseProgress.setResumeAtCheckpoint( true );
             }
 
+            if ( releaseProgress.getScmUrl() == null )
+            {
+                releaseProgress.setScmUrl( urlScm );
+            }
+
             if ( releaseProgress.getUsername() == null )
             {
                 if ( username == null )
@@ -430,23 +435,12 @@
                 releaseProgress.setPassword( password );
             }
 
-            if ( releaseProgress.getScmTag() == null )
-            {
-                releaseProgress.setScmTag( getTagLabel() );
-            }
-
             if ( releaseProgress.getScmTagBase() == null )
             {
                 releaseProgress.setScmTagBase( tagBase );
             }
 
-            if ( releaseProgress.getScmUrl() == null )
-            {
-                releaseProgress.setScmUrl( urlScm );
-            }
-
-            if ( releaseProgress.getUsername() == null || releaseProgress.getScmTag() ==
null ||
-                 releaseProgress.getScmUrl() == null )
+            if ( releaseProgress.getUsername() == null || releaseProgress.getScmUrl() ==
null )
             {
                 throw new MojoExecutionException( "Missing release preparation information."
);
             }
@@ -523,15 +517,7 @@
                     "Cannot prepare the release because you have local modifications : \n"
+ message );
             }
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                 ReleaseProgressTracker.CP_LOCAL_MODIFICATIONS_CHECKED
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_LOCAL_MODIFICATIONS_CHECKED );
         }
     }
 
@@ -859,21 +845,21 @@
                 releaseModel.setParent( null );
 
                 Set artifacts = releaseProject.getArtifacts();
-                
+
                 if ( artifacts != null )
                 {
                     //Rewrite dependencies section
                     List newdeps = new ArrayList();
 
                     Map oldDeps = new HashMap();
-                    
+
                     List deps = releaseProject.getDependencies();
                     if ( deps != null )
                     {
                         for ( Iterator depIterator = deps.iterator(); depIterator.hasNext();
)
                         {
                             Dependency dep = (Dependency) depIterator.next();
-                            
+
                             oldDeps.put( ArtifactUtils.artifactId( dep.getGroupId(), dep.getArtifactId(),
dep.getType(), dep.getVersion() ), dep );
                         }
                     }
@@ -881,7 +867,7 @@
                     for ( Iterator i = releaseProject.getArtifacts().iterator(); i.hasNext();
)
                     {
                         Artifact artifact = (Artifact) i.next();
-                        
+
                         String key = artifact.getId();
 
                         Dependency newdep = new Dependency();
@@ -906,9 +892,9 @@
                         newdep.setType( artifact.getType() );
                         newdep.setScope( artifact.getScope() );
                         newdep.setClassifier( artifact.getClassifier() );
-                        
+
                         Dependency old = (Dependency) oldDeps.get( key );
-                        
+
                         if ( old != null )
                         {
                             newdep.setSystemPath( old.getSystemPath() );
@@ -1074,15 +1060,7 @@
                     throw new MojoExecutionException( "Error adding the release-pom.xml:
" + releasePomFile, e );
                 }
 
-                try
-                {
-                    getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                     ReleaseProgressTracker.CP_GENERATED_RELEASE_POM
);
-                }
-                catch ( IOException e )
-                {
-                    getLog().warn( "Error writing checkpoint.", e );
-                }
+                checkpoint( ReleaseProgressTracker.CP_GENERATED_RELEASE_POM );
             }
         }
     }
@@ -1205,15 +1183,7 @@
 
             checkIn( "[maven-release-plugin] prepare release " + getTagLabel() );
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                 ReleaseProgressTracker.CP_CHECKED_IN_RELEASE_VERSION
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_CHECKED_IN_RELEASE_VERSION );
         }
     }
 
@@ -1258,15 +1228,7 @@
                                                   e );
             }
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                 ReleaseProgressTracker.CP_REMOVED_RELEASE_POM
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_REMOVED_RELEASE_POM );
         }
     }
 
@@ -1294,15 +1256,7 @@
 
             checkIn( "[maven-release-plugin] prepare for next development iteration" );
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(),
-                                                 ReleaseProgressTracker.CP_CHECKED_IN_DEVELOPMENT_VERSION
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_CHECKED_IN_DEVELOPMENT_VERSION );
         }
     }
 
@@ -1328,43 +1282,137 @@
         scm.setTag( tag );
     }
 
+    /** Creates a default tag name to suggest when prompting the user for a release tag name.
+     * The tag name returned is the artifactId-resolvedVersion from the first project
+     * in the reactorProjects list.
+     * 
+     * Returns null if unable to determine a default tag name.
+     * 
+     * @return
+     * @throws MojoExecutionException
+     */
+    private String getDefaultReleaseTag()
+        throws MojoExecutionException
+    {
+        MavenProject project = null;
+        if ( reactorProjects.size() == 0 ) {
+            return null;
+        }
+
+        project = (MavenProject) reactorProjects.get(0);
+        for (int i = 1; i < reactorProjects.size(); i++ )
+        {
+            if (! ((MavenProject) reactorProjects.get( i ) ).getParent().equals( project
))
+            {
+                // We have multiple projects, some of which are not descendants of the 0th
project in the list.
+                // rather than guess which one we should use for a default tag name, just
return null
+                return null;
+            }
+        }
+
+        try {
+            String version =
+                getVersionResolver().getResolvedVersion( project.getGroupId(), project.getArtifactId()
);
+
+            if ( version == null )
+            {
+                VersionInfo info = getVersionResolver().getVersionInfo( project.getVersion()
);
+                if ( info != null )
+                {
+                    version = info.getReleaseVersionString();
+                }
+            }
+
+            String defaultTag = project.getArtifactId() + "-" + version;
+
+            ScmHelper scm = getScm( basedir.getAbsolutePath() );
+            String provider = scm.getProvider();
+
+            // Really each of the scm providers should support something which returns the
supported
+            // characters & lengths supported in tag names.  For now, we'll just assume
that CVS is the
+            // only one with the problem with periods.
+            if ( "cvs".equals(provider) ) {
+                defaultTag = defaultTag.replace('.', '_');
+            }
+
+            return defaultTag;
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException("Unable to determine scm repository provider",
e);
+        }
+    }
+
+    /** Returns the tag name to be used when tagging the release in the scm repository.
+     * <p>
+     * If the userTag is already assigned, that value is returned.
+     * Else if the releaseProperties already has the value, then use that value.
+     * Else if we are interactive then prompt the user for a tag name.
+     * 
+     * @return
+     * @throws MojoExecutionException
+     */
     private String getTagLabel()
         throws MojoExecutionException
     {
         if ( userTag == null )
         {
-            try
+            if ( StringUtils.isNotEmpty( releaseProgress.getScmTag() ) )
+            {
+                userTag = releaseProgress.getScmTag();
+            }
+            else
             {
-                if ( tag == null && interactive )
+                try
                 {
-                    getLog().info( "What tag name should be used? " );
+                    if ( tag == null && interactive )
+                    {
+                        String prompt = "What tag name should be used? ";
 
-                    String inputTag = getInputHandler().readLine();
+                        String defaultTag = getDefaultReleaseTag();
 
-                    if ( !StringUtils.isEmpty( inputTag ) )
+                        if ( defaultTag != null )
+                        {
+                            prompt = prompt + "[" + defaultTag + "]";
+                        }
+
+                        getLog().info( prompt );
+
+                        String inputTag = getInputHandler().readLine();
+
+                        userTag = ( StringUtils.isEmpty( inputTag ) ) ? defaultTag : inputTag;
+                    }
+                    else
                     {
-                        userTag = inputTag;
+                        userTag = tag;
                     }
                 }
-                else
+                catch ( IOException e )
                 {
-                    userTag = tag;
+                    throw new MojoExecutionException( "An error has occurred while reading
user input.", e );
                 }
-            }
-            catch ( IOException e )
-            {
-                throw new MojoExecutionException( "An error has occurred in the tag process.",
e );
-            }
-        }
 
-        if ( userTag == null )
-        {
-            userTag = releaseProgress.getScmTag();
+                // If we were able to get a userTag from the user, save it to our release.properties
file
+                if ( userTag != null )
+                {
+                    ReleaseProgressTracker releaseProgress = getReleaseProgress();
+                    releaseProgress.setScmTag( userTag );
+                    try
+                    {
+                        releaseProgress.store();
+                    }
+                    catch ( IOException e )
+                    {
+                        getLog().warn( "An error occurred while saving the release progress
file", e );
+                    }
+
+                }
+            }
         }
 
         if ( userTag == null )
         {
-            throw new MojoExecutionException( "A tag must be specified" );
+            throw new MojoExecutionException( "A release tag must be specified" );
         }
 
         return userTag;
@@ -1403,14 +1451,7 @@
                 throw new MojoExecutionException( "An error is occurred in the tag process.",
e );
             }
 
-            try
-            {
-                getReleaseProgress().checkpoint( basedir.getAbsolutePath(), ReleaseProgressTracker.CP_TAGGED_RELEASE
);
-            }
-            catch ( IOException e )
-            {
-                getLog().warn( "Error writing checkpoint.", e );
-            }
+            checkpoint( ReleaseProgressTracker.CP_TAGGED_RELEASE );
         }
     }
 

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectScmRewriter.java
Mon Nov 21 07:59:12 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Scm;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.scm.provider.svn.SvnTagBranchUtils;
 
 public class ProjectScmRewriter
 {
@@ -43,12 +44,24 @@
         }
     }
 
-    public void restoreScmInfo( Model model )
+    public void restoreScmInfo( Model model ) 
+        throws MojoExecutionException
     {
         Scm scm = model.getScm();
         if ( scm != null )
         {
-            String projectId = ArtifactUtils.versionlessKey( model.getGroupId(), model.getArtifactId()
);
+            String groupId = model.getGroupId();
+            if ( groupId == null && model.getParent() != null )
+            {
+                groupId = model.getParent().getGroupId();
+            }
+            
+            if ( groupId == null ) 
+            {
+                throw new MojoExecutionException("Unable to determine groupId for artifact:
" + model.getArtifactId() );
+            }
+            
+            String projectId = ArtifactUtils.versionlessKey( groupId, model.getArtifactId()
);
 
             releaseProgress.restoreScmInfo( projectId, scm );
         }
@@ -62,56 +75,21 @@
             String scmConnection = scm.getConnection();
             if ( scmConnection != null && scmConnection.startsWith( "scm:svn" ) )
             {
-                scm.setConnection( convertSvnConnectionString( scmConnection, tag ) );
+                scm.setConnection( SvnTagBranchUtils.resolveTagUrl( scmConnection, tag )
);
 
                 String devConnection = scm.getDeveloperConnection();
                 if ( devConnection != null )
                 {
-                    scm.setDeveloperConnection( convertSvnConnectionString( devConnection,
tag ) );
+                    scm.setDeveloperConnection( SvnTagBranchUtils.resolveTagUrl( devConnection,
tag ) );
                 }
 
                 String url = scm.getUrl();
                 if ( url != null )
                 {
-                    scm.setUrl( convertSvnConnectionString( url, tag ) );
+                    scm.setUrl( SvnTagBranchUtils.resolveTagUrl( url, tag ) );
                 }
             }
         }
     }
 
-    private String convertSvnConnectionString( String scmConnection, String tag )
-    {
-        int trunkBegin = scmConnection.indexOf( "/trunk" );
-
-        if ( trunkBegin >= 0 )
-        {
-            String tail = "";
-
-            if ( scmConnection.length() > trunkBegin + "/trunk".length() )
-            {
-                tail = scmConnection.substring( trunkBegin + "/trunk".length() );
-
-                if ( !tail.startsWith( "/" ) )
-                {
-                    tail += "/";
-                }
-            }
-
-            scmConnection = scmConnection.substring( 0, trunkBegin ) + "/tags/" + tag + tail;
-        }
-        else
-        {
-            int begin = scmConnection.indexOf( "/branches/" );
-            if ( begin >= 0 )
-            {
-                int end = scmConnection.indexOf( '/', begin + "/branches/".length() );
-                scmConnection = scmConnection.substring( 0, begin ) + "/tags/" + tag;
-                if ( end >= 0 && end < scmConnection.length() - 1 )
-                {
-                    scmConnection += scmConnection.substring( end );
-                }
-            }
-        }
-        return scmConnection;
-    }
 }

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ProjectVersionResolver.java
Mon Nov 21 07:59:12 2005
@@ -63,7 +63,7 @@
 
         if ( interactive )
         {
-            projectVersion = getVersionFromUser("What is the release version for \'" + projectId
+ "\'?", projectVersion);
+            projectVersion = getVersionFromUser("What is the release version for \"" + projectId
+ "\"?", projectVersion);
         } 
         else if ( StringUtils.isEmpty( projectVersion ) ) 
         {
@@ -80,7 +80,7 @@
     {
         if ( defaultVersionStr != null )
         {
-            promptText = promptText + "[" + defaultVersionStr + "]";
+            promptText = promptText + " [" + defaultVersionStr + "]";
         }
         
         try
@@ -104,13 +104,13 @@
         return (String) resolvedVersions.get( projectId );
     }
 
-    private VersionInfo getVersionInfo(String version) {
+    public VersionInfo getVersionInfo( String version ) {
         // TODO: Provide a way to override the implementation of VersionInfo
         try 
         {
             return new DefaultVersionInfo( version );
         } 
-        catch (VersionParseException e)
+        catch ( VersionParseException e )
         {
             return null;
         }
@@ -134,7 +134,7 @@
         
         if ( interactive )
         {
-            nextVersion = getVersionFromUser("What is the new development version for \'"
+ projectId + "\'?", nextVersion );            
+            nextVersion = getVersionFromUser("What is the new development version for \""
+ projectId + "\"?", nextVersion );            
         }
         else if ( nextVersion == null )
         {

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ReleaseProgressTracker.java
Mon Nov 21 07:59:12 2005
@@ -53,40 +53,48 @@
 
     private Properties releaseProperties;
 
+    private File releasePropertiesFile;
+
     private boolean resumeAtCheckpoint = false;
 
-    private ReleaseProgressTracker( Properties properties )
+    private ReleaseProgressTracker( File propertiesFile, Properties properties )
     {
+        this.releasePropertiesFile = propertiesFile;
         this.releaseProperties = properties;
     }
 
-    public static ReleaseProgressTracker loadOrCreate( String basedir )
+    public static ReleaseProgressTracker loadOrCreate( File basedir )
         throws IOException
     {
         ReleaseProgressTracker tracker;
 
-        if ( new File( basedir, RELEASE_PROPERTIES ).exists() )
+        File releasePropertiesFile = new File( basedir, RELEASE_PROPERTIES );
+        if ( releasePropertiesFile.exists() )
         {
-            tracker = load( basedir );
+            tracker = doLoad( releasePropertiesFile );
         }
         else
         {
-            tracker = create();
+            tracker = create( releasePropertiesFile );
         }
 
         return tracker;
     }
 
-    public static ReleaseProgressTracker create()
+    public static ReleaseProgressTracker create( File releasePropertiesFile )
     {
-        return new ReleaseProgressTracker( new Properties() );
+        return new ReleaseProgressTracker( releasePropertiesFile, new Properties() );
     }
 
-    public static ReleaseProgressTracker load( String basedir )
+    public static ReleaseProgressTracker load( File basedir )
         throws IOException
     {
-        File releasePropertiesFile = new File( basedir, RELEASE_PROPERTIES );
+        return doLoad( new File( basedir, RELEASE_PROPERTIES ) );
+    }
 
+    private static ReleaseProgressTracker doLoad( File releasePropertiesFile )
+        throws IOException
+    {
         InputStream inStream = null;
 
         Properties rp;
@@ -103,9 +111,9 @@
             IOUtil.close( inStream );
         }
 
-        return new ReleaseProgressTracker( rp );
+        return new ReleaseProgressTracker( releasePropertiesFile, rp );
     }
-    
+
     protected void setReleaseProperty( String key, String value )
     {
         if ( StringUtils.isNotEmpty( value ) )
@@ -169,13 +177,17 @@
         return releaseProperties.getProperty( SCM_PASSWORD );
     }
 
-    public void checkpoint( String basedir, String pointName )
+    public void checkpoint( String pointName )
         throws IOException
     {
         setCheckpoint( pointName );
 
-        File releasePropertiesFile = new File( basedir, RELEASE_PROPERTIES );
+        store();
+    }
 
+    public void store()
+        throws IOException
+    {
         FileOutputStream outStream = null;
 
         try

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java?rev=345919&r1=345918&r2=345919&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
Mon Nov 21 07:59:12 2005
@@ -29,10 +29,11 @@
 import org.apache.maven.scm.command.unedit.UnEditScmResult;
 import org.apache.maven.scm.command.update.UpdateScmResult;
 import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.io.IOException;
@@ -84,38 +85,26 @@
         {
             repository = getScmManager().makeScmRepository( url );
 
+            ScmProviderRepository scmRepo = repository.getProviderRepository();
+
+            if ( !StringUtils.isEmpty( username ) )
+            {
+                scmRepo.setUser( username );
+            }
+            if ( !StringUtils.isEmpty( password ) )
+            {
+                scmRepo.setPassword( password );
+            }
+
             if ( repository.getProvider().equals( "svn" ) )
             {
                 SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
 
-                if ( username != null && username.length() > 0 )
-                {
-                    svnRepo.setUser( username );
-                }
-                if ( password != null && password.length() > 0 )
-                {
-                    svnRepo.setPassword( password );
-                }
                 if ( tagBase != null && tagBase.length() > 0 )
                 {
                     svnRepo.setTagBase( tagBase );
                 }
             }
-            
-            if ( repository.getProvider().equals( "starteam" ) )
-            {
-                StarteamScmProviderRepository starteamRepo = (StarteamScmProviderRepository)
repository.getProviderRepository();
-
-                if ( username != null && username.length() > 0 )
-                {
-                    starteamRepo.setUser( username );
-                }
-                if ( password != null && password.length() > 0 )
-                {
-                    starteamRepo.setPassword( password );
-                }
-            }
-            
         }
         catch ( Exception e )
         {
@@ -123,6 +112,22 @@
         }
 
         return repository;
+    }
+
+    public String getProvider()
+        throws ScmException
+    {
+        ScmRepository repository;
+        try
+        {
+            repository = getScmManager().makeScmRepository( url );
+
+            return repository.getProvider();
+        }
+        catch ( Exception e )
+        {
+            throw new ScmException( "Can't load the scm provider.", e );
+        }
     }
 
     private void checkResult( ScmResult result )



Mime
View raw message