Remove @GrabResolvers before packaging jar in CLI

Since all dependencies are local in a jar there is no need for
a GrabResolver (and it breaks the app because the default ivy
GrapeEngine is used instead of the smart, pretty Boot one).

Fixes gh-1179
This commit is contained in:
Dave Syer
2014-06-27 10:20:56 +01:00
parent 981669b7c0
commit 179ac6022a
3 changed files with 39 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.ModuleNode;
@@ -279,6 +280,21 @@ public class JarCommand extends OptionParsingCommand {
// We only need to do it at most once
break;
}
// Remove GrabReolvers because all the dependencies are local now
removeGrabResolver(module.getClasses());
removeGrabResolver(module.getImports());
}
private void removeGrabResolver(List<? extends AnnotatedNode> nodes) {
for (AnnotatedNode classNode : nodes) {
List<AnnotationNode> annotations = classNode.getAnnotations();
for (AnnotationNode node : new ArrayList<AnnotationNode>(annotations)) {
if (node.getClassNode().getNameWithoutPackage()
.equals("GrabResolver")) {
annotations.remove(node);
}
}
}
}
}