[MNG-3272] Fixing URI construction for reading the super-POM in cases where maven is in a directory structure where there are spaces in the path.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@592157 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-11-05 21:40:11 +00:00
parent 083a7dd4f0
commit d206986023
3 changed files with 34 additions and 2 deletions

View File

@ -1059,7 +1059,7 @@ public class DefaultMavenProjectBuilder
URI uri = null;
try
{
uri = new URI( url.toString() );
uri = new URI( url.toString().replaceAll( " ", "%20" ) );
reader = ReaderFactory.newXmlReader( url.openStream() );
return readModel( projectId, uri, reader, strict );
}

View File

@ -80,7 +80,7 @@ public abstract class AbstractMavenProjectTestCase
throw new FileNotFoundException( "Unable to find: " + resource );
}
return new File( new URI( resourceUrl.toString() ) );
return new File( new URI( resourceUrl.toString().replaceAll( " ", "%20" ) ) );
}
protected ArtifactRepository getLocalRepository()

View File

@ -0,0 +1,32 @@
package org.apache.maven.project;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import junit.framework.TestCase;
public class ProjectBuilderURITest
extends TestCase
{
/**
* MNG-3272:
* See {@link DefaultMavenProjectBuilder#readModel(String, URL, boolean)}
* for where this fix is implemented.
*/
public void testURL_to_URI_forSuperPom_WhenMavenHasSpaceInPath()
throws URISyntaxException, MalformedURLException, UnsupportedEncodingException
{
String url = "jar:file:/c:/Program Files/maven2.1/bin/../lib/maven-project-2.1-SNAPSHOT.jar!/org/apache/maven/project/pom-4.0.0.xml";
System.out.println( "Original URL String:\n" + url );
URL urlInst = new URL( url );
URI uUri = new URI( urlInst.toExternalForm().replaceAll( " ", "%20" ) );
System.out.println( "URI result:\n" + uUri );
}
}