gradle - Groovy generated constructor missing during compile -
i have setup in call generated constructor(@tupleconstructor) of groovy class(product) java class(productservice). ide shows generated constructors , compilation used work. now, unknown reasons, compilation fails because compiler doesnt find parameterized constructors anymore:
productservice.java:31: error: constructor product in class product cannot applied given types; required: no arguments found: string,boolean,boolean,float reason: actual , formal argument lists differ in length
and current gradle(2.4) setup:
apply plugin: 'groovy' apply plugin: 'java' project.sourcecompatibility = 1.8 project.targetcompatibility = 1.8 sourcesets.main.java.srcdirs = [] sourcesets.main.groovy.srcdir 'src/main/java' ... dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.+' testcompile 'org.spockframework:spock-core:1.0-groovy-2.4' }
groovy class:
@tupleconstructor class product { string name boolean bool1 boolean bool2 float price }
constructor call in java class(fails compile):
... products.add(new product("parliament", true, false, 10.50f)); ...
analysis:
this looks me joint compilation issue. transform @tupleconstructor runs after groovy did create .java stub files, causing java compilation part fail. have worked before, because compiled groovy part independent , reused existing class files (no clean). sadly limitation of stub generator , there not way fix issue in groovy, if transform supposed stay in same phase.
solutions:
- use groovy-eclipse batch compiler
- don't use transforms run after stub generator
- create multi module build in gradle, compile groovy part independent
Comments
Post a Comment