maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r531837 - in /maven/release/trunk/maven-release-manager/src: main/java/org/apache/maven/shared/release/phase/ main/java/org/apache/maven/shared/release/util/ test/java/org/apache/maven/shared/release/phase/
Date Tue, 24 Apr 2007 08:57:38 GMT
Author: evenisse
Date: Tue Apr 24 01:57:36 2007
New Revision: 531837

URL: http://svn.apache.org/viewvc?view=rev&rev=531837
Log:
[MRELEASE-137] Fix proposed release tag name when the root project isn't the parent of sub-modules

Added:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
  (with props)
Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPhaseTest.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
Tue Apr 24 01:57:36 2007
@@ -40,6 +40,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
@@ -262,7 +263,7 @@
         }
 
         transformScm( project, rootElement, namespace, releaseDescriptor, projectId, scmRepository,
result,
-                      (MavenProject) reactorProjects.get( 0 ) );
+                      ReleaseUtil.getRootProject( reactorProjects ) );
     }
 
     private void rewriteVersion( Element rootElement, Namespace namespace, Map mappedVersions,
String projectId,

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java
Tue Apr 24 01:57:36 2007
@@ -30,6 +30,7 @@
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.util.Iterator;
@@ -56,7 +57,7 @@
         // Currently, we don't deal with multiple SCM locations in a multiproject
         if ( StringUtils.isEmpty( releaseDescriptor.getScmSourceUrl() ) )
         {
-            MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+            MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
             if ( rootProject != null && rootProject.getScm() != null )
             {
                 if ( rootProject.getScm().getDeveloperConnection() != null )

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java
Tue Apr 24 01:57:36 2007
@@ -31,6 +31,7 @@
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.codehaus.plexus.components.interactivity.Prompter;
 import org.codehaus.plexus.components.interactivity.PrompterException;
 
@@ -85,7 +86,7 @@
         ReleaseResult result = new ReleaseResult();
 
         // get the root project
-        MavenProject project = (MavenProject) reactorProjects.get( 0 );
+        MavenProject project = ReleaseUtil.getRootProject( reactorProjects );
 
         String tag = releaseDescriptor.getScmReleaseLabel();
 

Added: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java?view=auto&rev=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
(added)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
Tue Apr 24 01:57:36 2007
@@ -0,0 +1,52 @@
+package org.apache.maven.shared.release.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.project.MavenProject;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class ReleaseUtil
+{
+    private ReleaseUtil()
+    {
+    }
+
+    public static MavenProject getRootProject( List reactorProjects )
+    {
+        MavenProject project = (MavenProject) reactorProjects.get( 0 );
+        for ( Iterator i = reactorProjects.iterator(); i.hasNext(); )
+        {
+            MavenProject currentProject = (MavenProject) i.next();
+            if ( currentProject.isExecutionRoot() )
+            {
+                project = currentProject;
+                break;
+            }
+        }
+
+        return project;
+    }
+}

Propchange: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java
Tue Apr 24 01:57:36 2007
@@ -35,6 +35,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.codehaus.plexus.util.FileUtils;
 import org.jmock.Mock;
 import org.jmock.core.constraint.IsEqual;
@@ -666,7 +667,7 @@
     protected ReleaseDescriptor createDescriptorFromProjects( List reactorProjects )
     {
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         if ( rootProject.getScm() == null )
         {
             descriptor.setScmSourceUrl( "scm:svn:file://localhost/tmp/scm-repo/trunk" );

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPhaseTest.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPhaseTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPhaseTest.java
Tue Apr 24 01:57:36 2007
@@ -36,6 +36,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.jmock.Mock;
 import org.jmock.core.Constraint;
 import org.jmock.core.constraint.IsAnything;
@@ -78,7 +79,7 @@
         List reactorProjects = createReactorProjects();
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
 
@@ -104,7 +105,7 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects( "scm-commit/", "multiple-poms", false
);
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
 
@@ -139,7 +140,7 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects();
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
 
@@ -182,7 +183,7 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects();
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
 

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java?view=diff&rev=531837&r1=531836&r2=531837
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java
Tue Apr 24 01:57:36 2007
@@ -36,6 +36,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.jmock.Mock;
 import org.jmock.core.Constraint;
 import org.jmock.core.constraint.IsAnything;
@@ -70,17 +71,16 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects();
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
-        descriptor.setScmCommentPrefix( "[my prefix]");
+        descriptor.setScmCommentPrefix( "[my prefix]" );
 
         ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() );
 
         Mock scmProviderMock = new Mock( ScmProvider.class );
-        Constraint[] arguments =
-            new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual(
"release-label" ),
-                             new IsEqual( "[my prefix] copy for tag release-label" )};
+        Constraint[] arguments = new Constraint[]{new IsAnything(), new IsScmFileSetEquals(
fileSet ),
+            new IsEqual( "release-label" ), new IsEqual( "[my prefix] copy for tag release-label"
)};
         scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments
).will(
             new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile()
) ) ) );
 
@@ -98,17 +98,16 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects( "scm-commit/", "multiple-poms", false
);
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
-        descriptor.setScmCommentPrefix( "[my prefix]");
+        descriptor.setScmCommentPrefix( "[my prefix]" );
 
         ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() );
 
         Mock scmProviderMock = new Mock( ScmProvider.class );
-        Constraint[] arguments =
-            new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual(
"release-label" ),
-                             new IsEqual( "[my prefix] copy for tag release-label" )};
+        Constraint[] arguments = new Constraint[]{new IsAnything(), new IsScmFileSetEquals(
fileSet ),
+            new IsEqual( "release-label" ), new IsEqual( "[my prefix] copy for tag release-label"
)};
         scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments
).will(
             new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile()
) ) ) );
 
@@ -143,7 +142,7 @@
         ReleaseDescriptor descriptor = new ReleaseDescriptor();
         List reactorProjects = createReactorProjects();
         descriptor.setScmSourceUrl( "scm-url" );
-        MavenProject rootProject = (MavenProject) reactorProjects.get( 0 );
+        MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         descriptor.setWorkingDirectory( rootProject.getFile().getParentFile().getAbsolutePath()
);
         descriptor.setScmReleaseLabel( "release-label" );
 



Mime
View raw message