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

>-----Original Message-----
>From: Nicolas Vervelle [mailto:[EMAIL PROTECTED] 
>Sent: Tuesday, September 20, 2005 6:23 PM
>To: user@ant.apache.org
>Subject: Extracting application version from Java file
>
>Hi,
>
>In one of my Java source file, I have a line like this:
>public final static String version = "XX.YY.ZZ";
>
>I'd like to extract the XX.YY.ZZ from the Ant build to name the 
>resulting jar file with it : Jmol.XX.YY.ZZ.jar
>
>Can someone help me with how to extract the string from the file ?
>
>Thanks in advance,
>Nicolas
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to