diff --git a/proposal/myrmidon/src/java/org/apache/antlib/java/JikesAdaptor.java b/proposal/myrmidon/src/java/org/apache/antlib/java/JikesAdaptor.java index d40c56b84..0cc8aaf42 100644 --- a/proposal/myrmidon/src/java/org/apache/antlib/java/JikesAdaptor.java +++ b/proposal/myrmidon/src/java/org/apache/antlib/java/JikesAdaptor.java @@ -10,6 +10,7 @@ package org.apache.antlib.java; import java.io.File; import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.framework.Execute; +import org.apache.myrmidon.framework.java.JavaRuntimeClassPath; import org.apache.myrmidon.framework.file.Path; import org.apache.tools.todo.types.Commandline; import org.apache.tools.todo.types.PathUtil; @@ -53,7 +54,7 @@ public class JikesAdaptor } // Add the runtime - PathUtil.addJavaRuntime( classpath ); + classpath.add( new JavaRuntimeClassPath() ); // Build the command line final Commandline cmd = exe.getCommandline(); diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/java/JavaRuntimeClassPath.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/java/JavaRuntimeClassPath.java new file mode 100644 index 000000000..9a83eac7f --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/java/JavaRuntimeClassPath.java @@ -0,0 +1,80 @@ +/* + * 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.myrmidon.framework.java; + +import org.apache.myrmidon.framework.file.FileList; +import org.apache.myrmidon.framework.file.Path; +import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.api.TaskContext; +import org.apache.tools.todo.types.FileSet; +import org.apache.aut.nativelib.Os; +import java.util.Locale; +import java.io.File; + +/** + * A FileList that evaluates to the runtime class-path for this JVM. + * + * @author Adam Murdoch + * @version $Revision$ $Date$ + * + * @ant.type type="path" name="java-runtime" + */ +public class JavaRuntimeClassPath + implements FileList +{ + /** + * Returns the files in this list. + * + * @param context the context to use to evaluate the list. + * @return The names of the files in this list. All names are absolute paths. + */ + public String[] listFiles( final TaskContext context ) + throws TaskException + { + final Path path = new Path(); + + 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 if( Os.isFamily( Os.OS_FAMILY_OSX ) ) + { + // MacOS X + final String classDir = System.getProperty( "java.home" ) + + File.separator + ".." + File.separator + "Classes"; + final File classes = new File( classDir, "classes.jar" ); + path.addLocation( classes ); + final File ui = new File( classDir, "ui.jar" ); + path.addLocation( ui ); + } + else + { + // JDK > 1.1 sets java.home to the JRE directory. + final String rt = System.getProperty( "java.home" ) + + File.separator + "lib" + File.separator + "rt.jar"; + final File rtJar = new File( rt ); + path.addLocation( rtJar ); + } + + return path.listFiles( context ); + } +} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JJTree.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JJTree.java index fd5832e61..16d08e94d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JJTree.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JJTree.java @@ -167,7 +167,6 @@ public class JJTree } final Path classpath = exe.getClassPath(); classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); - PathUtil.addJavaRuntime( classpath ); exe.setMaxMemory( "140M" ); exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JavaCC.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JavaCC.java index 41c47e92b..dd85e2265 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JavaCC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javacc/JavaCC.java @@ -222,7 +222,6 @@ public class JavaCC final Path classpath = exe.getClassPath(); classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); - PathUtil.addJavaRuntime( classpath ); exe.setMaxMemory( "140M" ); exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java index 7e4315821..72d3b4bf7 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java @@ -141,50 +141,6 @@ public class PathUtil } } - /** - * Adds this JVM's runtime to a path. - */ - 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 if( Os.isFamily( Os.OS_FAMILY_OSX ) ) - { - // MacOS X - final String classDir = System.getProperty( "java.home" ) + - File.separator + ".." + File.separator + "Classes"; - final File classes = new File( classDir, "classes.jar" ); - path.addLocation( classes ); - final File ui = new File( classDir, "ui.jar" ); - path.addLocation( ui ); - } - else - { - // JDK > 1.1 sets java.home to the JRE directory. - final String rt = System.getProperty( "java.home" ) + - File.separator + "lib" + File.separator + "rt.jar"; - final File rtJar = new File( rt ); - path.addLocation( rtJar ); - } - } - /** * Adds the contents of a set of directories to a path. */