Gradle 4 SourceSetOutput.setClassesDir deprecated


(Benjamin Schneider) #1

The Gradle 4.0 release notes suggest to add the following line to our Gradle scripts to change the output directory for the main source set back to the old path:

sourceSets.main.output.classesDir = new File(buildDir, "classes/main")

However, in doing so, I am using the deprecated method SourceSetOutput.setClassesDir.
The deprecation note says “Set the output directory for the particular {@link org.gradle.api.file.SourceDirectorySet}” - but I am not sure how to do that.

Could someone help me out and show how that call is supposed to look like?


(Sterling Greene) #2

If you need the old paths (to get certain 3rd party plugins to work with your build again), using setClassesDir is OK, but hopefully temporary.

If you can help it, you should try to keep the new default (separate class directories for each “language”).

If you want to just change the location for only Java sources, you can do this (this is using SourceDirectorySet):

sourceSets.main.java.outputDir = new File(buildDir, "some/path")