Forcing all Java code to compile with groovyc


(Sam D) #1

It appears the groovy plugin delegates any *.java files to the java compiler even though I explicitly do

sourceSets {
    main{
        java {
            srcDirs = []
        }
        groovy {
            srcDirs += ['src/main/java']
        }
    }

I want to use groovyc so that the metaclass is added for later testing reasons.

Is there anyway to get the groovy plugin to treat all java classes as groovy classes when compiling?


(Mark Vieira) #2

Not without renaming them to .groovy.

Gradle leverages Groovy’s joint compilation support which by default delegates compilation of all Java sources to javac. There’s currently no option for changing this behavior.


(Sam D) #3

Thanks Mark, that is what I suspected but figured it was good to get a confirmation.