Resolving classpath with ant's taskdef and running only required target

904 Views Asked by At

my main-build.xml looks like:

<path id="run.classpath">
        <pathelement location="${build.lib.dir}/ant-{version}.jar"/>
        <pathelement location="${third-party.lib.dir}/some-{my-ver}.jar"/>
</path>

deploy.xml uses taskdef ant task on one of class present inside third-party jar:

<taskdef name="run-third-party-exec" classname="package.name.ThirdPartyExec"/>

sub-build.xml imports main-build.xml & deploy.xml and tries to run a ant target present in deploy.xml but fails complaining

taskdef package.name.ThirdPartyExec cannot be found

How to resolve such problem. Since all taskdefs & imports get executed when we import a file prior to executing a target its failing. Not sure on adding all complaining thirdparty jar's to ant's classpath is right way or not?.

1

There are 1 best solutions below

2
On

Your <taskdef> needs to know where to find package.name.ThirdPartyExec. Do this by providing the classpath:

<taskdef 
    name="run-third-party-exec" 
    classname="package.name.ThirdPartyExec" 
    classpathref="run.classpath" 
/>