Solved

How to get the classpath from ant build file

Posted on 2008-06-13
5
1,646 Views
Last Modified: 2008-06-13
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
0
Comment
Question by:dportabella
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 21780924
See below:
<property name="cp" refid="project.classpath" />

<echo message="${cp}" />

Open in new window

0
 

Author Comment

by:dportabella
ID: 21781304
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21781434
:-)

You might find it more convenient to do
      <property name="cp" refid="project.classpath" />

        <echo message="${cp}" file="cp.txt" />

Open in new window

0
 

Author Comment

by:dportabella
ID: 21781497
Thanks!

DAvid
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21781588
And of course you could always print it from your app ;-)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now