Author: hibou
Date: Wed Aug 22 00:14:07 2012
New Revision: 1375859
URL: http://svn.apache.org/viewvc?rev=1375859&view=rev
Log:
Fixing tests: when trying to convert an url to a file, try first new File(new
URI(url.toExternalForm())), then new File(url.getPath())
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=1375859&r1=1375858&r2=1375859&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
Wed Aug 22 00:14:07 2012
@@ -20,6 +20,8 @@ package org.apache.ivy.plugins.resolver;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -1036,7 +1038,14 @@ public abstract class BasicResolver exte
logArtifactAttempt(artifact, url.toExternalForm());
Resource resource;
if ("file".equals(url.getProtocol())) {
- resource = new FileResource(new FileRepository(), new
File(url.getPath()));
+ File f;
+ try {
+ f = new File(new URI(url.toExternalForm()));
+ } catch (URISyntaxException e) {
+ // unexpected, try to get the best of it
+ f = new File(url.getPath());
+ }
+ resource = new FileResource(new FileRepository(), f);
} else {
resource = new URLResource(url);
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java?rev=1375859&r1=1375858&r2=1375859&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
Wed Aug 22 00:14:07 2012
@@ -19,6 +19,8 @@ package org.apache.ivy.plugins.resolver.
import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
@@ -40,7 +42,13 @@ public class FileURLLister implements UR
}
public List listAll(URL url) throws IOException {
- String path = url.getPath();
+ String path;
+ try {
+ path = new File(new URI(url.toExternalForm())).getPath();
+ } catch (URISyntaxException e) {
+ // unexpected try to get the best of it
+ path = url.getPath();
+ }
File file = basedir == null ? new File(path) : new File(basedir, path);
if (file.exists() && file.isDirectory()) {
String[] files = file.list();