I am relatively new to gradle so please be patient with me. My build.gradle:
def releaseBol = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
lintOptions {
abortOnError false
}
...
if (project.hasProperty('RELEASE') && project.ext.RELEASE == '1')
releaseBol = true
if (releaseBol)
{
..
//some code
..
}
}
...
task runScheduleReader() {
javaexec {
println 'here1'
main="-jar";
args = [
"../Generator.jar"
]
}
}
What I wish to is to run runScheduleReader if releaseBol is set to true, but I get an error when just moving it there, how can I do this?
Try:
task runScheduleReader() {
enabled = releaseBol
doLast {
javaexec {
println 'here1'
main="-jar";
args = [
"../Generator.jar"
]
}
}
}
Please have a look at enabling and disabling tasks. The second problem is that you added the logic at configuration time so it will be executed every time the script is evaluated. You need to add an action with doLast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With