On Oct 6, 2008, at 6:54 PM, Victor Ott wrote:
Hi Hans,
On Mon, Oct 6, 2008 at 4:26 PM, Hans Dockter <[EMAIL PROTECTED]> wrote:
On Oct 6, 2008, at 3:32 PM, Victor Ott wrote:
[...]
I had been confused by this as well. This config.xml is one way to
configure
how launch4j _generates_ the gradle.exe at build time.
Yes, and I suppose the issue is there, in the way "gradle.exe" was
generated. Those properties can't be overridden at runtime, at least
according to the docs:
"When you create a wrapper or launcher all configuration details are
compiled into the executable and cannot be changed without recreating
it or hacking with a resource editor."
That's why I was looking for that file, and strongly expected it to be
in the SVN repository(!?). Without it, Launch4J config must be done
from scratch.
See the build.gradle file (from line 199):
http://svn.gradle.codehaus.org/browse/gradle/gradle-core/tags/REL-0.4/
build.gradle?r=901
<snip>
I've added a last line to my script, right after the JAVACMD call:
"echo return code: %ERRORLEVEL%" and the value returned by java.exe is
always "0", even when the build fails!?
As if the whole thing is not complicated enough already, you have run
into a Gradle bug which is fixed in trunk: http://jira.codehaus.org/
browse/GRADLE-232
PS
As PoC I've forced a Gradle error early by calling with conflicting
arguments: "gradle.cmd -i -j " [Btw, Gradle returns code 0 on invalid
arguments... Main.main() line 115, should be System.exit(1) or so].
The result is:
==========
D:\xyz\Prj>gradle.cmd -i -j
[...]
Error: For the dependency output you must either set -i or -j. Not
Both!
return code: 1
D:\xyz\Prj>echo %ERRORLEVEL%
1
D:\xyz\Prj>
==========
The message "return code..." is from inside my CMD script. The
"D:\xyz\Prj>echo %ERRORLEVEL%" is typed on command line, after
gradle.cmd has run: 1 => Return code was successfully passed to
caller.
This is interesting. I wanted to write that we have tried all this
and it was of no avail (see http://jira.codehaus.org/browse/
GRADLE-58). But in fact it seems to work yet certain things are still
confusing to me.
If I call from my shell 'ant unknownTask', calling echo %ERRORLEVEL%
afterwards give me 1. If I do the following, an exit value of 0 is
printed by this Groovy script.
String command = 'ant unknownTask'
ByteArrayOutputStream outStream = new ByteArrayOutputStream()
ByteArrayOutputStream errStream = new ByteArrayOutputStream()
Process proc = ['cmd', '/c', command].execute()
proc.consumeProcessOutput(outStream, errStream)
proc.waitFor()
String output = outStream
String error = errStream
println proc.exitValue()
println "Output"
println output
println "Error"
println error
I have created the following class:
public class ErrorMain {
public static void main(String[] args) {
System.exit(1);
}
}
I have a script.cmd that contains one line: java -cp <somepath>
ErrorMain
If I change the command value in the Groovy script above to:
<somepath>/script.cmd an exit value of 1 is printed. I thought in
such a scenario you will always get an exit value of 0 (like in the
Ant case above). I would have bet quite a bit of money that this is
the case as I had played around with this a lot a couple of months
ago. If I rename script.cmd to script.bat I have the same behavior (I
get 1). I still don't know why in the Ant case it behaves differently.
Out of the sudden it looks easy to solve the problem with a non zero
exit value. If this is really the case (I'm still worried that I'm
missing something) we definitely should ditch launch4j ASAP and
replace it with a cmd script.
Therefore I conclude that not all code paths are end with
System.exit(code!=0). Here the end of v0.4 org.gradleMain.main(): if
build.run() does not throw a exception, the error code returned to
caller will always be "0":
========================
/* 230*/ try
{
/* 230*/ Build build = Build.newInstance(startParameter);
/* 232*/ build.addBuildListener(exceptionReporter);
/* 233*/ build.addBuildListener(resultLogger);
/* 235*/ build.run(startParameter);
}
/* 236*/ catch (Throwable e)
{
/* 237*/ exceptionReporter.buildFinished(new BuildResult
(null, e));
/* 238*/ exitWithError(options, e);
}
/* 240*/ exitWithSuccess(options);
========================
Again, this is the fixed http://jira.codehaus.org/browse/GRADLE-232 bug.
- Hans
--
Hans Dockter
Gradle Project lead
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email