[MNG-4172] Project POM artifact returned as dependency if project has no dependencies

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@778240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-24 21:24:57 +00:00
parent c7461bf048
commit 49698c0819
3 changed files with 58 additions and 4 deletions

View File

@ -456,9 +456,12 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
}
}
if ( artifacts == null || artifacts.size() == 0 )
if ( artifacts == null || artifacts.isEmpty() )
{
result.addArtifact( rootArtifact );
if ( request.isResolveRoot() )
{
result.addArtifact( rootArtifact );
}
return result;
}

View File

@ -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 @@ public void testProjectReading()
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 @@ public void testWriteSettings_shouldFailToValidate()
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 );
}
}

View File

@ -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>