ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r396563 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW src/main/org/apache/tools/ant/launch/Launcher.java src/main/org/apache/tools/ant/launch/Locator.java
Date Mon, 24 Apr 2006 14:15:57 GMT
Author: peterreilly
Date: Mon Apr 24 07:15:52 2006
New Revision: 396563

URL: http://svn.apache.org/viewcvs?rev=396563&view=rev
Log:
Bugzilla Report: 39295
Reporter: Waldek Herka
extract the fileToURL code
use it for tools jar as well as the other paths

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
    ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewcvs/ant/core/trunk/CONTRIBUTORS?rev=396563&r1=396562&r2=396563&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewcvs/ant/core/trunk/WHATSNEW?rev=396563&r1=396562&r2=396563&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Apr 24 07:15:52 2006
@@ -397,6 +397,9 @@
   attribute will read default values from the properties
   ant.build.javac.source and ant.build.javac.target.
 
+* Handling of ' ', '#' in CLASSPATH and '#' in -lib (cannot use ' '
+  in -lib on UNIX at the moment). Bugzilla Report 39295.
+
 Changes from Ant 1.6.4 to Ant 1.6.5
 ===================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java?rev=396563&r1=396562&r2=396563&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java Mon Apr 24 07:15:52
2006
@@ -130,11 +130,7 @@
                 }
             }
 
-            try {
-                libPathURLs.add(new URL(Locator.encodeURI(element.toURL().toString())));
-            } catch (UnsupportedEncodingException ex) {
-                throw new MalformedURLException(ex.toString());
-            }
+            libPathURLs.add(Locator.fileToURL(element));
         }
     }
 
@@ -255,7 +251,7 @@
             systemJars.length);
 
         if (toolsJar != null) {
-            jars[jars.length - 1] = toolsJar.toURL();
+            jars[jars.length - 1] = Locator.fileToURL(toolsJar);
         }
 
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java?rev=396563&r1=396562&r2=396563&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java Mon Apr 24 07:15:52 2006
@@ -311,6 +311,28 @@
     }
 
     /**
+     * Convert a File to a URL.
+     * File.toURL() does not encode characters like #.
+     * File.toURI() has been introduced in java 1.4, so
+     * ANT cannot use it (except by reflection)
+     * FileUtils.toURI() cannot be used by Locator.java
+     * Implemented this way.
+     * File.toURL() adds file: and changes '\' to '/' for dos OSes
+     * encodeURI converts characters like ' ' and '#' to %DD
+     * @param file the file to convert
+     * @return URL the converted File
+     * @throws MalformedURLException on error
+     */
+    public static URL fileToURL(File file)
+        throws MalformedURLException {
+        try {
+            return new URL(encodeURI(file.toURL().toString()));
+        } catch (UnsupportedEncodingException ex) {
+            throw new MalformedURLException(ex.toString());
+        }
+    }
+
+    /**
      * Get the File necessary to load the Sun compiler tools. If the classes
      * are available to this class, then no additional URL is required and
      * null is returned. This may be because the classes are explicitly in the
@@ -401,20 +423,7 @@
             String path = location.getPath();
             for (int i = 0; i < extensions.length; ++i) {
                 if (path.toLowerCase().endsWith(extensions[i])) {
-                    try {
-                        /**
-                         * File.toURL() does not encode characters like #.
-                         * File.toURI() has been introduced in java 1.4, so
-                         * ANT cannot use it (except by reflection)
-                         * FileUtils.toURI() cannot be used by Locator.java
-                         * Implemented this way.
-                         * File.toURL() adds file: and changes '\' to '/' for dos OSes
-                         * encodeURI converts characters like ' ' and '#' to %DD
-                         */
-                        urls[0] = new URL(encodeURI(location.toURL().toString()));
-                    } catch (UnsupportedEncodingException ex) {
-                        throw new MalformedURLException(ex.toString());
-                    }
+                    urls[0] = fileToURL(location);
                     break;
                 }
             }
@@ -433,12 +442,7 @@
             });
         urls = new URL[matches.length];
         for (int i = 0; i < matches.length; ++i) {
-            try {
-                // See comments above.
-                urls[i] = new URL(encodeURI(matches[i].toURL().toString()));
-            } catch (UnsupportedEncodingException ex) {
-                throw new MalformedURLException(ex.toString());
-            }
+            urls[i] = fileToURL(matches[i]);
         }
         return urls;
     }



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


Mime
View raw message