I have a scala project that uses a tiny bit of groovy source code (a single class to be precisely). I am applying the groovy plugin; and the sources are locates in src/main/scala and src/main/groovy. This used to work fine, however when I gave 4.0 a shot I got this error:
> Task :XXX:YYY:compileScala
Pruning sources from previous analysis, due to incompatible CompileSetup.
/path/to/some/ScalaSourceFile.scala:162: not found: type SomeClassWrittenInGroovy
where SomeClassWrittenInGroovy is located under src/main/groovy
–debug reveals that the -classpath passed to the scala compiler doesn’t include build/classes/groovy/main:
So I followed the suggestion in the release notes and added this to my build file:
sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
which helps. It turns out that the message Pruning sources from previous analysis, due to incompatible CompileSetup. was not related to the issue.
Anyway, this is just a workaround, so I would still like to understand how I can control the class path of the scala compiler task or how to enable joint compilation of scala and groovy sources. Anyone?
This used to work because all compilation tasks shared the same output directory, so depending on the order that the compilation tasks would run, you could depend on classes from earlier compilation tasks.
Since there was no relationship between compileGroovy and compileScala, you were getting lucky that Groovy compilation would happen before Scala compilation.