You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jake Ewerdt <ja...@emeta.com> on 2004/01/08 22:54:07 UTC

Java output

I need to capture the result of running the java task in the maven.xml file.  The same code works in an ant build.xml file, and it should work in the maven.xml file.

==== Java file ====
package com.jake;
public class Jake {
    public static void main(String []args) {
        System.out.println("Regular Output");
        System.out.println("Error Output");
        System.exit(1);
    }
}


==== build.xml target ====
  <target name="java-output">
    <path id="test.classpath">
        <fileset dir="target/classes"><include name="com/jake/Jake.class" /></fileset>
    </path>
    <java classname="com.jake.Jake" classpath="target/classes" fork="true" failonerror="false" outputproperty="testoutput" errorproperty="testerror" resultproperty="testresult" />
    <echo message="testresult = ${testresult}" />
    <echo message="testerror  = ${testerror}" />
    <echo message="testoutput = ${testoutput}" />
  </target>


==== maven.xml goal ====
  <goal name="java-output">
    <path id="test.classpath">
      <fileset dir="target/classes"><include name="com/jake/Jake.class" /></fileset>
    </path>
    <java classname="com.jake.Jake" classpath="target/classes" fork="true" failonerror="false" outputproperty="testoutput" errorproperty="testerror" resultproperty="testresult" />
    <echo message="testresult = ${testresult}" />
    <echo message="testerror  = ${testerror}" />
    <echo message="testoutput = ${testoutput}" />
  </goal>


++++ Ant output ++++
java-output:
     [java] Java Result: 1
     [echo] testresult = 1
     [echo] testerror  =
     [echo] testoutput = Regular Output
     [echo] Error Output


++++ Maven output ++++
java-output:
    [java] Regular Output
    [java] Error Output
    [java] [ERROR] Java Result: 1
    [echo] testresult =
    [echo] testerror  =
    [echo] testoutput =


I should probably complain that the testerror property in the ant call isn't being set either, but the testresult is the only property I really need set =)  Any ideas how to get the exit value of a java task in maven?

-jake



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org