Currently I am developing an app with gradle and I have lots of different sourcesets
for some different flavors. I am adding sourcesets
in my build.gradle
the following way:
sourceSets {
debug {
java.srcDirs += ['src/firstLib/common/java']
}
release {
java.srcDirs += ['src/firstLib/common/java']
}
}
Because I have lots of this blocks in my build.gradle
I was wondering if there is an possibility to simply call a function which takes the sourcesets
as a parameter and add it to the java.srcDirs
. For example something like this:
void addToSourceSet(String parameter) {
sourceSets {
debug {
java.srcDirs += [parameter]
}
release {
java.srcDirs += [parameter]
}
}
}
Is this possible even if the method body isn't part of the gradle android-tag?