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 2019/08/03 08:25:00 UTC

[maven] branch MNG-6716 updated (16bcff5 -> e536d59)

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

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


 discard 16bcff5  [MNG-6716] Avoid setting compileRoots
     new e536d59  [MNG-6716] Avoid setting compileRoots

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   (16bcff5)
            \
             N -- N -- N   refs/heads/MNG-6716 (e536d59)

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:


[maven] 01/01: [MNG-6716] Avoid setting compileRoots

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

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

commit e536d59e78a097aaef5fa3b396c4c6bfbbc48210
Author: Mickael Istria <mi...@redhat.com>
AuthorDate: Wed Jul 31 18:19:10 2019 +0200

    [MNG-6716] Avoid setting compileRoots
    
    Recent changes in ProjectBuilder make that the compile roots could be
    set erroneously on 1st phase and propagated in the results.
    This patch just skips setting the compile source root in the 1st pass
    (when buildParentIfNonExisting==false).
    
    It also tests some other fields of MavenProject
    
    This closes #274
---
 .../maven/project/DefaultProjectBuilder.java       |  2 +-
 .../apache/maven/project/ProjectBuilderTest.java   | 16 ++++++++++++++++
 .../project-builder/MNG-6716/project/pom.xml       | 22 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index 51c90cc..7e18f1e 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -684,7 +684,7 @@ public class DefaultProjectBuilder
                                              project.getPackaging() );
         project.setArtifact( projectArtifact );
 
-        if ( project.getFile() != null )
+        if ( project.getFile() != null && buildParentIfNotExisting ) // only set those on 2nd phase, ignore on 1st pass
         {
             Build build = project.getBuild();
             project.addScriptSourceRoot( build.getScriptSourceDirectory() );
diff --git a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
index 95c3149..c9fe27d 100644
--- a/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
@@ -306,4 +306,20 @@ public class ProjectBuilderTest
         }
     }
 
+    public void testBuildProperties()
+            throws Exception
+    {
+        File file = new File( getProject( "MNG-6716" ).getParentFile(), "project/pom.xml" );
+        MavenSession mavenSession = createMavenSession( null );
+        ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
+        configuration.setRepositorySession( mavenSession.getRepositorySession() );
+        configuration.setResolveDependencies( true );
+        List<ProjectBuildingResult> result = projectBuilder.build( Collections.singletonList(file), true, configuration );
+        MavenProject project = result.get(0).getProject();
+        // verify a few typical parameters are not duplicated
+        assertEquals( 1, project.getTestCompileSourceRoots().size() );
+        assertEquals( 1, project.getCompileSourceRoots().size() );
+        assertEquals( 1, project.getMailingLists().size() );
+        assertEquals( 1, project.getResources().size() );
+    }
 }
diff --git a/maven-core/src/test/projects/project-builder/MNG-6716/project/pom.xml b/maven-core/src/test/projects/project-builder/MNG-6716/project/pom.xml
new file mode 100644
index 0000000..9ffa865
--- /dev/null
+++ b/maven-core/src/test/projects/project-builder/MNG-6716/project/pom.xml
@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.tests</groupId>
+  <artifactId>MNG-6716</artifactId>
+  <packaging>jar</packaging>
+  <version>0.1-SNAPSHOT</version>
+
+  <mailingLists>
+    <mailingList>
+      <name>blah</name>
+    </mailingList>
+  </mailingLists>
+
+  <build>
+      <testSourceDirectory>../sibling/src-test</testSourceDirectory>
+      <sourceDirectory>../sibling/src-main</sourceDirectory>
+      <resources>
+        <resource><directory>blah</directory></resource>
+      </resources>
+  </build>
+</project>