I added a new Java source folder release
(app/src/release/java) for our release buildType. For this Android Studio automatically added this line to my app/build.gradle:
sourceSets { release { java.srcDirs = ['src/release/java', 'src/release/java/'] } }
We already had some code in the debug
folder (app/src/debug/java) for our debug buildType. And there is no entry in the app/build.gradle file for debug source set.
And our release and debug builds are working as expected with and without the sourceSet entry.
So, is it that gradle looks for the source for build type x
in app/src/x/java
by default while building.
If yes, why did Android-Studio added the sourceSet line in build.gradle for me?
Ok, so Android Studio had added sourceSet to build.gradle cause I had marked 'Change Folder Location' while adding folder 'release' for buildType 'release'.
And by default Gradle does look for the source for build type x
in app/src/x/java
.
For example, for debug build type, there's no sourceSet entry in build.gradle. And on ./gradlew sourceSets
it gives:
So there's no need to add sourceSet to build.gradle if you are not using custom folder structure.