From 9c16e724ba9081e4a056769853afe7cf78f6cf9e Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 17 Mar 2015 08:28:01 -0700 Subject: [PATCH] Support setting classpath directly. --- .../com/threerings/presents/tools/GenTask.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/src/main/java/com/threerings/presents/tools/GenTask.java b/tools/src/main/java/com/threerings/presents/tools/GenTask.java index eaabc8d2c..af459100d 100644 --- a/tools/src/main/java/com/threerings/presents/tools/GenTask.java +++ b/tools/src/main/java/com/threerings/presents/tools/GenTask.java @@ -40,6 +40,7 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.ClasspathUtils; @@ -75,7 +76,7 @@ public abstract class GenTask extends Task } } - /** Configures our classpath which we'll use to load service classes. */ + /** Configures the classpath which we'll use to load service classes. */ public void setClasspathref (Reference pathref) { _cloader = ClasspathUtils.getClassLoaderForPath(getProject(), pathref); @@ -86,6 +87,17 @@ public abstract class GenTask extends Task ((AntClassLoader)_cloader).setParent(getClass().getClassLoader()); } + /** Configures the classpath which we'll use to load service classes. */ + public void setClasspath (Path path) + { + _cloader = ClasspathUtils.getClassLoaderForPath(getProject(), path, "narya"); + + // set the parent of the classloader to be the classloader used to load this task, rather + // than the classloader used to load Ant, so that we have access to Narya classes like + // TransportHint + ((AntClassLoader)_cloader).setParent(getClass().getClassLoader()); + } + /** * Fails the build if generation would change files rather than generating * code.