Sources included in jars on the compile classpath are compiled with the rest of the sources

This is due to a quirk of the java compiler See below from Oracle’s javac documentation

">If the -sourcepath option is not specified, the user class path is also searched for source files. "

if the compileJava task had the equivalent of the below code added by default, this would not happen.

compileJava.options.compilerArgs += “-sourcepath” compileJava.options.compilerArgs += “”

I can’t think of anytime I would want sources included with classpath jars compiled in with the rest of my code

Relevant discussion:


compileJava.options.compilerArgs << '-implicit:none'

Related discussion