+ AutomaticExtraClasspathProvider
can now be
+ created in a declarative way. So libraries that wish to
+ provide such Ant extension may just do it in declarative
+ way without depending on AutomaticExtraClasspathProvider
+ class.
+
junit.jar
* as needed by the <junit>
task.
* Register instances to default lookup.
+ *
+ * Since version org.apache.tools.ant.module/3 3.18
there is a
+ * way to register a library declaratively:
+ *
+ * <filesystems> + * <folder name="Services"> + * <folder name="Hidden"> + * <file name="org-your-lib-Ant-Registration.instance"> + * <attr name="instanceCreate" methodvalue="org.apache.tools.ant.module.spi.AutomaticExtraClasspath.url"/> + * <attr name="url" urlvalue="nbinst:/modules/ext/org-your-lib.jar"/> + * </file> + * </folder> + * </folder> + * </filesystems> + *+ * + * * @since org.apache.tools.ant.module/3 3.8 * @author Jesse Glick */ Index: ant/test/unit/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspathTest.java *** /doma/jarda/netbeans-src/ant/test/unit/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspathTest.java No Base Revision --- /doma/jarda/netbeans-src/ant/test/unit/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspathTest.java Locally New *************** *** 1,0 **** --- 1,72 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.apache.tools.ant.module.spi; + + import junit.framework.TestCase; + import junit.framework.*; + import java.io.File; + import java.io.IOException; + import java.net.URL; + import java.util.Map; + import org.netbeans.junit.NbTestCase; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileSystem; + import org.openide.filesystems.FileUtil; + import org.openide.filesystems.MultiFileSystem; + import org.openide.filesystems.URLMapper; + import org.openide.filesystems.XMLFileSystem; + + /** + * + * @author jarda + */ + public class AutomaticExtraClasspathTest extends NbTestCase { + private static URL wd; + + + FileObject fo; + + public AutomaticExtraClasspathTest(String testName) { + super(testName); + } + + protected void setUp() throws Exception { + URL u = getClass().getResource("AutomaticExtraClasspathTest.xml"); + FileSystem fs = new XMLFileSystem(u); + fo = fs.findResource("testAutoProvider"); + assertNotNull("There is the resource", fo); + } + + protected void tearDown() throws Exception { + } + + public static URL getWD() { + return wd; + } + + public void testReadWorkDir() throws Exception { + URL u = getWorkDir().toURI().toURL(); + wd = u; + + Object value = fo.getAttribute("instanceCreate"); + assertTrue("provider created: " + value, value instanceof AutomaticExtraClasspathProvider); + + AutomaticExtraClasspathProvider auto = (AutomaticExtraClasspathProvider)value; + File[] arr = auto.getClasspathItems(); + assertNotNull(arr); + assertEquals("One item", 1, arr.length); + assertEquals("It is our work dir", getWorkDir(), arr[0]); + } + + } Index: ant/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspath.java *** /doma/jarda/netbeans-src/ant/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspath.java No Base Revision --- /doma/jarda/netbeans-src/ant/src/org/apache/tools/ant/module/spi/AutomaticExtraClasspath.java Locally New *************** *** 1,0 **** --- 1,51 ---- + /* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.apache.tools.ant.module.spi; + + import java.io.File; + import java.io.IOException; + import java.net.URL; + import java.util.Map; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileUtil; + import org.openide.filesystems.URLMapper; + + /** Factory method for urls. + * + * @author Jaroslav Tulach + */ + final class AutomaticExtraClasspath implements AutomaticExtraClasspathProvider { + private URL url; + + + private AutomaticExtraClasspath(URL url) { + this.url = url; + } + + public static AutomaticExtraClasspathProvider url(Map,?> map) throws Exception { + Object obj = map.get("url"); // NOI18N + if (obj instanceof URL) { + return new AutomaticExtraClasspath((URL)obj); + } else { + throw new IOException("url arg is not URL: " + obj); // NOI18N + } + } + + public File[] getClasspathItems() { + FileObject fo = URLMapper.findFileObject(url); + File f = fo != null ? FileUtil.toFile(fo) : null; + + return f == null ? new File[0] : new File[] { f }; + } + } Index: libs/jsch/src/org/netbeans/libs/jsch/mf-layer.xml *** /doma/jarda/netbeans-src/libs/jsch/src/org/netbeans/libs/jsch/mf-layer.xml No Base Revision --- /doma/jarda/netbeans-src/libs/jsch/src/org/netbeans/libs/jsch/mf-layer.xml Locally New *************** *** 1,0 **** --- 1,27 ---- + + + + +