ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r388814 - in /ant/core/trunk/src/main/org/apache/tools/ant: ./ taskdefs/ taskdefs/optional/ccm/ taskdefs/optional/clearcase/ taskdefs/optional/ejb/ taskdefs/optional/sos/ taskdefs/optional/vss/ util/
Date Sat, 25 Mar 2006 20:20:52 GMT
Author: jkf
Date: Sat Mar 25 12:20:49 2006
New Revision: 388814

URL: http://svn.apache.org/viewcvs?rev=388814&view=rev
Log:
Refactored translatePath from Project to FileUtils. 
Project now also fails with explicit message on java 1.1.
Added javadoc comment for the ant.java.version property

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Sat Mar 25 12:20:49 2006
@@ -187,6 +187,10 @@
      * 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 @@
         setSystemProperties();
     }
 
+
     /**
      * Factory method to create a class loader for loading classes from
      * a given path.
@@ -805,8 +810,9 @@
         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 @@
      *
      * @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);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java Sat Mar 25 12:20:49 2006
@@ -117,9 +117,7 @@
     }
 
     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;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java Sat
Mar 25 12:20:49 2006
@@ -24,6 +24,7 @@
 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 @@
      * @param dir the directory containing the ccm executable
      */
     public final void setCcmDir(String dir) {
-        ccmDir = Project.translatePath(dir);
+        ccmDir = FileUtils.translatePath(dir);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
Sat Mar 25 12:20:49 2006
@@ -25,6 +25,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.util.FileUtils;
 
 
 
@@ -54,7 +55,7 @@
      * @param dir the directory containing the cleartool executable
      */
     public final void setClearToolDir(String dir) {
-        mClearToolDir = Project.translatePath(dir);
+        mClearToolDir = FileUtils.translatePath(dir);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java Sat
Mar 25 12:20:49 2006
@@ -24,6 +24,7 @@
 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 @@
         }
 
         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 @@
      * @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);
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java Sat Mar 25
12:20:49 2006
@@ -24,6 +24,7 @@
 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 @@
 
         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 @@
      * Set the classpath to be used for this compilation.
      */
     public void setClasspath(String s) {
-        this.classpath = getProject().translatePath(s);
+        this.classpath = FileUtils.translatePath(s);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java Sat Mar 25
12:20:49 2006
@@ -24,6 +24,7 @@
 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 @@
      * @param  dir  The new sosCmd value.
      */
     public final void setSosCmd(String dir) {
-        sosCmdDir = Project.translatePath(dir);
+        sosCmdDir = FileUtils.translatePath(dir);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java Sat Mar
25 12:20:49 2006
@@ -32,6 +32,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.util.FileUtils;
 
 /**
  * A base class for creating tasks for executing commands on Visual SourceSafe.
@@ -112,7 +113,7 @@
      * @param  dir  The directory containing ss.exe.
      */
     public final void setSsdir(String dir) {
-        this.ssDir = Project.translatePath(dir);
+        this.ssDir = FileUtils.translatePath(dir);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?rev=388814&r1=388813&r2=388814&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Sat Mar 25 12:20:49 2006
@@ -32,6 +32,7 @@
 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 @@
             || (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();
+    }
     /**
      * &quot;Normalize&quot; the given absolute path.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message