maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r778240 - in /maven/components/branches/MNG-2766: maven-compat/src/main/java/org/apache/maven/artifact/resolver/ maven-embedder/src/test/java/org/apache/maven/embedder/ maven-embedder/src/test/resources/
Date Sun, 24 May 2009 21:24:58 GMT
Author: bentmann
Date: Sun May 24 21:24:57 2009
New Revision: 778240

URL: http://svn.apache.org/viewvc?rev=778240&view=rev
Log:
[MNG-4172] Project POM artifact returned as dependency if project has no dependencies

Added:
    maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
  (with props)
Modified:
    maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java

Modified: maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=778240&r1=778239&r2=778240&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
(original)
+++ maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
Sun May 24 21:24:57 2009
@@ -456,12 +456,15 @@
             }
         }
         
-        if ( artifacts == null || artifacts.size() == 0 )
+        if ( artifacts == null || artifacts.isEmpty() )
         {
-            result.addArtifact( rootArtifact );            
+            if ( request.isResolveRoot() )
+            {
+                result.addArtifact( rootArtifact );
+            }
             return result;
         } 
-                                
+
         // After the collection we will have the artifact object in the result but they will
not be resolved yet.
         result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository,
remoteRepositories, source, filter, listeners, null );
                         

Modified: maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java?rev=778240&r1=778239&r2=778240&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
(original)
+++ maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
Sun May 24 21:24:57 2009
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -389,6 +390,20 @@
         artifacts.iterator().next();
     }
 
+    public void testProjectReadingNoDependencies()
+        throws Exception
+    {
+        MavenExecutionRequest request =
+            new DefaultMavenExecutionRequest().setShowErrors( true ).setPom(
+                                                                             getPomFile(
"pom-without-dependencies.xml" ) );
+
+        MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies( request
);
+
+        assertNoExceptions( result );
+
+        assertEquals( new ArrayList<Artifact>(), new ArrayList<Artifact>( result.getProject().getArtifacts()
) );
+    }
+
     public void testProjectReading_FromChildLevel_ScmInheritanceCalculations()
         throws Exception
     {
@@ -600,6 +615,12 @@
 
     protected File getPomFile()
     {
-        return new File( basedir, "src/test/resources/pom.xml" );
+        return getPomFile( "pom.xml" );
+    }
+
+    protected File getPomFile( String name )
+    {
+        return new File( basedir, "src/test/resources/" + name );
     }
+
 }

Added: maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml?rev=778240&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
(added)
+++ maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
Sun May 24 21:24:57 2009
@@ -0,0 +1,30 @@
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven</groupId>
+  <artifactId>maven-model</artifactId>
+  <name>Maven Embedder Test Project</name>
+  <version>1.0</version>
+  <description>Maven Embedder Test Project Without Any Dependencies</description>
+  <dependencies>
+    <!-- no dependencies! -->
+  </dependencies>
+</project>

Propchange: maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-2766/maven-embedder/src/test/resources/pom-without-dependencies.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message