From 383cabf9e4992eeff36c9b5731d95bafa72398d3 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 16 Aug 2021 18:08:39 +0200 Subject: [PATCH] [MNG-7216] [Regression] Revert MNG-7170 This reverts commit 5a8997312680a4b9c69a129801524691bc546c08. This closes #524 --- .../maven/project/ProjectBuilderTest.java | 26 ------------------- .../projects/modelsourcebasedir/pom.xml | 19 -------------- .../model/building/DefaultModelBuilder.java | 9 +------ 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml 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 37d51cd49d..6adb10e8f4 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 @@ -39,8 +39,6 @@ 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.ModelProblem.Severity; import org.apache.maven.model.building.ModelSource; import org.apache.maven.shared.utils.io.FileUtils; @@ -85,30 +83,6 @@ public class ProjectBuilderTest assertNotNull( result.getProject().getParentFile() ); } - 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() == Severity.ERROR ) - { - errors++; - } - } - assertEquals( 0, errors ); - } - - public void testVersionlessManagedDependency() throws Exception { diff --git a/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml b/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml deleted file mode 100644 index ec0f7d385a..0000000000 --- a/maven-core/src/test/resources/projects/modelsourcebasedir/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - 4.0.0 - test.readparent - local-parent - pom - 1.0 - - - - blah - blah - 0.0.1-SNASPSHOT - system - ${basedir}/blah.jar - - - - diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index a089f9d991..70c9ed529c 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -624,14 +624,7 @@ public class DefaultModelBuilder throw problems.newModelBuildingException(); } - if ( pomFile != null ) - { - model.setPomFile( pomFile ); - } - else if ( modelSource instanceof FileModelSource ) - { - model.setPomFile( ( (FileModelSource) modelSource ).getFile() ); - } + model.setPomFile( pomFile ); problems.setSource( model ); modelValidator.validateRawModel( model, request, problems );