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 2021/08/16 21:24:19 UTC

[maven] branch test-for-MNG-5669 created (now 209e643)

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

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


      at 209e643  Add ModelSource test for MNG-5669

This branch includes the following new commits:

     new 209e643  Add ModelSource test for MNG-5669

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.


[maven] 01/01: Add ModelSource test for MNG-5669

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

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

commit 209e6434d2baf963d8eb3e18b1b70cddebe5a819
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Mon Aug 16 23:24:07 2021 +0200

    Add ModelSource test for MNG-5669
---
 .../apache/maven/project/ProjectBuilderTest.java   | 26 ++++++++++++++++++++++
 .../resources/projects/modelsourcebasedir/pom.xml  | 19 ++++++++++++++++
 2 files changed, 45 insertions(+)

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 e2babbf..fbe1a4e 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
@@ -32,6 +32,7 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.building.FileModelSource;
 import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.model.building.ModelProblem;
 import org.apache.maven.model.building.ModelSource;
 import org.apache.maven.shared.utils.io.FileUtils;
 import org.junit.jupiter.api.Test;
@@ -332,4 +333,29 @@ public class ProjectBuilderTest
             assertNotNull( "Missing version for build plugin " + buildPlugin.getKey(), buildPlugin.getVersion() );
         }
     }
+
+    @Test
+    public void testBuildFromModelSourceResolvesBasedir()
+        throws Exception
+    {
+        File pomFile = new File( "src/test/resources/projects/modelsourcebasedir/pom.xml" );
+        MavenSession mavenSession = createMavenSession( null );
+        ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
+        configuration.setRepositorySession( mavenSession.getRepositorySession() );
+        ModelSource modelSource = new FileModelSource( pomFile );
+        ProjectBuildingResult result =
+            getContainer().lookup( org.apache.maven.project.ProjectBuilder.class ).build( modelSource, configuration );
+
+        assertEquals( pomFile.getAbsoluteFile(), result.getProject().getModel().getPomFile().getAbsoluteFile() );
+        int errors = 0;
+        for ( ModelProblem p : result.getProblems() )
+        {
+            if ( p.getSeverity() == ModelProblem.Severity.ERROR )
+            {
+                errors++;
+            }
+        }
+        assertEquals( 0, errors );
+    }
+
 }
diff --git a/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml b/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml
new file mode 100644
index 0000000..ec0f7d3
--- /dev/null
+++ b/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml
@@ -0,0 +1,19 @@
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test.readparent</groupId>
+  <artifactId>local-parent</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>blah</groupId>
+      <artifactId>blah</artifactId>
+      <version>0.0.1-SNASPSHOT</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/blah.jar</systemPath>
+    </dependency>
+  </dependencies>
+
+</project>