git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272064 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -10,6 +10,7 @@ package org.apache.antlib.java; | |||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.framework.Execute; | import org.apache.myrmidon.framework.Execute; | ||||
| import org.apache.myrmidon.framework.java.JavaRuntimeClassPath; | |||||
| import org.apache.myrmidon.framework.file.Path; | import org.apache.myrmidon.framework.file.Path; | ||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| import org.apache.tools.todo.types.PathUtil; | import org.apache.tools.todo.types.PathUtil; | ||||
| @@ -53,7 +54,7 @@ public class JikesAdaptor | |||||
| } | } | ||||
| // Add the runtime | // Add the runtime | ||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| classpath.add( new JavaRuntimeClassPath() ); | |||||
| // Build the command line | // Build the command line | ||||
| final Commandline cmd = exe.getCommandline(); | final Commandline cmd = exe.getCommandline(); | ||||
| @@ -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 <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @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 ); | |||||
| } | |||||
| } | |||||
| @@ -167,7 +167,6 @@ public class JJTree | |||||
| } | } | ||||
| final Path classpath = exe.getClassPath(); | final Path classpath = exe.getClassPath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| exe.setMaxMemory( "140M" ); | exe.setMaxMemory( "140M" ); | ||||
| exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); | exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); | ||||
| @@ -222,7 +222,6 @@ public class JavaCC | |||||
| final Path classpath = exe.getClassPath(); | final Path classpath = exe.getClassPath(); | ||||
| classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); | ||||
| PathUtil.addJavaRuntime( classpath ); | |||||
| exe.setMaxMemory( "140M" ); | exe.setMaxMemory( "140M" ); | ||||
| exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); | exe.getSysProperties().addVariable( "install.root", javaccHome.getAbsolutePath() ); | ||||
| @@ -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. | * Adds the contents of a set of directories to a path. | ||||
| */ | */ | ||||