Browse Source

another go at bugzilla 38747, isolate resources

get the baseloader for resources in isolate mode


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@453032 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
b10bf232ba
3 changed files with 25 additions and 8 deletions
  1. +0
    -4
      WHATSNEW
  2. +24
    -3
      src/main/org/apache/tools/ant/AntClassLoader.java
  3. +1
    -1
      src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java

+ 0
- 4
WHATSNEW View File

@@ -44,10 +44,6 @@ Other changes:
* Added <tokens> resource collection for convenient creation of string
resources from other resources' content. Inspired by Bugzilla 40504.

* REVERTED for the moment: AntClassLoader did not isolate
resources when isolate was set. Bugzilla report 38747.


Changes from Ant 1.7.0Beta1 to Ant 1.7.0Beta2
=============================================



+ 24
- 3
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -871,6 +871,18 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
return useParentFirst;
}

/**
* Used for isolated resource seaching.
* @return the root classloader of AntClassLoader.
*/
private ClassLoader getRootLoader() {
ClassLoader ret = getClass().getClassLoader();
while (ret != null && ret.getParent() != null) {
ret = ret.getParent();
}
return ret;
}

/**
* Finds the resource with the given name. A resource is
* some data (images, audio, text, etc) that can be accessed by class
@@ -913,9 +925,13 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {

if (url == null && !isParentFirst(name)) {
// this loader was first but it didn't find it - try the parent

url = (parent == null) ? super.getResource(name)
: parent.getResource(name);
if (ignoreBase) {
url = (getRootLoader() == null) ? null
: getRootLoader().getResource(name);
} else {
url = (parent == null) ? super.getResource(name)
: parent.getResource(name);
}
if (url != null) {
log("Resource " + name + " loaded from parent loader",
Project.MSG_DEBUG);
@@ -953,6 +969,11 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
if (isParentFirst(name)) {
// Normal case.
return CollectionUtils.append(base, mine);
} else if (ignoreBase) {
return getRootLoader() == null
? mine
: CollectionUtils.append(
mine, getRootLoader().getResources(name));
} else {
// Inverted.
return CollectionUtils.append(mine, base);


+ 1
- 1
src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java View File

@@ -78,7 +78,7 @@ public class AntClassLoaderDelegationTest extends TestCase {
enum2List(acl.getResources(TEST_RESOURCE)));
}

public void NottestFindIsolateResources() throws Exception {
public void testFindIsolateResources() throws Exception {
String buildTestcases = System.getProperty("build.tests");
assertNotNull("defined ${build.tests}", buildTestcases);
assertTrue("have a dir " + buildTestcases, new File(buildTestcases).isDirectory());


Loading…
Cancel
Save