mirror of https://github.com/apache/maven.git
Resolving: MNG-717
o Dependencies don't have a default scope value, to allow DependencyManagement to set the scope if null...then, the metadata source sets the scope to 'compile' when it constructs the artifacts from deps that still have a null scope. Oh, and it will at that point back-propagate the 'compile' scope to these dependency instances, for later reference... git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@240428 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4b01d88bc3
commit
4ccb9068fb
|
@ -1248,7 +1248,10 @@
|
|||
<a href="http://maven.apache.org/maven2/dependencies.html">Dependency Mechanism</a>.]]>
|
||||
</description>
|
||||
<type>String</type>
|
||||
<defaultValue>compile</defaultValue>
|
||||
<!-- This default has to be enforced at the maven-artifact layer, to allow
|
||||
| injection of defaults from <dependencyManagement/>.
|
||||
|-->
|
||||
<!-- defaultValue>compile</defaultValue -->
|
||||
</field>
|
||||
<field>
|
||||
<name>exclusions</name>
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -235,11 +236,20 @@ public class MavenMetadataSource
|
|||
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
String scope = d.getScope();
|
||||
|
||||
if ( StringUtils.isEmpty( scope ) )
|
||||
{
|
||||
scope = Artifact.SCOPE_COMPILE;
|
||||
|
||||
d.setScope( scope );
|
||||
}
|
||||
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
|
||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||
versionRange, d.getType(), d.getClassifier(),
|
||||
d.getScope(), inheritedScope );
|
||||
scope, inheritedScope );
|
||||
|
||||
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.codehaus.plexus.context.Context;
|
|||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -144,10 +145,19 @@ public class TestArtifactResolver
|
|||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
String scope = d.getScope();
|
||||
|
||||
if ( StringUtils.isEmpty( scope ) )
|
||||
{
|
||||
scope = Artifact.SCOPE_COMPILE;
|
||||
|
||||
d.setScope( scope );
|
||||
}
|
||||
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
|
||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||
versionRange, d.getType(),
|
||||
d.getClassifier(), d.getScope(),
|
||||
d.getClassifier(), scope,
|
||||
inheritedScope );
|
||||
if ( artifact != null )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue