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:
John Dennis Casey 2005-12-06 20:50:41 +00:00
parent 662331c8de
commit 5b427cf076
6 changed files with 23 additions and 1 deletions

View File

@ -156,6 +156,8 @@ public interface Artifact
void setAvailableVersions( List versions );
boolean isOptional();
void setOptional( boolean optional );
ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException;

View File

@ -541,4 +541,9 @@ public class DefaultArtifact
{
return versionRange.isSelectedVersionKnown( this );
}
public void setOptional( boolean optional )
{
this.optional = optional;
}
}

View File

@ -32,6 +32,9 @@ public interface ArtifactFactory
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
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,
String classifier, String scope, String inheritedScope );

View File

@ -49,6 +49,12 @@ public class DefaultArtifactFactory
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,
String classifier, String scope, String inheritedScope )
{

View File

@ -249,7 +249,8 @@ public class DefaultMavenProjectBuilder
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(),
d.getClassifier(), d.getScope() );
d.getClassifier(), d.getScope(),
d.isOptional() );
map.put( d.getManagementKey(), artifact );
}
catch ( InvalidVersionSpecificationException e )

View File

@ -288,4 +288,9 @@ public class ActiveProjectArtifact
{
return artifact.isSelectedVersionKnown();
}
public void setOptional( boolean optional )
{
artifact.setOptional( optional );
}
}