Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput

I’m trying to bump from a (very, I know) old Gradle 2.10 to current 5.2.1 in for and it fails saying:

Build file '/home/vorburger/dev/Mifos/git/fineract/fineract-provider/build.gradle' line: 77

* What went wrong:
A problem occurred evaluating root project 'fineract-provider'.
> Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

that line 77 in is:

openjpa {
    files = fileTree(sourceSets.main.output.classesDir).matching {
		include '**/AbstractPersistableCustom.class'
		include '**/domain/*.class'

    enforcePropertyRestrictions = true

How do I adapt this so that it works with the current Gradle version?

Could not find property 'classesDir' on source set main is an older forum entry re. something that looks similar, but I don’t see how it applies here - it IS sourceSets.main.output.classesDir.

Hey Michael,

File classesDir has been replaced by FileCollection classesDirs. so you should be able to use classesDirs.filter{} here.

yup, thanks a lot, looks like this does the trick:

openjpa {
    files = fileTree(sourceSets.main.output.classesDirs.filter {
		include '**/AbstractPersistableCustom.class'
		include '**/domain/*.class'
    enforcePropertyRestrictions = true

but a have similar follow-up problem, related to

sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir

so Gradle now supports several classesDirs but there is still only a single resourcesDir, so how does one upgrade in this case?

As a bit of background, I believe the SourceSetOutput.getClassesDir() changed to SourceSetOutput.getClassesDirs() so that you could compile java, groovy and/or scala etc in the same project with each task’s outputs separated so that UP-TO-DATE task skipping works properly. If your project only has java sources you could do

sourceSets.main.output.resourcesDir =
sourceSets.test.output.resourcesDir =

If you need a single classesDir and have groovy/scala and/or java in the same project you might need a copy task.


task copyClasses(type: Copy) {
    dependsOn [compileJava, compileScala, compileGroovy] 
    sourceSets.main.output.classesDirs.each {
        from it
    into "$buildDir/allclasses" 
task copyTestClasses(type: Copy) { ... } 
processResources.dependsOn copyClasses 
processTestResources.dependsOn copyTestClasses
sourceSets.main.output.resourcesDir = file("$buildDir/allclasses") 
sourceSets.test.output.resourcesDir = file("$buildDir/alltestclasses")

Thanks, that works! (New problems unrelated to this in separate posts.)

Hi Guys,

I am using appengine pulgin which says same error. Here is the build.gradle file. Could you please help me on this?
“Could not get unknown property ‘classesDir’ for functional test classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.”


apply plugin: ‘war’
apply plugin: ‘appengine’

war {
version = ‘1.0’
expand appengineProjectName: appengineProject

appengine {
downloadSdk = true

dependencies {
compile ‘javax.servlet:servlet-api:2.5’
compile ‘jstl:jstl:1.2’
compile ‘com.googlecode.objectify:objectify:5.1.14’
compile ‘’
appengineSdk ‘’

Sir , i have the same problem would you help me out to fix it ?