You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by hdockter <ma...@dockter.biz> on 2008/05/03 19:26:37 UTC
Taskdef and custom classloader
With a Groovy based build tool I have the following problem.
The JVM this build tool is running in, is started with a jar in the
classpath that contains a certain Ant task (groovyc). What I need now is a
way to define a groovyc task from _another_ jar with a different version.
I try to do this the following way:
<taskdef name="isolatedLoader"
classname="org.gradle.api.tasks.util.IsolatedLoader"/>
<isolatedLoader ref="loader">
<classpath path='path+with_other_groovyc_and_ant'/>
</isolatedLoader>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"
loaderref="loader"/>
The lsolatedLoader class looks like this:
class IsolatedLoader extends MatchingTask {
private String name;
private Path taskClasspath;
/**
* sets the name of the reference which should store the Loader
*/
public void setRef(String n){
name = n;
}
public void execute() throws BuildException {
Project project = getProject();
AntClassLoader loader = new AntClassLoader();
loader.setClassPath(taskClasspath);
loader.setParent(getClass().classLoader.systemClassLoader.parent))
project.addReference(name,loader);
}
...
}
When I now execute the groovyc task, Ant can't find it.
If I try a different way of achieving my goal, this is when I define the
IsolatedLoader like:
public void execute() throws BuildException {
Project project = getProject();
AntClassLoader loader = new AntClassLoader();
loader.setClassPath(taskClasspath);
loader.setParentFirst(false);
project.addReference(name,loader);
I do get ClassCastExceptions.
Has anybody an idea how I completely isolate a taskdef from an existing
classpath?
- Hans
--
View this message in context: http://www.nabble.com/Taskdef-and-custom-classloader-tp17036211p17036211.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org