Solved

How to get the classpath from ant build file

Posted on 2008-06-13
5
1,675 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

809 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