I have a setup in which I call the generated constructor(@TupleConstructor) of a Groovy class(Product) from a java class(ProductService). The IDE shows the generated constructors and compilation used to work. But now, for unknown reasons, the compilation fails because the compiler doesnt find the parameterized constructors anymore:
ProductService.java:31: error: constructor Product in class Product cannot
be applied to given types;
required: no arguments
found: String,boolean,boolean,float
reason: actual and formal argument lists differ in length
And this is my 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 to compile):
...
products.add(new Product("Parliament", true, false, 10.50F));
...