Browse Source

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
master
Peter Reilly 20 years ago
parent
commit
60059dafe8
2 changed files with 7 additions and 0 deletions
  1. +3
    -0
      WHATSNEW
  2. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 3
- 0
WHATSNEW View File

@@ -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
===================================



+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -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(),


Loading…
Cancel
Save