Skip to content

Commit

Permalink
🐛 Fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Tudone committed Apr 20, 2016
1 parent a1f6c8f commit 81f5248
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/capsule/DependencyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ protected RepositorySystemSession newRepositorySession(RepositorySystem system,

s.setConfigProperty(ConfigurationProperties.CONNECT_TIMEOUT, propertyOrEnv(PROP_CONNECT_TIMEOUT, ENV_CONNECT_TIMEOUT));
s.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, propertyOrEnv(PROP_REQUEST_TIMEOUT, ENV_REQUEST_TIMEOUT));
// WARN: `ConflictResolver.CONFIG_PROP_VERBOSE` will retain (and mark) dependency graph duplicates such as conflict resolution losers since
// http://git.eclipse.org/c/aether/aether-core.git/diff/aether-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java?id=141a3669d23ab67846b0c3ccef14eb0cdc70cee9
s.setConfigProperty(ConflictResolver.CONFIG_PROP_VERBOSE, true);

s.setOffline(offline);
Expand Down Expand Up @@ -308,7 +310,8 @@ public final Map<Dependency, List<Path>> resolveDependencies(List<Dependency> de
dn.accept(new DependencyVisitor() {
@Override
public boolean visitEnter(DependencyNode node) {
jars.add(path(node.getArtifact()));
if (hasArtifactPath(node)) // Conflict losers won't have it
jars.add(path(node.getArtifact()));
return true;
}

Expand Down Expand Up @@ -349,6 +352,14 @@ protected DependencyResult resolve0(CollectRequest collectRequest) {
log(LOG_DEBUG, "DependencyManager.resolve " + collectRequest);
try {
final DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
dependencyRequest.setFilter(new DependencyFilter() {
@Override
public boolean accept(DependencyNode n, List<DependencyNode> parents) {
// Exclude conflict losers (which are marked but left in if verbose mode is enabled, see
// http://git.eclipse.org/c/aether/aether-core.git/diff/aether-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java?id=141a3669d23ab67846b0c3ccef14eb0cdc70cee9t
return !n.getData().containsKey(ConflictResolver.NODE_DATA_WINNER);
}
});
final DependencyResult result = system.resolveDependencies(getSession(), dependencyRequest);
if (isLogging(LOG_DEBUG))
log(LOG_DEBUG, "DependencyManager.resolve: " + result);
Expand Down Expand Up @@ -482,6 +493,14 @@ public void println(String x) {
};
}

private static boolean hasArtifactPath(DependencyNode node) {
Artifact a;
return
node != null &&
(a = node.getArtifact()) != null &&
a.getFile() != null;
}

private static String propertyOrEnv(String propName, String envVar) {
String val = System.getProperty(propName);
if (val == null)
Expand Down

0 comments on commit 81f5248

Please sign in to comment.