git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272552 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -56,6 +56,7 @@ package org.apache.tools.ant; | |||||
| import org.apache.tools.ant.input.DefaultInputHandler; | import org.apache.tools.ant.input.DefaultInputHandler; | ||||
| import org.apache.tools.ant.input.InputHandler; | import org.apache.tools.ant.input.InputHandler; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| @@ -558,8 +559,8 @@ public class Main { | |||||
| // use a system manager that prevents from System.exit() | // use a system manager that prevents from System.exit() | ||||
| // only in JDK > 1.1 | // only in JDK > 1.1 | ||||
| SecurityManager oldsm = null; | SecurityManager oldsm = null; | ||||
| if (!Project.JAVA_1_0.equals(Project.getJavaVersion()) && | |||||
| !Project.JAVA_1_1.equals(Project.getJavaVersion())){ | |||||
| if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0) && | |||||
| !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)){ | |||||
| oldsm = System.getSecurityManager(); | oldsm = System.getSecurityManager(); | ||||
| //SecurityManager can not be installed here for backwards | //SecurityManager can not be installed here for backwards | ||||
| @@ -64,7 +64,6 @@ import java.util.Enumeration; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.lang.reflect.Modifier; | import java.lang.reflect.Modifier; | ||||
| import org.apache.tools.ant.types.FilterSet; | import org.apache.tools.ant.types.FilterSet; | ||||
| import org.apache.tools.ant.types.FilterSetCollection; | import org.apache.tools.ant.types.FilterSetCollection; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -111,15 +110,35 @@ public class Project { | |||||
| */ | */ | ||||
| private static final String VISITED = "VISITED"; | private static final String VISITED = "VISITED"; | ||||
| /** Version constant for Java 1.0 */ | |||||
| /** | |||||
| * Version constant for Java 1.0 | |||||
| * | |||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | |||||
| public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | ||||
| /** Version constant for Java 1.1 */ | |||||
| /** | |||||
| * Version constant for Java 1.1 | |||||
| * | |||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | |||||
| public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | ||||
| /** Version constant for Java 1.2 */ | |||||
| /** | |||||
| * Version constant for Java 1.2 | |||||
| * | |||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | |||||
| public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | ||||
| /** Version constant for Java 1.3 */ | |||||
| /** | |||||
| * Version constant for Java 1.3 | |||||
| * | |||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | |||||
| public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | ||||
| /** Version constant for Java 1.4 */ | |||||
| /** | |||||
| * Version constant for Java 1.4 | |||||
| * | |||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | |||||
| public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | ||||
| /** Default filter start token. */ | /** Default filter start token. */ | ||||
| @@ -724,6 +743,7 @@ public class Project { | |||||
| * Returns the version of Java this class is running under. | * Returns the version of Java this class is running under. | ||||
| * @return the version of Java as a String, e.g. "1.1" | * @return the version of Java as a String, e.g. "1.1" | ||||
| * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion | * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion | ||||
| * @deprecated use org.apache.tools.ant.util.JavaEnvUtils instead | |||||
| */ | */ | ||||
| public static String getJavaVersion() { | public static String getJavaVersion() { | ||||
| return JavaEnvUtils.getJavaVersion(); | return JavaEnvUtils.getJavaVersion(); | ||||
| @@ -744,7 +764,7 @@ public class Project { | |||||
| setPropertyInternal("ant.java.version", javaVersion); | setPropertyInternal("ant.java.version", javaVersion); | ||||
| // sanity check | // sanity check | ||||
| if (javaVersion == JavaEnvUtils.JAVA_1_0) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)) { | |||||
| throw new BuildException("Ant cannot work on Java 1.0"); | throw new BuildException("Ant cannot work on Java 1.0"); | ||||
| } | } | ||||
| @@ -58,6 +58,7 @@ import java.util.Vector; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| /** | /** | ||||
| @@ -243,7 +244,7 @@ public class GenerateKey extends Task { | |||||
| } | } | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| if (Project.getJavaVersion().equals(Project.JAVA_1_1)) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| throw new BuildException("The genkey task is only available on JDK" | throw new BuildException("The genkey task is only available on JDK" | ||||
| + " versions 1.2 or greater"); | + " versions 1.2 or greater"); | ||||
| } | } | ||||
| @@ -66,6 +66,7 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| /** | /** | ||||
| * Get a particular file from a URL source. | * Get a particular file from a URL source. | ||||
| @@ -303,7 +304,7 @@ public class Get extends Task { | |||||
| * @param v "true" to enable file time fetching | * @param v "true" to enable file time fetching | ||||
| */ | */ | ||||
| public void setUseTimestamp(boolean v) { | public void setUseTimestamp(boolean v) { | ||||
| if (Project.getJavaVersion() != Project.JAVA_1_1) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| useTimestamp = v; | useTimestamp = v; | ||||
| } | } | ||||
| } | } | ||||
| @@ -65,6 +65,7 @@ import org.apache.tools.ant.DirectoryScanner; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| /** | /** | ||||
| * Sign a archive. | * Sign a archive. | ||||
| @@ -194,7 +195,7 @@ public class SignJar extends Task { | |||||
| private void doOneJar(File jarSource, File jarTarget) | private void doOneJar(File jarSource, File jarTarget) | ||||
| throws BuildException { | throws BuildException { | ||||
| if (Project.getJavaVersion().equals(Project.JAVA_1_1)) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| throw new BuildException("The signjar task is only available on " | throw new BuildException("The signjar task is only available on " | ||||
| + "JDK versions 1.2 or greater"); | + "JDK versions 1.2 or greater"); | ||||
| } | } | ||||
| @@ -60,15 +60,12 @@ import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.text.DateFormat; | import java.text.DateFormat; | ||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -189,7 +186,8 @@ public class Touch extends Task { | |||||
| } | } | ||||
| } | } | ||||
| if (millis >= 0 && Project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| if (millis >= 0 && | |||||
| !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| log("modification time of files cannot be set in JDK 1.1", | log("modification time of files cannot be set in JDK 1.1", | ||||
| Project.MSG_WARN); | Project.MSG_WARN); | ||||
| return; | return; | ||||
| @@ -234,7 +232,7 @@ public class Touch extends Task { | |||||
| + "read-only file " + file); | + "read-only file " + file); | ||||
| } | } | ||||
| if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -63,7 +63,7 @@ import org.apache.tools.ant.types.Path; | |||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -280,8 +280,8 @@ public class Javah extends Task { | |||||
| String compiler = project.getProperty("build.compiler"); | String compiler = project.getProperty("build.compiler"); | ||||
| if (compiler == null) { | if (compiler == null) { | ||||
| if (Project.getJavaVersion() != Project.JAVA_1_1 && | |||||
| Project.getJavaVersion() != Project.JAVA_1_2) { | |||||
| if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) && | |||||
| !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { | |||||
| compiler = "modern"; | compiler = "modern"; | ||||
| } else { | } else { | ||||
| compiler = "classic"; | compiler = "classic"; | ||||
| @@ -353,7 +353,7 @@ public class Javah extends Task { | |||||
| } | } | ||||
| // JDK1.1 is rather simpler than JDK1.2 | // JDK1.1 is rather simpler than JDK1.2 | ||||
| if (Project.getJavaVersion().startsWith("1.1")) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| if (verbose) { | if (verbose) { | ||||
| cmd.createArgument().setValue("-v"); | cmd.createArgument().setValue("-v"); | ||||
| } | } | ||||
| @@ -155,11 +155,7 @@ public abstract class AbstractMetamataTask extends Task { | |||||
| /** -mx or -Xmx depending on VM version */ | /** -mx or -Xmx depending on VM version */ | ||||
| public void setMaxmemory(String max) { | public void setMaxmemory(String max) { | ||||
| if (Project.getJavaVersion().startsWith("1.1")) { | |||||
| createJvmarg().setValue("-mx" + max); | |||||
| } else { | |||||
| createJvmarg().setValue("-Xmx" + max); | |||||
| } | |||||
| cmdl.setMaxmemory(max); | |||||
| } | } | ||||
| @@ -146,11 +146,7 @@ public class MParse extends Task { | |||||
| /** -mx or -Xmx depending on VM version */ | /** -mx or -Xmx depending on VM version */ | ||||
| public void setMaxmemory(String max){ | public void setMaxmemory(String max){ | ||||
| if (Project.getJavaVersion().startsWith("1.1")) { | |||||
| createJvmarg().setValue("-mx" + max); | |||||
| } else { | |||||
| createJvmarg().setValue("-Xmx" + max); | |||||
| } | |||||
| cmdl.setMaxmemory(max); | |||||
| } | } | ||||
| public MParse() { | public MParse() { | ||||
| @@ -59,6 +59,7 @@ import java.net.*; | |||||
| import java.util.*; | import java.util.*; | ||||
| import java.lang.reflect.*; | import java.lang.reflect.*; | ||||
| import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| /** | /** | ||||
| * proxy definition task. This allows all tasks in the build file | * proxy definition task. This allows all tasks in the build file | ||||
| @@ -198,7 +199,8 @@ public class SetProxy extends Task { | |||||
| //for Java1.1 we need to tell the system that the settings are new | //for Java1.1 we need to tell the system that the settings are new | ||||
| if (settingsChanged && project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| if (settingsChanged && | |||||
| JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| legacyResetProxySettingsCall(enablingProxy); | legacyResetProxySettingsCall(enablingProxy); | ||||
| } | } | ||||
| } | } | ||||
| @@ -60,6 +60,7 @@ import org.apache.tools.ant.types.Commandline; | |||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Random; | import java.util.Random; | ||||
| @@ -193,7 +194,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
| cmd.createArgument().setFile(attributes.getBase()); | cmd.createArgument().setFile(attributes.getBase()); | ||||
| if (attributes.getExtdirs() != null) { | if (attributes.getExtdirs() != null) { | ||||
| if (Project.getJavaVersion().startsWith("1.1")) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| /* | /* | ||||
| * XXX - This doesn't mix very well with build.systemclasspath, | * XXX - This doesn't mix very well with build.systemclasspath, | ||||
| */ | */ | ||||
| @@ -58,6 +58,7 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.PathTokenizer; | import org.apache.tools.ant.PathTokenizer; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| @@ -584,7 +585,7 @@ public class Path extends DataType implements Cloneable { | |||||
| kaffeJarFiles.setIncludes("*.jar"); | kaffeJarFiles.setIncludes("*.jar"); | ||||
| addFileset(kaffeJarFiles); | addFileset(kaffeJarFiles); | ||||
| } else if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| addExisting(new Path(null, | addExisting(new Path(null, | ||||
| System.getProperty("java.home") | System.getProperty("java.home") | ||||
| + File.separator + "lib" | + File.separator + "lib" | ||||
| @@ -420,7 +420,7 @@ public class FileUtils { | |||||
| * see whether we have a setLastModified method in File and return it. | * see whether we have a setLastModified method in File and return it. | ||||
| */ | */ | ||||
| protected final Method getSetLastModified() { | protected final Method getSetLastModified() { | ||||
| if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| return null; | return null; | ||||
| } | } | ||||
| if (setLastModified == null) { | if (setLastModified == null) { | ||||
| @@ -444,7 +444,7 @@ public class FileUtils { | |||||
| * Calls File.setLastModified(long time) in a Java 1.1 compatible way. | * Calls File.setLastModified(long time) in a Java 1.1 compatible way. | ||||
| */ | */ | ||||
| public void setFileLastModified(File file, long time) throws BuildException { | public void setFileLastModified(File file, long time) throws BuildException { | ||||
| if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||||
| if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
| return; | return; | ||||
| } | } | ||||
| Long[] times = new Long[1]; | Long[] times = new Long[1]; | ||||