From 60059dafe8f65bbc53657aaee25af3f823762743 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 7 Dec 2004 10:29:32 +0000 Subject: [PATCH] If junittask is loaded by a different classloader than the project classloader, set the junittask classloader as the parent of the classloader used to load the tests, otherwise the tests will not see the classes in ant-junit.jar and the classes loaded with the tests will use a different junit.jar than the junit used by junittask and will be not be compatible. PR: 28474 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277138 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ .../apache/tools/ant/taskdefs/optional/junit/JUnitTask.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/WHATSNEW b/WHATSNEW index 672a8a69a..db7dd8787 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -171,6 +171,9 @@ Fixed bugs: * Target location is not set for default target. Bugzilla report 32267. +* Incorrect classloader parent in junittask when using with ant-junit.jar and junit.jar + not in the project classloader. Bugzilla report 28474. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index afe38f770..b9d4fc303 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -1321,6 +1321,10 @@ public class JUnitTask extends Task { classpath.append(antRuntimeClasses); } classLoader = getProject().createClassLoader(classpath); + if (getClass().getClassLoader() != null + && getClass().getClassLoader() != Project.class.getClassLoader()) { + classLoader.setParent(getClass().getClassLoader()); + } classLoader.setParentFirst(false); classLoader.addJavaLibraries(); log("Using CLASSPATH " + classLoader.getClasspath(),