Getting compile errors on classes which exist in configurations.compile

I have a coworker who doesn’t want to jar anything. So In my dependencies dependencies {

compile files(

fileTree(‘R:/xxx/yyy/WebContent/WEB-INF/classes’) {include ‘zzz/*.class’},










for (File file : configurations.compile)





When I look at the output from printing the configurations.compile, it contains classes the compiler says it can’t find?

the rest of my is:

apply plugin: ‘java’ sourceCompatibility = 1.6 version = ‘1.0’

sourceSets {

main {

java {

srcDir ‘src’


} }

dependencies {


jar {

manifest {

attributes ‘Implementation-Title’: ‘aaa’,

‘Implementation-Author’: ‘bbb’,

‘Implementation-Version’: version

} }

Your issue is you are using a ‘FileTree’ for your classes directory. A ‘FileTree’ is evaluated in this case as a collection of files. In this instance the paths returned by the ‘files()’ method are simply added to the classpath when calling ‘javac’. When adding .class files to your classpath you must point to a directory that contains .class files, not the individual files themselves. See the Oracle documentation for more info.

“For .class files in a named package, the class path ends with the directory that contains the “root” package (the first package in the full package name).”

Modify your script to simply point at the directory containing the class files.

dependencies {

compile files(‘R:/xxx/yyy/WebContent/WEB-INF/classes’)


For a better explanation of what I’m talking about add the following task to your script and run it before and after the script change above.

task printClasspath << {

println compileJava.classpath.asPath


Thanks so much for the quick and thorough answer. Really appreciate it!!!