Permalink
Browse files

JRUBY-4750: Fix Rake tasks not loading from custom classpath in Ant

  • Loading branch information...
1 parent 4664093 commit 8fcc2a261d90e55d203312ab77fd29a01b94629c @nicksieger nicksieger committed Apr 28, 2010
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/org/jruby/ant/RakeTaskBase.java
@@ -27,14 +27,20 @@ public void execute() throws BuildException {
}
protected void acquireRakeReference() {
- System.setProperty("jruby.native.enabled", "false"); // Problem with cl w/ jnr + jffi
- container = new ScriptingContainer();
+ ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ System.setProperty("jruby.native.enabled", "false"); // Problem with cl w/ jnr + jffi
+ container = new ScriptingContainer();
- // FIXME: This needs to be replaced by something which does not assume CWD
- container.setLoadPaths(Arrays.asList("lib"));
- container.runScriptlet("require 'ant/tasks/raketasks'");
+ // FIXME: This needs to be replaced by something which does not assume CWD
+ container.setLoadPaths(Arrays.asList("lib"));
+ container.runScriptlet("require 'ant/tasks/raketasks'");
- rakeWrapper = container.runScriptlet("RakeWrapper.new");
+ rakeWrapper = container.runScriptlet("RakeWrapper.new");
+ } finally {
+ Thread.currentThread().setContextClassLoader(prevClassLoader);
+ }
}
protected List handleFilenameArgument() {

0 comments on commit 8fcc2a2

Please sign in to comment.