ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: ANT Task classpath?
Date Thu, 02 Sep 2004 02:16:58 GMT
Guru Balse <> wrote ..
> I am sure this has been discussed before, but I could not find it in the
> archives.  If my task depends on a particular set of jars in the classpath,
> how do I ensure that the task will work?  While I can set a classpath in
> the environment - I would like to avoid such a solution, or hack, as some
> of you would call this! :-)

check out the following;

<?xml version="1.0"?>

<!-- ===================================================== --> 
<!-- Library Paths					   --> 
<!-- ===================================================== --> 
<path id="checkstyle.class.path">
	<pathelement location="path_to_checkstyle"/>

<!-- ===================================================== --> 
<!-- taskdef					           --> 
<!-- ===================================================== --> 

<taskdef name="yourtask" classname="org.ant.taskdefs.testtask">
      <pathelement path="${classpath}"/>
      <fileset dir="lib">
        <include name="**/*.jar"/>
      <pathelement location="classes"/>
      <dirset dir="${build.dir}">
        <include name="apps/**/classes"/>
        <exclude name="apps/**/*Test*"/>
      <filelist refid="third-party_jars"/>

<taskdef resource="">
	<classpath refid="checkstyle.class.path"/>


see how you can supply taskdef with a classpath...which in turn can define a variety of path
structures..check out the manual on how to define classpaths

additionally your taskdef could reuse a defined path, as shown with the checkstyle example
paths which in turn can be used by taskdef using refid attribute.

hth, Jim Fuller

View raw message