peterreilly 2004/12/10 07:18:57 Modified: . WHATSNEW src/main/org/apache/tools/ant/util ClasspathUtils.java Added: src/testcases/org/apache/tools/ant/util ClasspathUtilsTest.java Log: with the bugzilla change 30161 it is not necessary to place Path.systemClasspath in the antclassloader Doing so causes resources to appear twice Revision Changes Path 1.693 +4 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.692 retrieving revision 1.693 diff -u -r1.692 -r1.693 --- WHATSNEW 7 Dec 2004 10:29:32 -0000 1.692 +++ WHATSNEW 10 Dec 2004 15:18:57 -0000 1.693 @@ -174,6 +174,10 @@ * Incorrect classloader parent in junittask when using with ant-junit.jar and junit.jar not in the project classloader. Bugzilla report 28474. +* getResources() on the classloader returned by ClasspathUtils would see each resource + twice - if the resource is in the project classpath and if the classloader is requested + with a null path. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== 1.13 +7 -9 ant/src/main/org/apache/tools/ant/util/ClasspathUtils.java Index: ClasspathUtils.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/ClasspathUtils.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ClasspathUtils.java 14 Apr 2004 15:42:08 -0000 1.12 +++ ClasspathUtils.java 10 Dec 2004 15:18:57 -0000 1.13 @@ -156,13 +156,13 @@ * 'ant.reuse.loader' this will try to reuse the perviously * created loader with that id, and of course store it there upon * creation.</p> - * @param path Path object to be used as classpath for this classloader - * @param loaderId identification for this Loader, + * @param path Path object to be used as classpath for this classloader + * @param loaderId identification for this Loader, * @param reverseLoader if set to true this new loader will take - * precedence over it's parent (which is contra the regular - * @param p Ant Project where the handled components are living in. - * classloader behaviour) - * @return ClassLoader that uses the Path as its classpath. + * precedence over it's parent (which is contra the regular + * classloader behaviour) + * @param p Ant Project where the handled components are living in. + * @return ClassLoader that uses the Path as its classpath. */ public static ClassLoader getClassLoaderForPath( Project p, Path path, String loaderId, boolean reverseLoader, @@ -205,9 +205,7 @@ Project p, Path path, boolean reverseLoader) { - - AntClassLoader acl = p.createClassLoader(path != null - ? path : Path.systemClasspath); + AntClassLoader acl = p.createClassLoader(path); if (reverseLoader) { acl.setParentFirst(false); acl.addJavaLibraries(); 1.1 ant/src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java Index: ClasspathUtilsTest.java =================================================================== /* * Copyright 2000-2002,2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.tools.ant.util; import java.io.File; import java.io.IOException; import java.util.Enumeration; import junit.framework.TestCase; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Path; /** * Test case for ClasspathUtils * */ public class ClasspathUtilsTest extends TestCase { private Project p; public ClasspathUtilsTest(String name) { super(name); } public void setUp() { p = new Project(); p.init(); } public void testOnlyOneInstance() { Enumeration enumeration; String list = ""; ClassLoader c = ClasspathUtils.getUniqueClassLoaderForPath(p, (Path) null, false); try { enumeration = c.getResources( "org/apache/tools/ant/taskdefs/defaults.properties"); } catch (IOException e) { throw new BuildException( "Could not get the defaults.properties resource"); } int count = 0; while (enumeration.hasMoreElements()) { list = list + " " + enumeration.nextElement(); count++; } assertTrue("Should be only one and not " + count + " " + list, count == 1); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]