I have few flavors defined and would like to take additional source for one of it:
sources {
c {
source {
srcDir "src"
include "foo.c"
if (flavor == flavors.my ) {
include "foo2.c"
}
}
}
}
This is no allowed since I get complaining “> No such property: flavor for class: org.gradle.api.internal.file.DefaultSourceDirectorySet” Where should I put my flavor’s condition?
I’ve changed it by adding binaries.all, so I don’t have mentioned error. However with that approach foo2.c is taken to all flavors, which is not expected.
Of course I can use targetFlavors, but that needs do define new components per condition. Is there a simpler way to have different sources per flavor.
but as soon as “C(CSourceSet)” is changed to “c”, than it stops to work.
I don’t really know how does it work in the gradle’s community. Should I raise a bug?
Thanks, your code works. In your example different CSourceSet are taken for different conditions platformWindows(CSourceSet) and platformLinux(CSourceSet). It also works where sourceSet names are not unique as in my example (if condition is true or false C(CSourceSet) is taken).
So I still don’t understand why default sources.c doesn’t work. Behavior when using sources.name(CSourceSet) or sources.c should be the same, but it isn’t.