private void appendDependency(StringBuilder builder, Dependency appendDependency) { appendCoordinates(builder, appendDependency.getCoordinate(), true); if (!appendDependency.getExcludedCoordinates().isEmpty()) { builder.append("<exclusions>"); for (Coordinate exclusion : appendDependency.getExcludedCoordinates()) { appendExclusion(builder, exclusion); } builder.append("</exclusions>"); } }
private List<org.apache.maven.model.Dependency> transformDependencies(MavenPlugin mavenPlugin) { List<org.apache.maven.model.Dependency> dependencies = new ArrayList<org.apache.maven.model.Dependency>(); for (Dependency dependency : mavenPlugin.getDirectDependencies()) { org.apache.maven.model.Dependency pluginDependency = new org.apache.maven.model.Dependency(); pluginDependency.setArtifactId(dependency.getCoordinate().getArtifactId()); pluginDependency.setGroupId(dependency.getCoordinate().getGroupId()); pluginDependency.setVersion(dependency.getCoordinate().getVersion()); pluginDependency.setScope(dependency.getScopeType()); if (dependency.getExcludedCoordinates() != null) { pluginDependency.setExclusions(transformExclusions(dependency.getExcludedCoordinates())); } dependencies.add(pluginDependency); } return dependencies; }
public static DependencyBuilder create(final Dependency dep) { DependencyBuilder builder = new DependencyBuilder(); builder.setCoordinate(dep.getCoordinate()); builder.setScopeType(dep.getScopeType()); builder.setArtifact(dep.getArtifact()); builder.setExcludedCoordinates(dep.getExcludedCoordinates()); builder.setOptional(dep.isOptional()); return builder; }
/** * 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); } } }