[GRADLE-860] Ant Exec has stale ant.project.properties in Gradle but in Groovy is OK. Created: 19/Mar/10  Updated: 04/Jan/13  Resolved: 22/Mar/10

Status: Resolved
Project: Gradle
Affects Version/s: 0.8
Fix Version/s: None

Type: Bug
Reporter: Carlton Joseph Assignee: Hans Dockter
Resolution: Not A Bug Votes: 0

Attachments: File build.groovy    

 Description   

Below have:
1 - Log of Gradle failing
2 - Log of Groovy passing
3 - Gradle code
4 - Groovy code

1 - Log of Gradle failing =====================================================================
carlton@laptopDellLatD820:~/cjMounts/local/boot/sdx5_mainStore/cj2010work/code/gradleBug1$ gradle
:runs
return code: 0
stderr:
stdout: bob
return code: 0
stderr:
stdout: bob

BUILD SUCCESSFUL

Total time: 3.343 secs

2 - Log of Groovy passing =====================================================================
carlton@laptopDellLatD820:~/cjMounts/local/boot/sdx5_mainStore/cj2010work/code/gradleBug1$ groovy build.groovy
return code: 0
stderr:
stdout: bob
return code: 0
stderr:
stdout: fred

3 - Gradle code ===============================================================================
defaultTasks "runs"

task runs << {
execAnt("echo","bob")
execAnt("echo","fred")
}

String execAnt(String cmd, String arguments) {
ant.exec(outputproperty: "cmdOut",
errorproperty: "cmdErr",
resultproperty:"cmdExit",
failonerror: "true",
executable: cmd)

{ arg(line: arguments) }

println "return code: ${ant.project.properties.cmdExit}"
println "stderr: ${ant.project.properties.cmdErr}"
println "stdout: ${ant.project.properties.cmdOut}"
}

4 - Groovy code ===============================================================================
String runs () {
execAnt("echo","bob")
execAnt("echo","fred")
}

String execAnt(String cmd, String arguments) {
ant = new AntBuilder()
ant.exec(outputproperty: "cmdOut",
errorproperty: "cmdErr",
resultproperty:"cmdExit",
failonerror: "true",
executable: cmd)

{ arg(line: arguments) }

println "return code: ${ant.project.properties.cmdExit}"
println "stderr: ${ant.project.properties.cmdErr}"
println "stdout: ${ant.project.properties.cmdOut}"
}

runs()



 Comments   
Comment by Carlton Joseph [ 19/Mar/10 ]

changing the if to false or true in groovy code below also show the
issue (code below is same as attached file)

code =============================================================
ant = new AntBuilder();
ant.exec(outputproperty: "cmdOut",
errorproperty: "cmdErr",
resultproperty:"cmdExit",
failonerror: "true",
executable: "echo") {
arg(line: "bob")
}
println "return code: ${ant.project.properties.cmdExit}"
println "stderr: ${ant.project.properties.cmdErr}"
println "stdout: ${ant.project.properties.cmdOut}"
if (false) {
ant = null
ant = new AntBuilder();
}
ant.exec(outputproperty: "cmdOut",
errorproperty: "cmdErr",
resultproperty:"cmdExit",
failonerror: "true",
executable: "echo") {
arg(line: "fred")
}
println "return code: ${ant.project.properties.cmdExit}"
println "stderr: ${ant.project.properties.cmdErr}"
println "stdout: ${ant.project.properties.cmdOut}"

Comment by Carlton Joseph [ 22/Mar/10 ]

The issue is an Ant issue and not a Gradle or Groovy problem.
Look at http://jira.codehaus.org/browse/GROOVY-4114 for details.

Generated at Wed Jun 30 11:40:48 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.