You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2018/05/02 22:44:07 UTC

[maven] branch MNG-6386 updated (b10e8b5 -> 9d29bb4)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MNG-6386
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard b10e8b5  Added a test for Windows
 discard 43b3459  [MNG-6386] project.baseUri is not a valid URL on Windows
     new 9d29bb4  [MNG-6386] ${project.baseUri} is not a valid URI (according to RFC 3986)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b10e8b5)
            \
             N -- N -- N   refs/heads/MNG-6386 (9d29bb4)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../interpolation/AbstractStringBasedModelInterpolator.java    |  2 +-
 .../java/org/apache/maven/project/PomConstructionTest.java     | 10 ++++++----
 .../interpolation/AbstractStringBasedModelInterpolator.java    |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
michaelo@apache.org.

[maven] 01/01: [MNG-6386] ${project.baseUri} is not a valid URI (according to RFC 3986)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MNG-6386
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 9d29bb4d91e9545a9b5bc2957646ad42d5add210
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Mar 30 22:07:18 2018 +0200

    [MNG-6386] ${project.baseUri} is not a valid URI (according to RFC 3986)
    
    File#toURI()#toString() produces a non-compliant URI making tools like
    Subversion or Git to choke on those URIs. Whereas Path#toUri()#toASCIIString()
    does the right job.
---
 .../AbstractStringBasedModelInterpolator.java      |  2 +-
 .../apache/maven/project/PomConstructionTest.java  | 81 ++++++++++++----------
 .../pom.xml                                        |  0
 .../AbstractStringBasedModelInterpolator.java      |  4 +-
 4 files changed, 49 insertions(+), 38 deletions(-)

diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
index 913e2dd..996baef 100644
--- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
+++ b/maven-compat/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
@@ -241,7 +241,7 @@ public abstract class AbstractStringBasedModelInterpolator
             {
                 if ( projectDir != null && "baseUri".equals( expression ) )
                 {
-                    return projectDir.getAbsoluteFile().toURI().toString();
+                    return projectDir.getAbsoluteFile().toPath().toUri().toASCIIString();
                 }
                 return null;
             }
diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
index ba5e3a0..33b8968 100644
--- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
@@ -39,6 +39,7 @@ import org.codehaus.plexus.PlexusTestCase;
 import org.eclipse.aether.DefaultRepositorySystemSession;
 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
 import org.eclipse.aether.repository.LocalRepository;
+import static org.junit.Assert.assertNotEquals;
 
 public class PomConstructionTest
     extends PlexusTestCase
@@ -140,9 +141,9 @@ public class PomConstructionTest
 
     /*MNG-3900*/
     public void testProfilePropertiesInterpolation()
-    	throws Exception
+        throws Exception
     {
-    	PomTestWrapper pom = buildPom( "profile-properties-interpolation", "interpolation-profile" );
+        PomTestWrapper pom = buildPom( "profile-properties-interpolation", "interpolation-profile" );
         assertEquals( "PASSED", pom.getValue( "properties[1]/test" ) );
         assertEquals( "PASSED", pom.getValue( "properties[1]/property" ) );
     }
@@ -1082,11 +1083,21 @@ public class PomConstructionTest
     }
 
     /* MNG-3760*/
-    public void testInterpolationOfBaseUrl()
+    public void testInterpolationOfBaseUri()
+        throws Exception
+    {
+        PomTestWrapper pom = buildPom( "baseuri-interpolation/pom.xml" );
+        assertNotEquals( pom.getBasedir().toURI().toString(), pom.getValue( "properties/prop1" ).toString() );
+    }
+
+    /* MNG-6386 */
+    public void testInterpolationOfRfc3986BaseUri()
         throws Exception
     {
-        PomTestWrapper pom = buildPom( "baseurl-interpolation/pom.xml" );
-        assertEquals( pom.getBasedir().toURI().toString(), pom.getValue( "properties/prop1" ).toString() );
+        PomTestWrapper pom = buildPom( "baseuri-interpolation/pom.xml" );
+        String prop1 = pom.getValue( "properties/prop1" ).toString();
+        assertEquals( pom.getBasedir().toPath().toUri().toASCIIString(), prop1 );
+        assertTrue( prop1.startsWith( "file:///" ) );
     }
 
     /* MNG-3811*/
@@ -1103,9 +1114,9 @@ public class PomConstructionTest
     }
 
     public void testPropertiesNoDuplication()
-    	throws Exception
+        throws Exception
     {
-    	PomTestWrapper pom = buildPom( "properties-no-duplication/sub" );	
+        PomTestWrapper pom = buildPom( "properties-no-duplication/sub" );
         assertEquals( 1, ( (Properties) pom.getValue( "properties" ) ).size() );
         assertEquals( "child", pom.getValue( "properties/pomProfile" ) );
     }
@@ -1416,9 +1427,9 @@ public class PomConstructionTest
 
     /*MNG-1957*/
     public void testJdkActivation()
-    	throws Exception
-	{
-    	Properties props = new Properties();
+        throws Exception
+    {
+        Properties props = new Properties();
         props.put( "java.version", "1.5.0_15" );
 
         PomTestWrapper pom = buildPom( "jdk-activation", props );
@@ -1426,7 +1437,7 @@ public class PomConstructionTest
         assertEquals( "PASSED", pom.getValue( "properties/jdkProperty3" ) );
         assertEquals( "PASSED", pom.getValue( "properties/jdkProperty2" ) );
         assertEquals( "PASSED", pom.getValue( "properties/jdkProperty1" ) );
-	}
+    }
 
     /* MNG-2174 */
     public void testProfilePluginMngDependencies()
@@ -1464,54 +1475,54 @@ public class PomConstructionTest
     }
 
     public void testProfilePlugins()
-	    throws Exception
-	{
+        throws Exception
+    {
         PomTestWrapper pom = this.buildPom( "profile-plugins", "standard" );
         assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins" ) ).size() );
         assertEquals( "maven-assembly2-plugin", pom.getValue( "build/plugins[2]/artifactId" ) );
-	}
+    }
 
     public void testPluginInheritanceSimple()
-	    throws Exception
-	{
+        throws Exception
+    {
         PomTestWrapper pom = this.buildPom( "plugin-inheritance-simple/sub" );
-	    assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins" ) ).size() );
-	}
+        assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins" ) ).size() );
+    }
 
     public void testPluginManagementDuplicate()
-	    throws Exception
-	{
+        throws Exception
+    {
         PomTestWrapper pom = this.buildPom( "plugin-management-duplicate/sub" );
         assertEquals( 12, ( (List<?>) pom.getValue( "build/pluginManagement/plugins" ) ).size() );
-	}
+    }
 
     public void testDistributionManagement()
-	    throws Exception
-	{
+        throws Exception
+    {
         PomTestWrapper pom = this.buildPom( "distribution-management" );
         assertEquals( "legacy", pom.getValue( "distributionManagement/repository/layout" ) );
-	}
+    }
 
     public void testDependencyScopeInheritance()
-	    throws Exception
-	{
+        throws Exception
+    {
         PomTestWrapper pom = buildPom( "dependency-scope-inheritance/sub" );
         String scope = (String) pom.getValue( "dependencies[1]/scope" );
         assertEquals( "compile", scope );
-	}
+    }
 
     public void testDependencyScope()
-	    throws Exception
-	{
-	    buildPom( "dependency-scope/sub" );
-	}
+        throws Exception
+    {
+        buildPom( "dependency-scope/sub" );
+    }
 
     //This will fail on a validation error if incorrect
     public void testDependencyManagementWithInterpolation()
-	    throws Exception
-	{
-	    buildPom( "dependency-management-with-interpolation/sub" );
-	}
+        throws Exception
+    {
+        buildPom( "dependency-management-with-interpolation/sub" );
+    }
 
     public void testInterpolationWithSystemProperty()
         throws Exception
diff --git a/maven-core/src/test/resources-project-builder/baseurl-interpolation/pom.xml b/maven-core/src/test/resources-project-builder/baseuri-interpolation/pom.xml
similarity index 100%
rename from maven-core/src/test/resources-project-builder/baseurl-interpolation/pom.xml
rename to maven-core/src/test/resources-project-builder/baseuri-interpolation/pom.xml
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
index ae8a35e..0322f89 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java
@@ -61,7 +61,7 @@ public abstract class AbstractStringBasedModelInterpolator
     public static final String CHANGELIST_PROPERTY = "changelist";
 
     public static final String REVISION_PROPERTY = "revision";
-    
+
     private static final List<String> PROJECT_PREFIXES = Arrays.asList( "pom.", "project." );
 
     private static final Collection<String> TRANSLATED_PATH_EXPRESSIONS;
@@ -158,7 +158,7 @@ public abstract class AbstractStringBasedModelInterpolator
                 {
                     if ( "baseUri".equals( expression ) )
                     {
-                        return projectDir.getAbsoluteFile().toURI().toString();
+                        return projectDir.getAbsoluteFile().toPath().toUri().toASCIIString();
                     }
                     return null;
                 }

-- 
To stop receiving notification emails like this one, please contact
michaelo@apache.org.