git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270809 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -24,6 +24,7 @@ import org.apache.tools.ant.types.DirectoryScanner; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.xml.sax.EntityResolver; | import org.xml.sax.EntityResolver; | ||||
| import org.xml.sax.ErrorHandler; | import org.xml.sax.ErrorHandler; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| @@ -334,7 +335,8 @@ public class XMLValidateTask | |||||
| Class readerClass = null; | Class readerClass = null; | ||||
| if( m_classpath != null ) | if( m_classpath != null ) | ||||
| { | { | ||||
| final ClassLoader classLoader = new URLClassLoader( m_classpath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( m_classpath ); | |||||
| final ClassLoader classLoader = new URLClassLoader( urls ); | |||||
| readerClass = classLoader.loadClass( m_readerClassName ); | readerClass = classLoader.loadClass( m_readerClassName ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -9,12 +9,14 @@ package org.apache.antlib.xml; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.DirectoryScanner; | import org.apache.tools.ant.types.DirectoryScanner; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * A Task to process via XSLT a set of XML documents. This is useful for | * A Task to process via XSLT a set of XML documents. This is useful for | ||||
| @@ -381,7 +383,8 @@ public class XSLTProcess | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| final ClassLoader classLoader = new URLClassLoader( m_classpath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( m_classpath ); | |||||
| final ClassLoader classLoader = new URLClassLoader( urls ); | |||||
| return classLoader.loadClass( classname ); | return classLoader.loadClass( classname ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -24,6 +24,7 @@ import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.types.DirectoryScanner; | import org.apache.tools.ant.types.DirectoryScanner; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Generate a dependency file for a given set of classes | * Generate a dependency file for a given set of classes | ||||
| @@ -570,7 +571,8 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // now determine which jars each class depends upon | // now determine which jars each class depends upon | ||||
| classpathDependencies = new Hashtable(); | classpathDependencies = new Hashtable(); | ||||
| final ClassLoader classLoader = new URLClassLoader( dependClasspath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( dependClasspath ); | |||||
| final ClassLoader classLoader = new URLClassLoader( urls ); | |||||
| Hashtable classpathFileCache = new Hashtable(); | Hashtable classpathFileCache = new Hashtable(); | ||||
| Object nullFileMarker = new Object(); | Object nullFileMarker = new Object(); | ||||
| @@ -11,6 +11,7 @@ import java.io.File; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.types.DirectoryScanner; | import org.apache.tools.ant.types.DirectoryScanner; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||||
| // ==================================================================== | // ==================================================================== | ||||
| @@ -93,9 +94,8 @@ import org.apache.tools.ant.types.Path; | |||||
| * @version 0.3 | * @version 0.3 | ||||
| */ | */ | ||||
| public class CSharp | public class CSharp | ||||
| extends org.apache.tools.ant.taskdefs.MatchingTask | |||||
| extends MatchingTask | |||||
| { | { | ||||
| /** | /** | ||||
| * name of the executable. the .exe suffix is deliberately not included in | * name of the executable. the .exe suffix is deliberately not included in | ||||
| * anticipation of the unix version | * anticipation of the unix version | ||||
| @@ -958,6 +958,5 @@ public class CSharp | |||||
| protected boolean notEmpty( String s ) | protected boolean notEmpty( String s ) | ||||
| { | { | ||||
| return s != null && s.length() != 0; | return s != null && s.length() != 0; | ||||
| }// end execute | |||||
| }//end class | |||||
| } | |||||
| } | |||||
| @@ -13,6 +13,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| @@ -33,6 +34,7 @@ import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.apache.tools.ant.util.depend.Dependencies; | import org.apache.tools.ant.util.depend.Dependencies; | ||||
| import org.apache.tools.ant.util.depend.Filter; | import org.apache.tools.ant.util.depend.Filter; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| @@ -332,7 +334,8 @@ public class GenericDeploymentTool | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| classpathLoader = new URLClassLoader( combinedClasspath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( combinedClasspath ); | |||||
| classpathLoader = new URLClassLoader( urls ); | |||||
| } | } | ||||
| return classpathLoader; | return classpathLoader; | ||||
| @@ -13,6 +13,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.jar.JarEntry; | import java.util.jar.JarEntry; | ||||
| @@ -24,6 +25,7 @@ import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | public class WeblogicDeploymentTool extends GenericDeploymentTool | ||||
| @@ -335,7 +337,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| lookupPath.append( classpath ); | lookupPath.append( classpath ); | ||||
| } | } | ||||
| return new URLClassLoader( lookupPath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( lookupPath ); | |||||
| return new URLClassLoader( urls ); | |||||
| } | } | ||||
| protected DescriptorHandler getWeblogicDescriptorHandler( final File srcDir ) | protected DescriptorHandler getWeblogicDescriptorHandler( final File srcDir ) | ||||
| @@ -12,6 +12,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.jar.JarEntry; | import java.util.jar.JarEntry; | ||||
| @@ -23,6 +24,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.EnvironmentVariable; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Websphere deployment tool that augments the ejbjar task. | * Websphere deployment tool that augments the ejbjar task. | ||||
| @@ -413,7 +415,8 @@ public class WebsphereDeploymentTool | |||||
| { | { | ||||
| lookupPath.append( classpath ); | lookupPath.append( classpath ); | ||||
| } | } | ||||
| return new URLClassLoader( lookupPath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( lookupPath ); | |||||
| return new URLClassLoader( urls ); | |||||
| } | } | ||||
| protected DescriptorHandler getDescriptorHandler( File srcDir ) | protected DescriptorHandler getDescriptorHandler( File srcDir ) | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -174,7 +175,7 @@ public class JJTree extends Task | |||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| classpath.addJavaRuntime(); | |||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| cmdl.addVmArgument( "-mx140M" ); | cmdl.addVmArgument( "-mx140M" ); | ||||
| cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -18,6 +18,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| /** | /** | ||||
| @@ -228,7 +229,7 @@ public class JavaCC extends Task | |||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| classpath.addJavaRuntime(); | |||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| cmdl.addVmArgument( "-mx140M" ); | cmdl.addVmArgument( "-mx140M" ); | ||||
| cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -29,6 +29,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
| import org.apache.tools.ant.types.EnvironmentVariable; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.SysProperties; | import org.apache.tools.ant.types.SysProperties; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Ant task to run JUnit tests. <p> | * Ant task to run JUnit tests. <p> | ||||
| @@ -696,7 +697,8 @@ public class JUnitTask extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| getLogger().debug( "Using CLASSPATH " + classpath ); | getLogger().debug( "Using CLASSPATH " + classpath ); | ||||
| classLoader = new URLClassLoader( classpath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( classpath ); | |||||
| classLoader = new URLClassLoader( urls ); | |||||
| } | } | ||||
| runner = new JUnitTestRunner( test, | runner = new JUnitTestRunner( test, | ||||
| test.getHaltonerror(), | test.getHaltonerror(), | ||||
| @@ -7,15 +7,14 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.DataType; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.DataType; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * This object represents a path as used by CLASSPATH or PATH environment | * This object represents a path as used by CLASSPATH or PATH environment | ||||
| @@ -132,55 +131,6 @@ public class Path | |||||
| m_elements.add( fileSet ); | m_elements.add( fileSet ); | ||||
| } | } | ||||
| /** | |||||
| * Add the Java Runtime classes to this Path instance. | |||||
| */ | |||||
| public void addJavaRuntime() | |||||
| throws TaskException | |||||
| { | |||||
| if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) | |||||
| { | |||||
| // Pull in *.zip from packages directory | |||||
| FileSet msZipFiles = new FileSet(); | |||||
| msZipFiles.setDir( new File( System.getProperty( "java.home" ) + File.separator + "Packages" ) ); | |||||
| msZipFiles.setIncludes( "*.ZIP" ); | |||||
| addFileset( msZipFiles ); | |||||
| } | |||||
| else if( "Kaffe".equals( System.getProperty( "java.vm.name" ) ) ) | |||||
| { | |||||
| FileSet kaffeJarFiles = new FileSet(); | |||||
| kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) | |||||
| + File.separator + "share" | |||||
| + File.separator + "kaffe" ) ); | |||||
| kaffeJarFiles.setIncludes( "*.jar" ); | |||||
| addFileset( kaffeJarFiles ); | |||||
| } | |||||
| else | |||||
| { | |||||
| // JDK > 1.1 seems to set java.home to the JRE directory. | |||||
| final String rt = System.getProperty( "java.home" ) + | |||||
| File.separator + "lib" + File.separator + "rt.jar"; | |||||
| addExisting( new Path( rt ) ); | |||||
| // Just keep the old version as well and let addExisting | |||||
| // sort it out. | |||||
| final String rt2 = System.getProperty( "java.home" ) + | |||||
| File.separator + "jre" + File.separator + "lib" + | |||||
| File.separator + "rt.jar"; | |||||
| addExisting( new Path( rt2 ) ); | |||||
| // Added for MacOS X | |||||
| final String classes = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "classes.jar"; | |||||
| addExisting( new Path( classes ) ); | |||||
| final String ui = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "ui.jar"; | |||||
| addExisting( new Path( ui ) ); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Append the contents of the other Path instance to this. | * Append the contents of the other Path instance to this. | ||||
| */ | */ | ||||
| @@ -309,32 +259,4 @@ public class Path | |||||
| throw new Error( te.toString() ); | throw new Error( te.toString() ); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Returns an array of URLs - useful for building a ClassLoader. | |||||
| */ | |||||
| public URL[] toURLs() | |||||
| throws TaskException | |||||
| { | |||||
| try | |||||
| { | |||||
| final String[] list = list(); | |||||
| final URL[] result = new URL[ list.length ]; | |||||
| // path containing one or more elements | |||||
| for( int i = 0; i < list.length; i++ ) | |||||
| { | |||||
| result[ i ] = new File( list[ i ] ).toURL(); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| catch( final IOException ioe ) | |||||
| { | |||||
| final String message = "Malformed path entry. Reason:" + ioe; | |||||
| throw new TaskException( message, ioe ); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,113 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant.types; | |||||
| import java.net.URL; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| import java.util.Locale; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | |||||
| * Utilities for operating on Path objects. | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class PathUtil | |||||
| { | |||||
| /** | |||||
| * Returns an array of URLs - useful for building a ClassLoader. | |||||
| */ | |||||
| public static URL[] toURLs( final Path path ) | |||||
| throws TaskException | |||||
| { | |||||
| try | |||||
| { | |||||
| final String[] list = path.list(); | |||||
| final URL[] result = new URL[ list.length ]; | |||||
| // path containing one or more elements | |||||
| for( int i = 0; i < list.length; i++ ) | |||||
| { | |||||
| result[ i ] = new File( list[ i ] ).toURL(); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| catch( final IOException ioe ) | |||||
| { | |||||
| final String message = "Malformed path entry. Reason:" + ioe; | |||||
| throw new TaskException( message, ioe ); | |||||
| } | |||||
| } | |||||
| public static void addJavaRuntime( final Path path ) | |||||
| throws TaskException | |||||
| { | |||||
| if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) | |||||
| { | |||||
| // Pull in *.zip from packages directory | |||||
| FileSet msZipFiles = new FileSet(); | |||||
| msZipFiles.setDir( new File( System.getProperty( "java.home" ) + File.separator + "Packages" ) ); | |||||
| msZipFiles.setIncludes( "*.ZIP" ); | |||||
| path.addFileset( msZipFiles ); | |||||
| } | |||||
| else if( "Kaffe".equals( System.getProperty( "java.vm.name" ) ) ) | |||||
| { | |||||
| FileSet kaffeJarFiles = new FileSet(); | |||||
| kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) | |||||
| + File.separator + "share" | |||||
| + File.separator + "kaffe" ) ); | |||||
| kaffeJarFiles.setIncludes( "*.jar" ); | |||||
| path.addFileset( kaffeJarFiles ); | |||||
| } | |||||
| else | |||||
| { | |||||
| // JDK > 1.1 seems to set java.home to the JRE directory. | |||||
| final String rt = System.getProperty( "java.home" ) + | |||||
| File.separator + "lib" + File.separator + "rt.jar"; | |||||
| path.addExisting( new Path( rt ) ); | |||||
| // Just keep the old version as well and let addExisting | |||||
| // sort it out. | |||||
| final String rt2 = System.getProperty( "java.home" ) + | |||||
| File.separator + "jre" + File.separator + "lib" + | |||||
| File.separator + "rt.jar"; | |||||
| path.addExisting( new Path( rt2 ) ); | |||||
| // Added for MacOS X | |||||
| final String classes = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "classes.jar"; | |||||
| path.addExisting( new Path( classes ) ); | |||||
| final String ui = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "ui.jar"; | |||||
| path.addExisting( new Path( ui ) ); | |||||
| } | |||||
| } | |||||
| public static void addExtdirs( final Path toPath, final Path extDirs ) | |||||
| throws TaskException | |||||
| { | |||||
| final String[] dirs = extDirs.list(); | |||||
| for( int i = 0; i < dirs.length; i++ ) | |||||
| { | |||||
| final File dir = new File( dirs[ i ] ); | |||||
| if( dir.exists() && dir.isDirectory() ) | |||||
| { | |||||
| final FileSet fileSet = new FileSet(); | |||||
| fileSet.setDir( dir ); | |||||
| fileSet.setIncludes( "*" ); | |||||
| toPath.addFileset( fileSet ); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -24,6 +24,7 @@ import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.types.DirectoryScanner; | import org.apache.tools.ant.types.DirectoryScanner; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Generate a dependency file for a given set of classes | * Generate a dependency file for a given set of classes | ||||
| @@ -570,7 +571,8 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // now determine which jars each class depends upon | // now determine which jars each class depends upon | ||||
| classpathDependencies = new Hashtable(); | classpathDependencies = new Hashtable(); | ||||
| final ClassLoader classLoader = new URLClassLoader( dependClasspath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( dependClasspath ); | |||||
| final ClassLoader classLoader = new URLClassLoader( urls ); | |||||
| Hashtable classpathFileCache = new Hashtable(); | Hashtable classpathFileCache = new Hashtable(); | ||||
| Object nullFileMarker = new Object(); | Object nullFileMarker = new Object(); | ||||
| @@ -11,6 +11,7 @@ import java.io.File; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.types.DirectoryScanner; | import org.apache.tools.ant.types.DirectoryScanner; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||||
| // ==================================================================== | // ==================================================================== | ||||
| @@ -93,9 +94,8 @@ import org.apache.tools.ant.types.Path; | |||||
| * @version 0.3 | * @version 0.3 | ||||
| */ | */ | ||||
| public class CSharp | public class CSharp | ||||
| extends org.apache.tools.ant.taskdefs.MatchingTask | |||||
| extends MatchingTask | |||||
| { | { | ||||
| /** | /** | ||||
| * name of the executable. the .exe suffix is deliberately not included in | * name of the executable. the .exe suffix is deliberately not included in | ||||
| * anticipation of the unix version | * anticipation of the unix version | ||||
| @@ -958,6 +958,5 @@ public class CSharp | |||||
| protected boolean notEmpty( String s ) | protected boolean notEmpty( String s ) | ||||
| { | { | ||||
| return s != null && s.length() != 0; | return s != null && s.length() != 0; | ||||
| }// end execute | |||||
| }//end class | |||||
| } | |||||
| } | |||||
| @@ -13,6 +13,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| @@ -33,6 +34,7 @@ import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.apache.tools.ant.util.depend.Dependencies; | import org.apache.tools.ant.util.depend.Dependencies; | ||||
| import org.apache.tools.ant.util.depend.Filter; | import org.apache.tools.ant.util.depend.Filter; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| @@ -332,7 +334,8 @@ public class GenericDeploymentTool | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| classpathLoader = new URLClassLoader( combinedClasspath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( combinedClasspath ); | |||||
| classpathLoader = new URLClassLoader( urls ); | |||||
| } | } | ||||
| return classpathLoader; | return classpathLoader; | ||||
| @@ -13,6 +13,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.jar.JarEntry; | import java.util.jar.JarEntry; | ||||
| @@ -24,6 +25,7 @@ import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | public class WeblogicDeploymentTool extends GenericDeploymentTool | ||||
| @@ -335,7 +337,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| lookupPath.append( classpath ); | lookupPath.append( classpath ); | ||||
| } | } | ||||
| return new URLClassLoader( lookupPath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( lookupPath ); | |||||
| return new URLClassLoader( urls ); | |||||
| } | } | ||||
| protected DescriptorHandler getWeblogicDescriptorHandler( final File srcDir ) | protected DescriptorHandler getWeblogicDescriptorHandler( final File srcDir ) | ||||
| @@ -12,6 +12,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
| import java.net.URL; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.jar.JarEntry; | import java.util.jar.JarEntry; | ||||
| @@ -23,6 +24,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.EnvironmentVariable; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Websphere deployment tool that augments the ejbjar task. | * Websphere deployment tool that augments the ejbjar task. | ||||
| @@ -413,7 +415,8 @@ public class WebsphereDeploymentTool | |||||
| { | { | ||||
| lookupPath.append( classpath ); | lookupPath.append( classpath ); | ||||
| } | } | ||||
| return new URLClassLoader( lookupPath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( lookupPath ); | |||||
| return new URLClassLoader( urls ); | |||||
| } | } | ||||
| protected DescriptorHandler getDescriptorHandler( File srcDir ) | protected DescriptorHandler getDescriptorHandler( File srcDir ) | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -174,7 +175,7 @@ public class JJTree extends Task | |||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| classpath.addJavaRuntime(); | |||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| cmdl.addVmArgument( "-mx140M" ); | cmdl.addVmArgument( "-mx140M" ); | ||||
| cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -18,6 +18,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| /** | /** | ||||
| @@ -228,7 +229,7 @@ public class JavaCC extends Task | |||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| classpath.addJavaRuntime(); | |||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| cmdl.addVmArgument( "-mx140M" ); | cmdl.addVmArgument( "-mx140M" ); | ||||
| cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -29,6 +29,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
| import org.apache.tools.ant.types.EnvironmentVariable; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.SysProperties; | import org.apache.tools.ant.types.SysProperties; | ||||
| import org.apache.tools.ant.types.PathUtil; | |||||
| /** | /** | ||||
| * Ant task to run JUnit tests. <p> | * Ant task to run JUnit tests. <p> | ||||
| @@ -696,7 +697,8 @@ public class JUnitTask extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| getLogger().debug( "Using CLASSPATH " + classpath ); | getLogger().debug( "Using CLASSPATH " + classpath ); | ||||
| classLoader = new URLClassLoader( classpath.toURLs() ); | |||||
| final URL[] urls = PathUtil.toURLs( classpath ); | |||||
| classLoader = new URLClassLoader( urls ); | |||||
| } | } | ||||
| runner = new JUnitTestRunner( test, | runner = new JUnitTestRunner( test, | ||||
| test.getHaltonerror(), | test.getHaltonerror(), | ||||
| @@ -7,15 +7,14 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.DataType; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.DataType; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * This object represents a path as used by CLASSPATH or PATH environment | * This object represents a path as used by CLASSPATH or PATH environment | ||||
| @@ -132,55 +131,6 @@ public class Path | |||||
| m_elements.add( fileSet ); | m_elements.add( fileSet ); | ||||
| } | } | ||||
| /** | |||||
| * Add the Java Runtime classes to this Path instance. | |||||
| */ | |||||
| public void addJavaRuntime() | |||||
| throws TaskException | |||||
| { | |||||
| if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) | |||||
| { | |||||
| // Pull in *.zip from packages directory | |||||
| FileSet msZipFiles = new FileSet(); | |||||
| msZipFiles.setDir( new File( System.getProperty( "java.home" ) + File.separator + "Packages" ) ); | |||||
| msZipFiles.setIncludes( "*.ZIP" ); | |||||
| addFileset( msZipFiles ); | |||||
| } | |||||
| else if( "Kaffe".equals( System.getProperty( "java.vm.name" ) ) ) | |||||
| { | |||||
| FileSet kaffeJarFiles = new FileSet(); | |||||
| kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) | |||||
| + File.separator + "share" | |||||
| + File.separator + "kaffe" ) ); | |||||
| kaffeJarFiles.setIncludes( "*.jar" ); | |||||
| addFileset( kaffeJarFiles ); | |||||
| } | |||||
| else | |||||
| { | |||||
| // JDK > 1.1 seems to set java.home to the JRE directory. | |||||
| final String rt = System.getProperty( "java.home" ) + | |||||
| File.separator + "lib" + File.separator + "rt.jar"; | |||||
| addExisting( new Path( rt ) ); | |||||
| // Just keep the old version as well and let addExisting | |||||
| // sort it out. | |||||
| final String rt2 = System.getProperty( "java.home" ) + | |||||
| File.separator + "jre" + File.separator + "lib" + | |||||
| File.separator + "rt.jar"; | |||||
| addExisting( new Path( rt2 ) ); | |||||
| // Added for MacOS X | |||||
| final String classes = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "classes.jar"; | |||||
| addExisting( new Path( classes ) ); | |||||
| final String ui = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "ui.jar"; | |||||
| addExisting( new Path( ui ) ); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Append the contents of the other Path instance to this. | * Append the contents of the other Path instance to this. | ||||
| */ | */ | ||||
| @@ -309,32 +259,4 @@ public class Path | |||||
| throw new Error( te.toString() ); | throw new Error( te.toString() ); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Returns an array of URLs - useful for building a ClassLoader. | |||||
| */ | |||||
| public URL[] toURLs() | |||||
| throws TaskException | |||||
| { | |||||
| try | |||||
| { | |||||
| final String[] list = list(); | |||||
| final URL[] result = new URL[ list.length ]; | |||||
| // path containing one or more elements | |||||
| for( int i = 0; i < list.length; i++ ) | |||||
| { | |||||
| result[ i ] = new File( list[ i ] ).toURL(); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| catch( final IOException ioe ) | |||||
| { | |||||
| final String message = "Malformed path entry. Reason:" + ioe; | |||||
| throw new TaskException( message, ioe ); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,113 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant.types; | |||||
| import java.net.URL; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| import java.util.Locale; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | |||||
| * Utilities for operating on Path objects. | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class PathUtil | |||||
| { | |||||
| /** | |||||
| * Returns an array of URLs - useful for building a ClassLoader. | |||||
| */ | |||||
| public static URL[] toURLs( final Path path ) | |||||
| throws TaskException | |||||
| { | |||||
| try | |||||
| { | |||||
| final String[] list = path.list(); | |||||
| final URL[] result = new URL[ list.length ]; | |||||
| // path containing one or more elements | |||||
| for( int i = 0; i < list.length; i++ ) | |||||
| { | |||||
| result[ i ] = new File( list[ i ] ).toURL(); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| catch( final IOException ioe ) | |||||
| { | |||||
| final String message = "Malformed path entry. Reason:" + ioe; | |||||
| throw new TaskException( message, ioe ); | |||||
| } | |||||
| } | |||||
| public static void addJavaRuntime( final Path path ) | |||||
| throws TaskException | |||||
| { | |||||
| if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) | |||||
| { | |||||
| // Pull in *.zip from packages directory | |||||
| FileSet msZipFiles = new FileSet(); | |||||
| msZipFiles.setDir( new File( System.getProperty( "java.home" ) + File.separator + "Packages" ) ); | |||||
| msZipFiles.setIncludes( "*.ZIP" ); | |||||
| path.addFileset( msZipFiles ); | |||||
| } | |||||
| else if( "Kaffe".equals( System.getProperty( "java.vm.name" ) ) ) | |||||
| { | |||||
| FileSet kaffeJarFiles = new FileSet(); | |||||
| kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) | |||||
| + File.separator + "share" | |||||
| + File.separator + "kaffe" ) ); | |||||
| kaffeJarFiles.setIncludes( "*.jar" ); | |||||
| path.addFileset( kaffeJarFiles ); | |||||
| } | |||||
| else | |||||
| { | |||||
| // JDK > 1.1 seems to set java.home to the JRE directory. | |||||
| final String rt = System.getProperty( "java.home" ) + | |||||
| File.separator + "lib" + File.separator + "rt.jar"; | |||||
| path.addExisting( new Path( rt ) ); | |||||
| // Just keep the old version as well and let addExisting | |||||
| // sort it out. | |||||
| final String rt2 = System.getProperty( "java.home" ) + | |||||
| File.separator + "jre" + File.separator + "lib" + | |||||
| File.separator + "rt.jar"; | |||||
| path.addExisting( new Path( rt2 ) ); | |||||
| // Added for MacOS X | |||||
| final String classes = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "classes.jar"; | |||||
| path.addExisting( new Path( classes ) ); | |||||
| final String ui = System.getProperty( "java.home" ) + | |||||
| File.separator + ".." + File.separator + "Classes" + | |||||
| File.separator + "ui.jar"; | |||||
| path.addExisting( new Path( ui ) ); | |||||
| } | |||||
| } | |||||
| public static void addExtdirs( final Path toPath, final Path extDirs ) | |||||
| throws TaskException | |||||
| { | |||||
| final String[] dirs = extDirs.list(); | |||||
| for( int i = 0; i < dirs.length; i++ ) | |||||
| { | |||||
| final File dir = new File( dirs[ i ] ); | |||||
| if( dir.exists() && dir.isDirectory() ) | |||||
| { | |||||
| final FileSet fileSet = new FileSet(); | |||||
| fileSet.setDir( dir ); | |||||
| fileSet.setIncludes( "*" ); | |||||
| toPath.addFileset( fileSet ); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||