I'm compiling a Groovy project with Gradle, but I've noticed that when I use the @Grab annotation in my code, I get the following error:
$ gradle compile
:buildInfo
:compileJava UP-TO-DATE
:compileGroovy FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> org/apache/ivy/core/report/ResolveReport
(full stack trace here http://pastebin.com/0ty4jNct)
I've found out that the only way to get it working is to add the 'groovy' and 'ivy' module to the groovy classpath, but I would like to avoid this, since the groovy classpath is deprecated.
Is this a Gradle bug? or there's a better way to manage the @Grab dependency?
@Grab
is meant to be used for standalone scripts that aren't precompiled, and you wouldn't normally use it together with compiled code. If you do, you may have to add Ivy togroovyClasspath
. Something like:That said, a better approach is to manage dependencies with Gradle.