Project now also fails with explicit message on java 1.1. Added javadoc comment for the ant.java.version property git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@388814 13f79535-47bb-0310-9956-ffa450edef68master
@@ -187,6 +187,10 @@ public class Project implements ResourceFactory { | |||
* Flag which catches Listeners which try to use System.out or System.err . | |||
*/ | |||
private boolean loggingMessage = false; | |||
/** | |||
* Property used to store the java version ant is running in. | |||
*/ | |||
public static final String ANT_JAVA_VERSION = "ant.java.version"; | |||
/** | |||
@@ -284,6 +288,7 @@ public class Project implements ResourceFactory { | |||
setSystemProperties(); | |||
} | |||
/** | |||
* Factory method to create a class loader for loading classes from | |||
* a given path. | |||
@@ -805,8 +810,9 @@ public class Project implements ResourceFactory { | |||
setPropertyInternal(ANT_JAVA_VERSION, javaVersion); | |||
// sanity check | |||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)) { | |||
throw new BuildException("Ant cannot work on Java 1.0"); | |||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0) | |||
|| JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||
throw new BuildException("Ant cannot work on Java 1.0 / 1.1"); | |||
} | |||
log("Detected Java version: " + javaVersion + " in: " | |||
+ System.getProperty("java.home"), MSG_VERBOSE); | |||
@@ -1332,25 +1338,13 @@ public class Project implements ResourceFactory { | |||
* | |||
* @return the native version of the specified path or | |||
* an empty string if the path is <code>null</code> or empty. | |||
* | |||
* @deprecated use FileUtils.translatePath instead. | |||
* | |||
* @see PathTokenizer | |||
*/ | |||
public static String translatePath(String toProcess) { | |||
if (toProcess == null || toProcess.length() == 0) { | |||
return ""; | |||
} | |||
StringBuffer path = new StringBuffer(toProcess.length() + 50); | |||
PathTokenizer tokenizer = new PathTokenizer(toProcess); | |||
while (tokenizer.hasMoreTokens()) { | |||
String pathComponent = tokenizer.nextToken(); | |||
pathComponent = pathComponent.replace('/', File.separatorChar); | |||
pathComponent = pathComponent.replace('\\', File.separatorChar); | |||
if (path.length() != 0) { | |||
path.append(File.pathSeparatorChar); | |||
} | |||
path.append(pathComponent); | |||
} | |||
return path.toString(); | |||
return FileUtils.translatePath(toProcess); | |||
} | |||
/** | |||
@@ -117,9 +117,7 @@ public class Javac extends MatchingTask { | |||
} | |||
private String assumedJavaVersion() { | |||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||
return JAVAC11; | |||
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { | |||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { | |||
return JAVAC12; | |||
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) { | |||
return JAVAC13; | |||
@@ -24,6 +24,7 @@ import org.apache.tools.ant.taskdefs.Execute; | |||
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; | |||
import org.apache.tools.ant.taskdefs.LogStreamHandler; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
@@ -65,7 +66,7 @@ public abstract class Continuus extends Task { | |||
* @param dir the directory containing the ccm executable | |||
*/ | |||
public final void setCcmDir(String dir) { | |||
ccmDir = Project.translatePath(dir); | |||
ccmDir = FileUtils.translatePath(dir); | |||
} | |||
/** | |||
@@ -25,6 +25,7 @@ import org.apache.tools.ant.taskdefs.ExecTask; | |||
import org.apache.tools.ant.taskdefs.Execute; | |||
import org.apache.tools.ant.taskdefs.LogStreamHandler; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.util.FileUtils; | |||
@@ -54,7 +55,7 @@ public abstract class ClearCase extends Task { | |||
* @param dir the directory containing the cleartool executable | |||
*/ | |||
public final void setClearToolDir(String dir) { | |||
mClearToolDir = Project.translatePath(dir); | |||
mClearToolDir = FileUtils.translatePath(dir); | |||
} | |||
/** | |||
@@ -24,6 +24,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.taskdefs.MatchingTask; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* Builds a serialized deployment descriptor given a text file description of the | |||
@@ -87,7 +88,7 @@ public class DDCreator extends MatchingTask { | |||
} | |||
String systemClassPath = System.getProperty("java.class.path"); | |||
String execClassPath = Project.translatePath(systemClassPath + ":" + classpath); | |||
String execClassPath = FileUtils.translatePath(systemClassPath + ":" + classpath); | |||
Java ddCreatorTask = new Java(this); | |||
ddCreatorTask.setFork(true); | |||
ddCreatorTask.setClassname("org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper"); | |||
@@ -126,6 +127,6 @@ public class DDCreator extends MatchingTask { | |||
* @param s the classpath to use for the ddcreator tool. | |||
*/ | |||
public void setClasspath(String s) { | |||
this.classpath = getProject().translatePath(s); | |||
this.classpath = FileUtils.translatePath(s); | |||
} | |||
} |
@@ -24,6 +24,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.taskdefs.MatchingTask; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* Builds EJB support classes using WebLogic's ejbc tool from a directory containing | |||
@@ -94,7 +95,7 @@ public class Ejbc extends MatchingTask { | |||
String systemClassPath = System.getProperty("java.class.path"); | |||
String execClassPath | |||
= Project.translatePath(systemClassPath + ":" + classpath | |||
= FileUtils.translatePath(systemClassPath + ":" + classpath | |||
+ ":" + generatedFilesDirectory); | |||
// get all the files in the descriptor directory | |||
DirectoryScanner ds = super.getDirectoryScanner(descriptorDirectory); | |||
@@ -172,7 +173,7 @@ public class Ejbc extends MatchingTask { | |||
* Set the classpath to be used for this compilation. | |||
*/ | |||
public void setClasspath(String s) { | |||
this.classpath = getProject().translatePath(s); | |||
this.classpath = FileUtils.translatePath(s); | |||
} | |||
/** | |||
@@ -24,6 +24,7 @@ import org.apache.tools.ant.taskdefs.Execute; | |||
import org.apache.tools.ant.taskdefs.LogStreamHandler; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* A base class for creating tasks for executing commands on SourceOffSite. | |||
@@ -82,7 +83,7 @@ public abstract class SOS extends Task implements SOSCmd { | |||
* @param dir The new sosCmd value. | |||
*/ | |||
public final void setSosCmd(String dir) { | |||
sosCmdDir = Project.translatePath(dir); | |||
sosCmdDir = FileUtils.translatePath(dir); | |||
} | |||
/** | |||
@@ -32,6 +32,7 @@ import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.taskdefs.Execute; | |||
import org.apache.tools.ant.taskdefs.LogStreamHandler; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* A base class for creating tasks for executing commands on Visual SourceSafe. | |||
@@ -112,7 +113,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* @param dir The directory containing ss.exe. | |||
*/ | |||
public final void setSsdir(String dir) { | |||
this.ssDir = Project.translatePath(dir); | |||
this.ssDir = FileUtils.translatePath(dir); | |||
} | |||
/** | |||
@@ -32,6 +32,7 @@ import java.util.Stack; | |||
import java.util.StringTokenizer; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.PathTokenizer; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.taskdefs.condition.Os; | |||
import org.apache.tools.ant.types.FilterSetCollection; | |||
@@ -601,6 +602,40 @@ public class FileUtils { | |||
|| (onNetWare && colon > 0); | |||
} | |||
/** | |||
* Translate a path into its native (platform specific) format. | |||
* <p> | |||
* This method uses PathTokenizer to separate the input path | |||
* into its components. This handles DOS style paths in a relatively | |||
* sensible way. The file separators are then converted to their platform | |||
* specific versions. | |||
* | |||
* @param toProcess The path to be translated. | |||
* May be <code>null</code>. | |||
* | |||
* @return the native version of the specified path or | |||
* an empty string if the path is <code>null</code> or empty. | |||
* | |||
* @since ant 1.7 | |||
* @see PathTokenizer | |||
*/ | |||
public static String translatePath(String toProcess) { | |||
if (toProcess == null || toProcess.length() == 0) { | |||
return ""; | |||
} | |||
StringBuffer path = new StringBuffer(toProcess.length() + 50); | |||
PathTokenizer tokenizer = new PathTokenizer(toProcess); | |||
while (tokenizer.hasMoreTokens()) { | |||
String pathComponent = tokenizer.nextToken(); | |||
pathComponent = pathComponent.replace('/', File.separatorChar); | |||
pathComponent = pathComponent.replace('\\', File.separatorChar); | |||
if (path.length() != 0) { | |||
path.append(File.pathSeparatorChar); | |||
} | |||
path.append(pathComponent); | |||
} | |||
return path.toString(); | |||
} | |||
/** | |||
* "Normalize" the given absolute path. | |||
* | |||