I have multiple build types defined in my build.gradle. In variant window I selected build variant (ex debugAPI23). I expected that code in only one build type will be executed. But in Gradle Console I can see output for all build types.
As you can see I am trying to remove specific file for each build type. But everytime all build types are executed. So in the end I am missing the file that should be present for my selected build type.
android {
buildTypes {
debug {
println "build type debug"
debuggable true
signingConfig signingConfigs.debug
sourceSets {
main.java {
exclude '/cz/kctdata/kmf/Reader/KMFReaderCN51A60.java'
}
main.java.getIncludes().each { println "Added include: $it" }
main.java.sourceFiles.each { println "File in source set: " + it }
}
}
release {
println "build type release"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
sourceSets {
main.java {
exclude '/cz/kctdata/kmf/Reader/KMFReaderCN51A60.java'
}
main.java.getIncludes().each { println "Added include: $it" }
main.java.sourceFiles.each { println "File in source set: " + it }
}
}
debugAPI23 {
println "build type debugAPI23"
debuggable true
signingConfig signingConfigs.debug
sourceSets {
main.java {
exclude '/cz/kctdata/kmf/Reader/KMFReaderCN51A42.java'
}
main.java.getIncludes().each { println "Added include: $it" }
main.java.sourceFiles.each { println "File in source set: " + it }
}
}
releaseAPI23 {
println "build type releaseAPI23"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
sourceSets {
main.java {
exclude '/cz/kctdata/kmf/Reader/KMFReaderCN51A42.java'
}
main.java.getIncludes().each { println "Added include: $it" }
main.java.sourceFiles.each { println "File in source set: " + it }
}
}
}
}
I can not use build type specific folder because I have more build types and some files should be presented in multiple build types. I don't want to have multiple copies of same file in my project.