ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Flemetakis" <cflem...@hotmail.com>
Subject Re: Classpath stored in a single position?
Date Thu, 06 Sep 2001 20:04:01 GMT
You most definately do NOT have to have multiple classpaths in each build 
file. There is more than 1 approach to take with this.. I will present you 
with 2

1) You can create a global properties file (global.properties). In that 
properties file have an classpath value and make it equal to your classpath. 
Then in each build.xml import the global.properties file and reference the 
classpath variable for all the tasks that require a classpath (such as 
javac)

Examples are

#global.properties
my_classpath=l:/Java/build/;C:/ABI/arrays/lib/816classes12.zip.. etc etc

#build.xml
<property file="c:\ant1.4\global.properties" />

<javac .... classpath="${my_classpath}"

2) This second one is a bit dangerous and requires strict control of your 
libraries but you can use the <path> attribute to import libraries. This is 
really good in the sense that it picks up all the libraries that you put in 
specified directories but because this is a catch-all technique you have to 
make sure that you don't place libraries that you do not want.

Example

#build.xml
<path id="lib_classpath">

<pathelement path="xyz.jar"/>

<fileset dir="${dir.lib}">
    <include name="**/*.jar"/>
    <include name="**/*.zip"/>
</fileset>
</path>

You can use a combination of pathelements and filesets to include the libs 
you want. Then for you javac task (or any other one needing a classpath) you 
can use the following

<javac ... classpath refid="lib_classpath"/>

Hope this helps you a bit...
Chris

>From: Ralph Jocham <rjocham72@yahoo.com>
>Reply-To: ant-user@jakarta.apache.org
>To: ant-user@jakarta.apache.org
>Subject: Classpath stored in a single position?
>Date: Thu, 6 Sep 2001 08:48:21 -0700 (PDT)
>
>Hi,
>in our project we do have a rather long classpath.
>Currently I have this build.xml file in each package
>folder. (see below) But the Classpath changes often,
>so I have to change each build.xml file in each
>folder.
>Is it possible to extract the classpath into a single
>position from where it is being picked up by the
>build.xml file. That way I just have to change the
>classpath only once.
>
>TIA
>Ralph
>
><project name="Test" default="compile" basedir=".">
>
>   <!-- set global properties for this build -->
>   <property name="src" value="."/>
>   <property name="build" value="L:/java/build"/>
>
>   <target name="init">
>     <!-- Create the time stamp -->
>     <tstamp/>
>   </target>
>
>   <target name="compile" depends="init">
>     <!-- Compile the java code from ${src} into
>${build} -->
>     <javac srcdir="${src}"
>            destdir="${build}"
>	   debug="on">
>	   <include name="*.java"/>
>	   <exclude name="test/**"/>
>	   <classpath
>path="l:/Java/build/;C:/ABI/arrays/lib/816classes12.zip;C:/ABI/arrays/lib/AppClasses.jar;C:/ABI/arrays/lib/castor-0.9.2-xml.jar;C:/ABI/arrays/lib/classes12.zip;C:/ABI/arrays/lib/comm.jar;C:/ABI/arrays/lib/corelib.jar;C:/ABI/arrays/lib/crimson.jar;C:/ABI/arrays/lib/dta.jar;C:/ABI/arrays/lib/fmprtl.zip;C:/ABI/arrays/lib/jai_codec.jar;C:/ABI/arrays/lib/jai_core.jar;C:/ABI/arrays/lib/jaxp.jar;C:/ABI/arrays/lib/log4j.jar;C:/ABI/arrays/lib/mlibwrapper_jai.jar;C:/ABI/arrays/lib/nav.jar;C:/ABI/arrays/lib/reqres.jar;C:/ABI/arrays/lib/rtc.jar;C:/ABI/arrays/lib/security.jar;C:/ABI/arrays/lib/sms.jar;C:/ABI/arrays/lib/Tools.jar;C:/ABI/arrays/lib/TOPLink.jar;C:/ABI/arrays/lib/TOPLinkX.jar;C:/ABI/arrays/lib/xalan.jar;C:/ABI/arrays/lib/xerces.jar;C:/JBoss-2.2.2/lib/jaas.jar;C:/JBoss-2.2.2/lib/jaxp.jar;C:/JBoss-2.2.2/lib/jboss-jass.jar;C:/JBoss-2.2.2/lib/jdbc2_0-stdext.jar;C:/JBoss-2.2.2/lib/jmxri.jar;
>C:/JBoss-2.2.2/lib/xml.jar;C:/JBoss-2.2.2/lib/ext/ab-jnpserver.jar;C:/JBoss-2.2.2/lib/ext/activation.jar;C:/JBoss-2.2.2/lib/ext/awt.jar;C:/JBoss-2.2.2/lib/ext/classes12.zip;C:/JBoss-2.2.2/lib/ext/connector.jar;C:/JBoss-2.2.2/lib/ext/dynaserver.jar;C:/JBoss-2.2.2/lib/ext/ejb.jar;C:/JBoss-2.2.2/lib/ext/ejb2.jar;C:/JBoss-2.2.2/lib/ext/ejxeditor.jar;C:/JBoss-2.2.2/lib/ext/ejxejb.jar;C:/JBoss-2.2.2/lib/ext/ejxjaws.jar;C:/JBoss-2.2.2/lib/ext/ejxjboss.jar;C:/JBoss-2.2.2/lib/ext/exolabcore-0.1.jar;C:/JBoss-2.2.2/lib/ext/gnu-regexp-1.0.8.jar;C:/JBoss-2.2.2/lib/ext/hsql.jar;C:/JBoss-2.2.2/lib/ext/idb.jar;C:/JBoss-2.2.2/lib/ext/jboss.jar;C:/JBoss-2.2.2/lib/ext/jbosscx-0.2.jar;C:/JBoss-2.2.2/lib/ext/jbossmq.jar;C:/JBoss-2.2.2/lib/ext/jbosssx.jar;C:/JBoss-2.2.2/lib/ext/jdbm.jar;C:/JBoss-2.2.2/lib/ext/jetty-service.jar;C:/JBoss-2.2.2/lib/ext/jms.jar;C:/JBoss-2.2.2/lib/ext/jmxtools.jar;C:/JBoss-2.2.2/
>lib/ext/jndi.jar;C:/JBoss-2.2.2/lib/ext/jnpserver.jar;C:/JBoss-2.2.2/lib/ext/jpl-util-0_5b.jar;C:/JBoss-2.2.2/lib/ext/jta-spec1_0_1.jar;C:/JBoss-2.2.2/lib/ext/log4j.jar;C:/JBoss-2.2.2/lib/ext/log4j-old.jar;C:/JBoss-2.2.2/lib/ext/mail.jar;C:/JBoss-2.2.2/lib/ext/minerva-1_0b3.jar;C:/JBoss-2.2.2/lib/ext/openjms-client-patched-0.5.1.jar;C:/JBoss-2.2.2/lib/ext/openjms-patched-0.5.1.jar;C:/JBoss-2.2.2/lib/ext/openjms-pool.jar;C:/JBoss-2.2.2/lib/ext/openjms-rmi-patched-0.5.1.jar;C:/JBoss-2.2.2/lib/ext/tomcat-service.jar;C:/JBoss-2.2.2/lib/ext/crimson.jar"/>
>     </javac>
>   </target>
></project>
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


Mime
View raw message