Author: ltheussl
Date: Tue Aug 22 11:01:11 2006
New Revision: 433710

URL: http://svn.apache.org/viewvc?rev=433710&view=rev
Log:
PR: MAVEN-1704
artifactId is used as groupId when the latter is not defined

Added:
    
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
   (with props)
    
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
   (with props)
Modified:
    maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java
    
maven/maven-1/core/trunk/src/test/java/org/apache/maven/project/LegacyIdTest.java

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java?rev=433710&r1=433709&r2=433710&view=diff
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java 
(original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/project/Project.java Tue 
Aug 22 11:01:11 2006
@@ -810,10 +810,25 @@
             setShortDescription( parent.getShortDescription() );
         }
 
+        /*
         if ( model.getGroupId() == null )
         {
             // Don't inherit if it was from an id element
             if ( parent.originalGroupId != null || model.getId() == null )
+            {
+                // Don't inherit if only artifactId is given, see MAVEN-1704
+                if ( !( parent.originalGroupId == null && model.getId() == 
null ) )
+                {
+                    model.setGroupId( parent.model.getGroupId() );
+                }
+            }
+        }
+        */
+
+        // This is equivalent to the above
+        if ( model.getGroupId() == null )
+        {
+            if ( parent.originalGroupId != null )
             {
                 model.setGroupId( parent.model.getGroupId() );
             }

Modified: 
maven/maven-1/core/trunk/src/test/java/org/apache/maven/project/LegacyIdTest.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/test/java/org/apache/maven/project/LegacyIdTest.java?rev=433710&r1=433709&r2=433710&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/test/java/org/apache/maven/project/LegacyIdTest.java
 (original)
+++ 
maven/maven-1/core/trunk/src/test/java/org/apache/maven/project/LegacyIdTest.java
 Tue Aug 22 11:01:11 2006
@@ -175,6 +175,17 @@
         assertEquals( "check id", "base-groupId:extend-artifactId", p.getId() 
);
     }
 
+    public void testExtendOnlyArtifactIds()
+        throws Exception
+    {
+        Project p = MavenUtils.getProject( new File( System.getProperty( 
"basedir" ),
+                                                     
"src/test/test-data/pom/extend/test-artifact-id-only-extend.xml" ) );
+        assertEquals( "check id", "childArtifactId:childArtifactId", p.getId() 
);
+        assertEquals( "check artifact id", "childArtifactId", 
p.getArtifactId() );
+        assertEquals( "check group id", "childArtifactId", p.getGroupId() );
+        assertEquals( "check id", "childArtifactId:childArtifactId", p.getId() 
);
+    }
+
     public void testExtendArtifactIdOnly()
         throws Exception
     {

Added: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml?rev=433710&view=auto
==============================================================================
--- 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
 (added)
+++ 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
 Tue Aug 22 11:01:11 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * Copyright 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 xmlns="http://maven.apache.org/POM/3.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/3.0.0 
http://maven.apache.org/maven-v3_0_0.xsd";>
+
+
+  <pomVersion>3</pomVersion>
+  <artifactId>parentArtifactId</artifactId>
+  <name>Parent Application</name>
+  <currentVersion>1.0</currentVersion>
+  <inceptionYear>2006</inceptionYear>
+
+</project>

Propchange: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-base.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml?rev=433710&view=auto
==============================================================================
--- 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
 (added)
+++ 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
 Tue Aug 22 11:01:11 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * Copyright 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 xmlns="http://maven.apache.org/POM/3.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/3.0.0 
http://maven.apache.org/maven-v3_0_0.xsd";>
+
+  <extend>test-artifact-id-only-base.xml</extend>
+  <pomVersion>3</pomVersion>
+  <artifactId>childArtifactId</artifactId>
+  <name>Child Application</name>
+  <currentVersion>1.0</currentVersion>
+  <inceptionYear>2006</inceptionYear>
+
+</project>

Propchange: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/maven-1/core/trunk/src/test/test-data/pom/extend/test-artifact-id-only-extend.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to