Exception in compiling groovy & java using maven

366 Views Asked by At

My groovy file contains:

@Grapes([

    @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7'),
    @Grab('org.apache.httpcomponents:httpmime:4.5.1')

])

.......code

I am trying to compile groovy and java code. But I am getting below error:

java.lang.RuntimeException: Transform groovy.grape.GrabAnnotationTransformation@69bda33a cannot be run
2

There are 2 best solutions below

1
pczeus On

This works for me, note that I did change HttpBuilder to v.0.7.1:

@Grapes([
    @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1'),
    @Grab(group='org.apache.httpcomponents', module='httpmime', version='4.5.1')
])
0
Matt Sheppard On

Likely way too late for you to care, but I saw the same error just now.

I suspect the problem is that the @Grab annotation can't take effect because Maven is controlling the dependencies, or perhaps because Maven is trying to compile both Groovy and Java code, and the class loader created by the @Grab annotation can't influence the Java code.

Upshot is, I suspect you (and I) need to move the dependency out of the Groovy class in question, and put it into the pom.xml file Maven is using.