Hi Adam,
I made a short test application to demonstrate it, and to ensure that it
wasn't an issue particular to my complicated build script.
The problem exists even in this simple script, and I paste the script, and
both running of the script (first linux, then windows XP) to show.
Please let me know if you get the same results. If not, and you'd like the
more verbose logout (-debug or stacktrace option) please let me know.
Obviously the point is, the two runs on linux result in different exit
values because the first provides the required property, the second not.
On windows, when the required propery is not provided, the script returns
with exit value zero anyway (incorrectly, I believe).
Sean
p.s. Please note, the only difference in the scripts run on linux and
windows, is that on linux, gradle is referred to as 'gradle', and on
windows, as 'gradle.bat' (otherwise, it won't run).
===================
script: build.gradle
---------------------------------
task first << {
println 'first!'
def moduleBuildResult = exec {
executable = 'gradle'
args = ['second',
"-Pmy_property="+"hello!!",
]
ignoreExitValue = true
}
println "Exit value for second build is: " +
moduleBuildResult.getExitValue()
moduleBuildResult = exec {
executable = 'gradle'
args = ['second'
]
ignoreExitValue = true
}
println "Exit value for second build is: " +
moduleBuildResult.getExitValue()
}
task second << {
println "second! ${my_property}"
}
========================================================
log out for linux:
--------------------
seanvb@svUbuntuX2:/mnt/data/dev2/bugtest$ gradle first
:first
first!
:second
second! hello!!
BUILD SUCCESSFUL
Total time: 3.372 secs
Exit value for second build is: 0
:second
FAILURE: Build failed with an exception.
* Where:
Build file '/mnt/data/dev2/bugtest/build.gradle' line: 30
* What went wrong:
Execution failed for task ':second'.
Cause: Could not find property 'my_property' on task ':second'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
BUILD FAILED
Total time: 3.246 secs
Exit value for second build is: 1
BUILD SUCCESSFUL
===========================================
log out for windows
----------------------------------------
D:\dev\scripts\testbug>gradle first
:first
first!
:second
second! hello!!
BUILD SUCCESSFUL
Total time: 2.543 secs
Exit value for second build is: 0
:second
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\dev\scripts\testbug\build.gradle' line: 30
BUILD FAILED
Total time: 2.474 secs
* What went wrong:
Execution failed for task ':second'.
Cause: Could not find property 'my_property' on task ':second'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
Exit value for second build is: 0
BUILD SUCCESSFUL
Total time: 9.253 secs
D:\dev\scripts\testbug>
> Does your log file contain anything useful?
>
>
> println "Exit value for module build is: " +
> moduleBuildResult.getExitValue()
> if (moduleBuildResult.getExitValue()==0)
> {
> getByName('aggregateModuleTests').execute()
> getByName('distributeProducts').execute()
> getByName('notifyOfModuleBuildSuccess').execute()
> }
> else
> {
> println "Error! The module build has NOT been successful. Distributions
> and consolidated reports will not be made!"
> getByName('notifyOfModuleErrors').execute()
> }
>
>
>
>
> --
> Adam Murdoch
> Gradle Co-founder
> http://www.gradle.org
> VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
> http://www.gradleware.com
>
>