Skip to content

Commit

Permalink
FORGE-2158: MavenDependencyAdapter should return the artifact when
Browse files Browse the repository at this point in the history
available
  • Loading branch information
gastaldi committed Nov 26, 2014
1 parent f374e11 commit 2ffe05f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
@Vetoed
public class FileResourceFactory implements ResourceFactory
class FileResourceFactory implements ResourceFactory
{
@Override
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
*/
public class MavenDependencyAdapter extends org.apache.maven.model.Dependency implements Dependency
{
private static final FileResourceFactory RESOURCE_FACTORY = new FileResourceFactory();
private static final long serialVersionUID = -518791785675970540L;

private FileResource<?> artifact;

public MavenDependencyAdapter(final org.apache.maven.model.Dependency dep)
{
if (dep == null)
Expand Down Expand Up @@ -61,6 +64,7 @@ public MavenDependencyAdapter(final Dependency dep)
this.setType(dep.getCoordinate().getPackaging());
this.setClassifier(dep.getCoordinate().getClassifier());
this.setSystemPath(dep.getCoordinate().getSystemPath());
this.artifact = dep.getArtifact();
if (dep.isOptional())
{
this.setOptional(dep.isOptional());
Expand All @@ -78,13 +82,13 @@ public MavenDependencyAdapter(final Dependency dep)
}
}

@SuppressWarnings("unchecked")
public MavenDependencyAdapter(final org.eclipse.aether.graph.Dependency dep)
{
if (dep == null)
{
throw new IllegalArgumentException("Dependency must not be null.");
}

this.setArtifactId(dep.getArtifact().getArtifactId());
this.setGroupId(dep.getArtifact().getGroupId());
this.setClassifier("".equals(dep.getArtifact().getClassifier()) ? null : dep.getArtifact().getClassifier());
Expand All @@ -96,6 +100,7 @@ public MavenDependencyAdapter(final org.eclipse.aether.graph.Dependency dep)
this.setScope(dep.getScope());
this.setType(dep.getArtifact().getExtension());
this.setVersion(dep.getArtifact().getBaseVersion());
this.artifact = RESOURCE_FACTORY.create(FileResource.class, dep.getArtifact().getFile());
}

@Override
Expand All @@ -113,7 +118,7 @@ public Coordinate getCoordinate()
@Override
public FileResource<?> getArtifact() throws DependencyException
{
return null;
return artifact;
}

private void setExclusions(final Collection<org.eclipse.aether.graph.Exclusion> exclusions)
Expand Down

0 comments on commit 2ffe05f

Please sign in to comment.