Sorted - i didn't have the bcel.jar in my lib folder. Added it and it
works fine.
Sooooooooooo - Nicolas, *if* you have bcel.jar installed, you can use
the example below to get your version string out of your file!
(but you shouldn't ;)
/t
>-----Original Message-----
>From: RADEMAKERS Tanguy
>Sent: Tuesday, September 20, 2005 8:26 PM
>To: 'Ant Users List'
>Subject: RE: Extracting application version from Java file
>
>Hello List,
>
>I was going to reply to Nicolas that, whilst i agree with the
>other two replies (you should pass the version in somehow and
>not read it from the java source file), you *can* achieve what
>he is trying to do using the <loadproperties> task with a
>nested <classconstants> filterchain. But i can't seem to get
>it to work. I've posted my example below, can anybody see what
>i'm doing wrong?
>
>------mytest.java----
>public class mytest
>{
> public static final String VERSION = "XX.YY.ZZ";
>
> public static void main(String[] args)
> {
> System.out.println("Hello, World!");
> }
>}
>
>------build.xml----
><project name="test" default="main" basedir=".">
>
> <target name="main">
>
> <javac srcdir="."
> destdir="."
> includes="mytest.java"/>
>
> <loadproperties srcfile="mytest.class">
> <filterchain>
> <classconstants/>
> </filterchain>
> </loadproperties>
>
> <echo>${VERSION}</echo>
>
> </target>
>
></project>
>
>i get a "Unable to load file: java.io.IOException" message.
>I've tried putting a static properties file and loading that -
>no probs. I've tried copying the class to a properties file by
>using the classconstants filterchain... didn't work (same error).
>
>/t
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]