mirror of https://github.com/apache/maven.git
[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:
parent
c7461bf048
commit
49698c0819
|
@ -456,12 +456,15 @@ public class DefaultArtifactResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( artifacts == null || artifacts.size() == 0 )
|
if ( artifacts == null || artifacts.isEmpty() )
|
||||||
{
|
{
|
||||||
result.addArtifact( rootArtifact );
|
if ( request.isResolveRoot() )
|
||||||
|
{
|
||||||
|
result.addArtifact( rootArtifact );
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// After the collection we will have the artifact object in the result but they will not be resolved yet.
|
// 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 );
|
result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners, null );
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -389,6 +390,20 @@ public class MavenEmbedderTest
|
||||||
artifacts.iterator().next();
|
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()
|
public void testProjectReading_FromChildLevel_ScmInheritanceCalculations()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -600,6 +615,12 @@ public class MavenEmbedderTest
|
||||||
|
|
||||||
protected File getPomFile()
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue