Author: brett
Date: Thu Apr 27 07:02:31 2006
New Revision: 397547

URL: http://svn.apache.org/viewcvs?rev=397547&view=rev
Log:
[MRELEASE-98] more parent tests

Added:
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
   (with props)
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
   (with props)
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
   (with props)
    
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
   (with props)
Modified:
    
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhase.java
    
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java

Modified: 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhase.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhase.java?rev=397547&r1=397546&r2=397547&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhase.java
 (original)
+++ 
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhase.java
 Thu Apr 27 07:02:31 2006
@@ -128,22 +128,25 @@
     private void transformPomToReleaseVersionPom( MavenProject project, 
Element rootElement, Map mappedVersions )
         throws ReleaseExecutionException
     {
-        // TODO: what about if version is inherited? shouldn't prompt...
-        Element versionElement = rootElement.getChild( "version", 
rootElement.getNamespace() );
-        String version = (String) mappedVersions.get(
-            ArtifactUtils.versionlessKey( project.getGroupId(), 
project.getArtifactId() ) );
-        if ( version == null )
+        if ( project.getArtifact().isSnapshot() )
         {
-            throw new ReleaseExecutionException( "Version for '" + 
project.getName() + "' was not mapped" );
+            // TODO: what about if version is inherited? shouldn't prompt...
+            Element versionElement = rootElement.getChild( "version", 
rootElement.getNamespace() );
+            String version = (String) mappedVersions.get(
+                ArtifactUtils.versionlessKey( project.getGroupId(), 
project.getArtifactId() ) );
+            if ( version == null )
+            {
+                throw new ReleaseExecutionException( "Version for '" + 
project.getName() + "' was not mapped" );
+            }
+            versionElement.setText( version );
         }
-        versionElement.setText( version );
 
-        if ( project.hasParent() )
+        if ( project.hasParent() && project.getParentArtifact().isSnapshot() )
         {
             Element parentElement = rootElement.getChild( "parent", 
rootElement.getNamespace() );
-            versionElement = parentElement.getChild( "version", 
rootElement.getNamespace() );
+            Element versionElement = parentElement.getChild( "version", 
rootElement.getNamespace() );
             MavenProject parent = project.getParent();
-            version = (String) mappedVersions.get(
+            String version = (String) mappedVersions.get(
                 ArtifactUtils.versionlessKey( parent.getGroupId(), 
parent.getArtifactId() ) );
             if ( version == null )
             {
@@ -162,17 +165,6 @@
 /*
         ProjectScmRewriter scmRewriter = getScmRewriter();
         scmRewriter.rewriteScmInfo( model, projectId, getTagLabel() );
-
-        //Rewrite parent version
-        if ( model.getParent() != null )
-        {
-            if ( ArtifactUtils.isSnapshot( parentArtifact.getBaseVersion() ) )
-            {
-                String version = resolveVersion( parentArtifact, "parent", 
pluginArtifactRepositories );
-
-                model.getParent().setVersion( version );
-            }
-        }
 
         //Rewrite dependencies section
         List dependencies = model.getDependencies();

Modified: 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java?rev=397547&r1=397546&r2=397547&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
 (original)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
 Thu Apr 27 07:02:31 2006
@@ -27,6 +27,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -65,6 +66,47 @@
         ReleaseConfiguration config = createConfigurationFromProjects( 
"pom-with-parent" );
 
         config.mapReleaseVersion( "groupId:artifactId", "1.0" );
+        config.mapReleaseVersion( "groupId:subproject1", "2.0" );
+
+        phase.execute( config );
+
+        assertTrue( compareFiles( config.getReactorProjects() ) );
+    }
+
+    public void testRewritePomWithUnmappedParent()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( 
"pom-with-parent" );
+
+        // remove parent from processing so it fails when looking at the 
parent of the child instead
+        for ( Iterator i = config.getReactorProjects().iterator(); 
i.hasNext(); )
+        {
+            MavenProject project = (MavenProject) i.next();
+            if ( "subproject1".equals( project.getArtifactId() ) )
+            {
+                config.setReactorProjects( Collections.singletonList( project 
) );
+            }
+        }
+
+        config.mapReleaseVersion( "groupId:subproject1", "2.0" );
+
+        try
+        {
+            phase.execute( config );
+
+            fail( "Should have thrown an exception" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertNull( "Check no cause", e.getCause() );
+        }
+    }
+
+    public void testRewritePomWithReleasedParent()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( 
"pom-with-released-parent" );
+
         config.mapReleaseVersion( "groupId:subproject1", "2.0" );
 
         phase.execute( config );

Added: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml?rev=397547&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
 Thu Apr 27 07:02:31 2006
@@ -0,0 +1,27 @@
+<!--
+  ~ Copyright 2005-2006 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.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>groupId</groupId>
+  <artifactId>artifactId</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>subproject1</module>
+  </modules>
+</project>

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/expected-pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml?rev=397547&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
 Thu Apr 27 07:02:31 2006
@@ -0,0 +1,27 @@
+<!--
+  ~ Copyright 2005-2006 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.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>groupId</groupId>
+  <artifactId>artifactId</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>subproject1</module>
+  </modules>
+</project>

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml?rev=397547&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
 Thu Apr 27 07:02:31 2006
@@ -0,0 +1,27 @@
+<!--
+  ~ Copyright 2005-2006 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.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>groupId</groupId>
+    <artifactId>artifactId</artifactId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>subproject1</artifactId>
+  <version>2.0</version>
+</project>

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/expected-pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml?rev=397547&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
 Thu Apr 27 07:02:31 2006
@@ -0,0 +1,27 @@
+<!--
+  ~ Copyright 2005-2006 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.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>groupId</groupId>
+    <artifactId>artifactId</artifactId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>subproject1</artifactId>
+  <version>2.0-SNAPSHOT</version>
+</project>

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-release-plugin/src/test/resources/projects/rewrite-for-release/pom-with-released-parent/subproject1/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to