Solved

How to get the classpath from ant build file

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This video teaches viewers about errors in exception handling.
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.

776 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