mirror of https://github.com/apache/maven.git
PR: MNG-1630
Submitted By: Edwin Punzalan Reviewed By: John Casey Applied patches, with minor changes. These patches will ensure that the optional flag is passed on and inherited correctly when dealing with managed dependencies. I changed the patches, in that I added a new createDependencyArtifact(..) method on ArtifactFactory, which will eliminate the need to call an older variant of the method by passing in a null value for the inheritedScope parameter. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@354544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
662331c8de
commit
5b427cf076
|
@ -157,6 +157,8 @@ public interface Artifact
|
||||||
|
|
||||||
boolean isOptional();
|
boolean isOptional();
|
||||||
|
|
||||||
|
void setOptional( boolean optional );
|
||||||
|
|
||||||
ArtifactVersion getSelectedVersion()
|
ArtifactVersion getSelectedVersion()
|
||||||
throws OverConstrainedVersionException;
|
throws OverConstrainedVersionException;
|
||||||
|
|
||||||
|
|
|
@ -541,4 +541,9 @@ public class DefaultArtifact
|
||||||
{
|
{
|
||||||
return versionRange.isSelectedVersionKnown( this );
|
return versionRange.isSelectedVersionKnown( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOptional( boolean optional )
|
||||||
|
{
|
||||||
|
this.optional = optional;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,9 @@ public interface ArtifactFactory
|
||||||
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
String classifier, String scope );
|
String classifier, String scope );
|
||||||
|
|
||||||
|
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String classifier, String scope, boolean optional );
|
||||||
|
|
||||||
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
String classifier, String scope, String inheritedScope );
|
String classifier, String scope, String inheritedScope );
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@ public class DefaultArtifactFactory
|
||||||
return createArtifact( groupId, artifactId, versionRange, type, classifier, null, null );
|
return createArtifact( groupId, artifactId, versionRange, type, classifier, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String classifier, String scope, boolean optional )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional );
|
||||||
|
}
|
||||||
|
|
||||||
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
String classifier, String scope, String inheritedScope )
|
String classifier, String scope, String inheritedScope )
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,7 +249,8 @@ public class DefaultMavenProjectBuilder
|
||||||
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
|
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
|
||||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||||
versionRange, d.getType(),
|
versionRange, d.getType(),
|
||||||
d.getClassifier(), d.getScope() );
|
d.getClassifier(), d.getScope(),
|
||||||
|
d.isOptional() );
|
||||||
map.put( d.getManagementKey(), artifact );
|
map.put( d.getManagementKey(), artifact );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
|
|
|
@ -288,4 +288,9 @@ public class ActiveProjectArtifact
|
||||||
{
|
{
|
||||||
return artifact.isSelectedVersionKnown();
|
return artifact.isSelectedVersionKnown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOptional( boolean optional )
|
||||||
|
{
|
||||||
|
artifact.setOptional( optional );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue