/** * Compare the {@link Coordinate} of each given {@link Dependency} for equivalence. */ public static boolean areEquivalent(Coordinate l, Coordinate r) { if (l == r) { return true; } if ((l == null) && (r == null)) { return true; } else if ((l == null) || (r == null)) { return false; } return !(l.getArtifactId() != null ? !l.getArtifactId() .equals(r.getArtifactId()) : r.getArtifactId() != null) && !(l.getGroupId() != null ? !l.getGroupId() .equals(r.getGroupId()) : r.getGroupId() != null) && !(l.getClassifier() != null ? !l.getClassifier() .equals(r.getClassifier()) : r.getClassifier() != null); }
/** * Compare the {@link Coordinate} of each given {@link Dependency} for equivalence. */ public static boolean areEquivalent(Dependency l, Dependency r) { if (l == r) { return true; } if ((l == null) && (r == null)) { return true; } else if ((l == null) || (r == null)) { return false; } return !(l.getCoordinate().getArtifactId() != null ? !l.getCoordinate().getArtifactId() .equals(r.getCoordinate().getArtifactId()) : r.getCoordinate().getArtifactId() != null) && !(l.getCoordinate().getGroupId() != null ? !l.getCoordinate().getGroupId() .equals(r.getCoordinate().getGroupId()) : r.getCoordinate().getGroupId() != null) && !(l.getCoordinate().getClassifier() != null ? !l.getCoordinate().getClassifier() .equals(r.getCoordinate().getClassifier()) : r.getCoordinate().getClassifier() != null); } /**
static Artifact coordinateToMavenArtifact(final Coordinate dep) { Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getPackaging() == null ? "jar" : dep.getPackaging(), dep.getVersion()); return artifact; }
public static CoordinateBuilder create(Coordinate c) { CoordinateBuilder builder = create(); builder.setGroupId(c.getGroupId()).setArtifactId(c.getArtifactId()); builder.setClassifier(c.getClassifier()).setPackaging(c.getPackaging()).setVersion(c.getVersion()); return builder; }
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()); 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); } } }