You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2019/08/05 21:08:15 UTC

[maven] branch MNG-6714_2 created (now 8d78b4d)

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

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


      at 8d78b4d  checkout core-its/MNG-6714_2

This branch includes the following new commits:

     new ddee6b9  interpolate non java classes
     new 8d78b4d  checkout core-its/MNG-6714_2

The 2 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.



[maven] 02/02: checkout core-its/MNG-6714_2

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

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

commit 8d78b4de7c210ed69c7a1eb47a1bdb4337b930d9
Author: tibordigana <ti...@apache.org>
AuthorDate: Mon Aug 5 23:08:03 2019 +0200

    checkout core-its/MNG-6714_2
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 5d5d998..0817dc1 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -66,7 +66,7 @@ node(jenkinsEnv.nodeSelection(osNode)) {
             }
         }
 
-        tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'master']
+        tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'MNG-6714_2']
     }
 }
 


[maven] 01/02: interpolate non java classes

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

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

commit ddee6b9abf0feaea1c958afc4336f29941bc437e
Author: tibordigana <ti...@apache.org>
AuthorDate: Mon Aug 5 16:47:27 2019 +0200

    interpolate non java classes
---
 .../StringSearchModelInterpolator.java             | 48 ++++++++++++----------
 .../StringSearchModelInterpolatorTest.java         | 35 ++++++++++++++++
 2 files changed, 61 insertions(+), 22 deletions(-)

diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
index 3c2ea13..ae43aa4 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
@@ -278,33 +278,37 @@ public class StringSearchModelInterpolator
                 this.isQualifiedForInterpolation = isQualifiedForInterpolation( clazz );
                 this.isArray = clazz.isArray();
                 List<CacheField> fields = new ArrayList<>();
-                for ( Field currentField : clazz.getDeclaredFields() )
+                if ( isQualifiedForInterpolation )
                 {
-                    Class<?> type = currentField.getType();
-                    if ( isQualifiedForInterpolation( currentField, type ) )
+                    for ( Field currentField : clazz.getDeclaredFields() )
                     {
-                        if ( String.class == type )
+                        Class<?> type = currentField.getType();
+                        if ( isQualifiedForInterpolation( currentField, type ) )
                         {
-                            if ( !Modifier.isFinal( currentField.getModifiers() ) )
+                            if ( String.class == type )
                             {
-                                fields.add( new StringField( currentField ) );
+                                if ( !Modifier.isFinal( currentField.getModifiers() ) )
+                                {
+                                    fields.add( new StringField( currentField ) );
+                                }
+                            }
+                            else if ( List.class.isAssignableFrom( type ) )
+                            {
+                                fields.add( new ListField( currentField ) );
+                            }
+                            else if ( Collection.class.isAssignableFrom( type ) )
+                            {
+                                throw new RuntimeException(
+                                        "We dont interpolate into collections, use a list instead" );
+                            }
+                            else if ( Map.class.isAssignableFrom( type ) )
+                            {
+                                fields.add( new MapField( currentField ) );
+                            }
+                            else
+                            {
+                                fields.add( new ObjectField( currentField ) );
                             }
-                        }
-                        else if ( List.class.isAssignableFrom( type ) )
-                        {
-                            fields.add( new ListField( currentField ) );
-                        }
-                        else if ( Collection.class.isAssignableFrom( type ) )
-                        {
-                            throw new RuntimeException( "We dont interpolate into collections, use a list instead" );
-                        }
-                        else if ( Map.class.isAssignableFrom( type ) )
-                        {
-                            fields.add( new MapField( currentField ) );
-                        }
-                        else
-                        {
-                            fields.add( new ObjectField( currentField ) );
                         }
                     }
                 }
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java
index 71ebf51..907a0b5 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java
@@ -33,6 +33,10 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
 /**
  * @author jdcasey
  * @author Benjamin Bentmann
@@ -337,6 +341,37 @@ public class StringSearchModelInterpolatorTest
         assertEquals( "value4", ( (String[]) obj.values.get( "key2" ) )[1] );
     }
 
+    public void testInterpolateObjectWithFile()
+            throws Exception
+    {
+        Model model = new Model();
+        model.setPomFile( new File( System.getProperty( "user.dir" ), "pom.xml" ) );
+        File baseDir = model.getProjectDirectory();
+
+        Properties p = new Properties();
+
+        Map<String, String> values = new HashMap<>();
+        values.put( "key", "${project.basedir}" + File.separator + "target" );
+
+        ObjectWithMapField obj = new ObjectWithMapField( values );
+
+        StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator();
+
+        ModelBuildingRequest config = createModelBuildingRequest( p );
+
+        SimpleProblemCollector collector = new SimpleProblemCollector();
+        interpolator.interpolateObject( obj, model, new File( "." ), config, collector );
+        assertProblemFree( collector );
+
+        assertThat( baseDir.getCanonicalPath(), is( System.getProperty( "user.dir" ) ) );
+        assertThat( obj.values.size(), is( 1 ) );
+        assertThat( (String) obj.values.get( "key" ), is( anyOf(
+                is( System.getProperty( "user.dir" ) + File.separator + "target" ),
+                // TODO why MVN adds dot /./ in paths???
+                is( System.getProperty( "user.dir" ) + File.separator + '.' + File.separator + "target" )
+        ) ) );
+    }
+
 
     public void testConcurrentInterpolation()
         throws Exception