ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jful...@ruminate.co.uk
Subject Re: ANT Task classpath?
Date Thu, 02 Sep 2004 02:16:58 GMT
Guru Balse <guru.balse@oracle.com> 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"?>
<project>

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

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

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

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

</project>

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
http://ant.apache.org/manual/using.html#path

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


Mime
View raw message