I am trying to run JBoss TattleTale from an Ant buildfile. Usually I run it from the commandline like so:
java -Xmx512m -jar /home/myuser/jars/tattletale.jar /home/myuser/projects/lib /home/myuser/tmp/tt
where /home/myuser/projects/src
is the source directory where all my JARs are, and where /home/myuser/tmp/tt
is the output directory where I place all of TattleTale's reports.
In the Ant buildfile I am using the following:
<echo message="Running tattle-tale..."/>
<java fork="true" failonerror="true" jar="/home/myuser/jars/tattletale.jar">
<arg value="Xmx512m"/>
<arg value="/home/myuser/projects/lib"/>
<arg value="/home/myuser/tmp/tt"/>
</java>
When I run this target from the commandline:
run-tattletale:
[echo] Running tattle-tale...
BUILD SUCCESSFUL
Total time: 3 seconds
When I go to /home/myuser/tmp/tt
I don't see any output, however the Ant output shows SUCCESS
with no errors or warnings. Do my <arg>
s look correct, and if not, how should I change them? If they do look correct, what can I do to debug? Thanks in advance!
Two things:
Try using the debug option when running Ant, and save the output into a logfile. Then look at the log file. It will show you how it is executing the Java command. That will help you figure out where the Ant <java>
is differing from the way you run Java directly from the command line. It'll give you the ability to tweek your <java>
task.
When a parameter is for the java
command itself, you use <jvmarg>
and not <arg>
:
An example:
<echo message="Running tattle-tale..."/>
<java fork="true"
failonerror="true"
jar="/home/myuser/jars/tattletale.jar">
<jvmarg value="-Xmx512m"/> <!-- Note the dash! -->
<arg value="/home/myuser/projects/lib"/>
<arg value="/home/myuser/tmp/tt"/>
</java>
Try that, and run with ant -d | tee ant.out
if you're on Unix/Linux. On Windows, you'll have to do ant -d > ant.out.txt
which will save the output in ant.out.txt
, but won't display the output while ant
is running.
The first args is a JVM argument not a program argument so <arg>
is the wrong syntax. For this case it's easier to use the maxmemory
parameter of the java
task.
So remove the first <arg>
and put maxmemory=512m
in the <java>
block.
If you see no output in target directory, it may be due to 1) there is no archive in given input directory or 2) tattletale process is failing.
In case of failure or exception, tattletale process seems returning exit code 0
and it makes ant believe that the process execution is successful.
For debugging, I suggest you to
ensure given directory is correct and has java archive (jar) files and analyze the standard output/errors produced by tattletale
.
Example:
<echo message="Running tattle-tale..."/>
<java fork="true"
failonerror="false"
errorproperty="errorproperty"
outputproperty="outputproperty"
jar="/home/myuser/jars/tattletale.jar">
<jvmarg value="-Xmx512m"/> <!-- Note the dash! -->
<arg value="/home/myuser/projects/lib"/>
<arg value="/home/myuser/tmp/tt"/>
</java>
<echo message="stdout>> ${outputproperty}"/>
<echo message="stderr>> ${errorproperty}" />
Note:- failonerror
is false temporarily for debugging purpose only.
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