Link to home
Start Free TrialLog in
Avatar of dportabella
dportabella

asked on

How to get the classpath from ant build file

I have a ant build file as follows:
+++++++++++
<project name="test" basedir=".">
      <property name="lib.dir"           value="/data/java_library/ext"/>
      <path id="project.classpath">
            <fileset dir="${lib.dir}">
                  <include name="**/*.jar"/>
                  <include name="**/*.zip"/>
            </fileset>
      </path>
</project>
++++++++++++

I would to run something like:

MYCLASSPATH=`ant -q cp`

which should set the environment variable MYCLASSPATH to whatever is defined in the ant build file.

how can I do that?


DAvid
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dportabella
dportabella

ASKER

It works!
Thanks CEHJ.


If someone is interested, add this to the build.xml
++++++++
      <property name="cp" refid="project.classpath" />
      <target name="cp" description="Shows the classpath">
            <echo message="${cp}"/>
      </target>
++++++++
And then execute:
MYCLASSPATH=`ant -q cp | sed -n -e "s/     \[echo\] //p"`


DAvid
:-)

You might find it more convenient to do
      <property name="cp" refid="project.classpath" />
        <echo message="${cp}" file="cp.txt" />

Open in new window

Thanks!

DAvid
And of course you could always print it from your app ;-)