| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
package capsule; |
| 10 |
|
| 11 |
import java.util.Collection; |
| 12 |
|
| 13 |
import org.eclipse.aether.artifact.Artifact; |
| 14 |
import org.eclipse.aether.graph.Dependency; |
| 15 |
import org.eclipse.aether.graph.Exclusion; |
| 16 |
|
| 17 |
import org.eclipse.aether.repository.RemoteRepository; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class Dependencies { |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public static String toCapsuleRepositoryString(RemoteRepository rr) { |
| 30 |
return DependencyManager.WELL_KNOWN_REPOS.keySet().contains(rr.getId()) |
| 31 |
? rr.getId() : rr.getUrl(); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public static String toCapsuleDependencyString(Dependency d) { |
| 40 |
return toCapsuleArtifactString(d.getArtifact()) |
| 41 |
+ toCapsuleExclusionsString(d.getExclusions()); |
| 42 |
} |
| 43 |
|
| 44 |
private static String toCapsuleArtifactString(Artifact a) { |
| 45 |
return DependencyManager.artifactToCoords(a); |
| 46 |
} |
| 47 |
|
| 48 |
private static String toCapsuleExclusionsString(Collection<Exclusion> exclusions) { |
| 49 |
final StringBuilder res = new StringBuilder(); |
| 50 |
|
| 51 |
if (!exclusions.isEmpty()) { |
| 52 |
res.append("("); |
| 53 |
|
| 54 |
boolean starting = true; |
| 55 |
|
| 56 |
for (Exclusion e : exclusions) { |
| 57 |
if (!starting) |
| 58 |
res.append(","); |
| 59 |
else |
| 60 |
starting = false; |
| 61 |
|
| 62 |
res.append(e.getGroupId()); |
| 63 |
res.append(":"); |
| 64 |
|
| 65 |
if (e.getArtifactId() != null && e.getArtifactId().length() > 0) |
| 66 |
res.append(e.getArtifactId()); |
| 67 |
else |
| 68 |
res.append("*"); |
| 69 |
} |
| 70 |
|
| 71 |
res.append(")"); |
| 72 |
} |
| 73 |
|
| 74 |
return res.toString(); |
| 75 |
} |
| 76 |
} |