donaldp 02/01/20 01:55:47
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/types
Path.java
Added: proposal/myrmidon/src/main/org/apache/tools/ant/types
PathUtil.java
Log:
Moved some path manipulation utilities into PathUtils
Revision Changes Path
1.19 +3 -81
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Path.java 19 Jan 2002 07:26:22 -0000 1.18
+++ Path.java 20 Jan 2002 09:55:47 -0000 1.19
@@ -7,15 +7,14 @@
*/
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.IOException;
import java.net.URL;
import java.util.ArrayList;
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
@@ -133,55 +132,6 @@
}
/**
- * 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.
*/
public void append( final Path other )
@@ -309,32 +259,4 @@
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 );
- }
- }
-
}
1.1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PathUtil.java
Index: PathUtil.java
===================================================================
/*
* 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:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/01/20 09:55:47 $
*/
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 );
}
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>