maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Casey <jdca...@commonjava.org>
Subject Re: svn commit: r592157 - in /maven/components/trunk/maven-project/src: main/java/org/apache/maven/project/ test/java/org/apache/maven/project/
Date Tue, 06 Nov 2007 00:52:22 GMT
I tried several different ideas (actually, I used the unit test to  
try out various strategies), and this is the best thing I could come  
up with at the time. Since spaces in file paths is about the only  
weird character I've heard about in connection with these sorts of  
problems, I figured it was an acceptable interim solution until  
someone else found a better way.

Personally, I'm not convinced of the value of having a URI that  
references the super-POM anyway...or, for that matter, why we need  
URI's at all in this stuff. This commit was to correct changes Carlos  
put in place, so maybe he can speak to that. I was just trying to get  
the maven build back on its feet for those of us using Program Files  
to house their Maven instances.

-john

On Nov 5, 2007, at 7:31 PM, Brett Porter wrote:

> Will this fall over on any other characters? ISTR there being a  
> standard way to get a proper file URL reference for these  
> occurrences, but it's slipping my mind right now...
>
> On 06/11/2007, at 8:40 AM, jdcasey@apache.org wrote:
>
>> Author: jdcasey
>> Date: Mon Nov  5 13:40:11 2007
>> New Revision: 592157
>>
>> URL: http://svn.apache.org/viewvc?rev=592157&view=rev
>> Log:
>> [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.
>>
>> Added:
>>     maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/ProjectBuilderURITest.java   (with props)
>> Modified:
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java
>>     maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/AbstractMavenProjectTestCase.java
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/DefaultMavenProjectBuilder.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/ 
>> DefaultMavenProjectBuilder.java? 
>> rev=592157&r1=592156&r2=592157&view=diff
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java Mon Nov  5 13:40:11  
>> 2007
>> @@ -1059,7 +1059,7 @@
>>          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 );
>>          }
>>
>> Modified: maven/components/trunk/maven-project/src/test/java/org/ 
>> apache/maven/project/AbstractMavenProjectTestCase.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/test/java/org/apache/maven/project/ 
>> AbstractMavenProjectTestCase.java? 
>> rev=592157&r1=592156&r2=592157&view=diff
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/AbstractMavenProjectTestCase.java (original)
>> +++ maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/AbstractMavenProjectTestCase.java Mon Nov  5  
>> 13:40:11 2007
>> @@ -80,7 +80,7 @@
>>              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()
>>
>> Added: maven/components/trunk/maven-project/src/test/java/org/ 
>> apache/maven/project/ProjectBuilderURITest.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/test/java/org/apache/maven/project/ 
>> ProjectBuilderURITest.java?rev=592157&view=auto
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/ProjectBuilderURITest.java (added)
>> +++ maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/ProjectBuilderURITest.java Mon Nov  5 13:40:11 2007
>> @@ -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 );
>> +    }
>> +
>> +}
>>
>> Propchange: maven/components/trunk/maven-project/src/test/java/org/ 
>> apache/maven/project/ProjectBuilderURITest.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:eol-style = native
>>
>> Propchange: maven/components/trunk/maven-project/src/test/java/org/ 
>> apache/maven/project/ProjectBuilderURITest.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:keywords = "Author Date Id Revision"
>>
>>
>
> --
> Brett Porter - brett@apache.org
> Blog: http://www.devzuz.org/blogs/bporter/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

---
John Casey
Committer and PMC Member, Apache Maven
mail: jdcasey at commonjava dot org
blog: http://www.ejlife.net/blogs/john
rss: http://feeds.feedburner.com/ejlife/john



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message