/** * Convert a forge {@link org.jboss.forge.project.dependencies.Dependency} to * a Maven {@link Dependency}. */ public static Dependency convert(org.jboss.forge.addon.dependencies.Dependency forgeDep) { Dependency retVal = new Dependency(); final Coordinate coord = forgeDep.getCoordinate(); retVal.setArtifactId(coord.getArtifactId()); retVal.setGroupId(coord.getGroupId()); retVal.setVersion(coord.getVersion()); retVal.setScope(forgeDep.getScopeType()); if ("system".equalsIgnoreCase(forgeDep.getScopeType())) retVal.setSystemPath(coord.getSystemPath()); retVal.setClassifier(coord.getClassifier()); retVal.setType(coord.getPackaging()); if (forgeDep.getExcludedCoordinates() != null) { for (final Coordinate dep : forgeDep.getExcludedCoordinates()) { Exclusion exclude = new Exclusion(); exclude.setArtifactId(dep.getArtifactId()); exclude.setGroupId(dep.getGroupId()); retVal.addExclusion(exclude); } } return retVal; }
public MavenDependencyAdapter(final Dependency dep) { if (dep == null) { throw new IllegalArgumentException("Dependency must not be null."); } this.setArtifactId(dep.getCoordinate().getArtifactId()); this.setGroupId(dep.getCoordinate().getGroupId()); this.setVersion(dep.getCoordinate().getVersion()); this.setScope(dep.getScopeType()); 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()); } if (dep.getExcludedCoordinates() != null) { for (Coordinate exclusion : dep.getExcludedCoordinates()) { Exclusion temp = new Exclusion(); temp.setArtifactId(exclusion.getArtifactId()); temp.setGroupId(exclusion.getGroupId()); this.getExclusions().add(temp); } } }