mirror of https://github.com/apache/maven.git
[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:
parent
083a7dd4f0
commit
d206986023
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue