Not sure but perhaps my gradle-java-flavours plugin could help here. Eg:
plugins { id "com.lazan.javaflavours" version "1.2" } javaFlavours { flavour 'debug' flavour 'release' } debugJar { version = "${project.version}-debug" } releaseJar { version = "${project.version}-release" } Each flavour gets it's own Jar and JavaCompile tasks etc and you can specify custom sources, resources, tests, dependencies for each flavour too.
See here for a bit more overview on the tasks, directories and configurations avaliable and here for a test which covers the functionality.
This approach differes from your GradleBuild style since the "flavours" can happily live together in a single project which builds multiple artifacts rather than running a project twice with two different parameters.