If I have a simple gradle java build, can I somehow swap out one of the jar dependencies, say jarX for jarY based on a flag?
e.g.:
if running ./gradlew build
- then include jarX
but if running ./gradlew build -specialBuild
- then include jarY instead of jarX
Yes, you can use conditional statements on the dependencies {}
closure.
dependencies {
if (project.hasProperty("useX")) {
implementation 'x:x:x'
} else {
implementation 'y:y:y'
}
}
call as
gradle -PuseX=true