I have a project called stubworld-corelib-android, which depends on stubworld-java-core, and here is the build.gradle file for stubworld-corelib-android:
dependencies {
compile 'com.android.support:appcompat-v7:+'
// use source dependency
compile project(':libraries:stubworld-corelib-java')
// uncomment this to use maven artifact dependency
// compile 'com.stubworld.core:CorelibJava:1.0'
}
Normally when I’m developing, I always directly depend on the source of stubworld-corelib-java, because this facilitates easier debugging and experimenting.
However, when I build a maven artifact, I can’t depend on the source of stubworld-corelib-java, because otherwise it produces an artifact that has invalid dependencies. Instead, I need to comment the source dependency and uncomment the maven dependency:
dependencies {
compile 'com.android.support:appcompat-v7:+'
// uncomment to use source dependency
// compile project(':libraries:stubworld-corelib-java')
// use maven artifact dependency
compile 'com.stubworld.core:CorelibJava:1.0'
}
This works, but it is really awkward with regards to build automation, because I need to have some hacky script that conditionally includes the right dependency.
Is there any way to perform this level of indirection in gradle instead?