File tree 3 files changed +39
-0
lines changed
java/org/springframework/boot/cli
main/java/org/springframework/boot/cli/command/jar
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,23 @@ public void noSources() throws Exception {
59
59
+ "resulting jar and at least one source file must be specified" ));
60
60
}
61
61
62
+ @ Test
63
+ public void jarCreationWithGrabResolver () throws Exception {
64
+ File jar = new File ("target/test-app.jar" );
65
+ Invocation invocation = this .cli .invoke ("jar" , jar .getAbsolutePath (),
66
+ "bad.groovy" );
67
+ invocation .await ();
68
+ assertEquals (invocation .getErrorOutput (), 0 , invocation .getErrorOutput ().length ());
69
+ assertTrue (jar .exists ());
70
+
71
+ Process process = new JavaExecutable ().processBuilder ("-jar" ,
72
+ jar .getAbsolutePath ()).start ();
73
+ invocation = new Invocation (process );
74
+ invocation .await ();
75
+
76
+ assertThat (invocation .getErrorOutput (), equalTo ("" ));
77
+ }
78
+
62
79
@ Test
63
80
public void jarCreation () throws Exception {
64
81
File jar = new File ("target/test-app.jar" );
Original file line number Diff line number Diff line change
1
+ @GrabResolver (name = ' clojars.org' , root = ' http://clojars.org/repo' )
2
+ @Grab (' redis.embedded:embedded-redis:0.2' )
3
+
4
+ @Component
5
+ class EmbeddedRedis {
6
+ }
Original file line number Diff line number Diff line change 35
35
import joptsimple .OptionSpec ;
36
36
37
37
import org .codehaus .groovy .ast .ASTNode ;
38
+ import org .codehaus .groovy .ast .AnnotatedNode ;
38
39
import org .codehaus .groovy .ast .AnnotationNode ;
39
40
import org .codehaus .groovy .ast .ClassNode ;
40
41
import org .codehaus .groovy .ast .ModuleNode ;
@@ -279,6 +280,21 @@ private void visitModule(ModuleNode module) {
279
280
// We only need to do it at most once
280
281
break ;
281
282
}
283
+ // Remove GrabReolvers because all the dependencies are local now
284
+ removeGrabResolver (module .getClasses ());
285
+ removeGrabResolver (module .getImports ());
286
+ }
287
+
288
+ private void removeGrabResolver (List <? extends AnnotatedNode > nodes ) {
289
+ for (AnnotatedNode classNode : nodes ) {
290
+ List <AnnotationNode > annotations = classNode .getAnnotations ();
291
+ for (AnnotationNode node : new ArrayList <AnnotationNode >(annotations )) {
292
+ if (node .getClassNode ().getNameWithoutPackage ()
293
+ .equals ("GrabResolver" )) {
294
+ annotations .remove (node );
295
+ }
296
+ }
297
+ }
282
298
}
283
299
284
300
}
You can’t perform that action at this time.
0 commit comments