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/06/26 20:33:52 UTC

[maven] branch maven-3.8.x updated: [MNG-6842] ProjectBuilderTest uses Guava, but Guava is not defined in dependencies

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

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


The following commit(s) were added to refs/heads/maven-3.8.x by this push:
     new 863f919  [MNG-6842] ProjectBuilderTest uses Guava, but Guava is not defined in dependencies
863f919 is described below

commit 863f9193e615f474cce402535948002138af4dae
Author: Artem Krosheninnikov <fe...@gmail.com>
AuthorDate: Mon Jan 6 17:28:39 2020 +0300

    [MNG-6842] ProjectBuilderTest uses Guava, but Guava is not defined in dependencies
    
    This closes #311
---
 .../org/apache/maven/project/ProjectBuilderTest.java | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

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 644f6d1..a318821 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
@@ -26,6 +26,8 @@ import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
 import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -40,7 +42,6 @@ import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelSource;
 import org.apache.maven.shared.utils.io.FileUtils;
 
-import com.google.common.io.Files;
 
 public class ProjectBuilderTest
     extends AbstractCoreMavenComponentTestCase
@@ -143,19 +144,20 @@ public class ProjectBuilderTest
         String initialValue = System.setProperty( DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, Boolean.toString( true ) );
         // TODO a similar test should be created to test the dependency management (basically all usages
         // of DefaultModelBuilder.getCache() are affected by MNG-6530
-        File tempDir = Files.createTempDir();
-        FileUtils.copyDirectoryStructure (new File( "src/test/resources/projects/grandchild-check"), tempDir );
+
+        Path tempDir = Files.createTempDirectory( null );
+        FileUtils.copyDirectoryStructure ( new File( "src/test/resources/projects/grandchild-check" ), tempDir.toFile() );
         try
         {
             MavenSession mavenSession = createMavenSession( null );
             ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
             configuration.setRepositorySession( mavenSession.getRepositorySession() );
             org.apache.maven.project.ProjectBuilder projectBuilder = lookup( org.apache.maven.project.ProjectBuilder.class );
-            File child = new File( tempDir, "child/pom.xml" );
+            File child = new File( tempDir.toFile(), "child/pom.xml" );
             // build project once
             projectBuilder.build( child, configuration );
             // modify parent
-            File parent = new File( tempDir, "pom.xml" );
+            File parent = new File( tempDir.toFile(), "pom.xml" );
             String parentContent = FileUtils.fileRead( parent );
             parentContent = parentContent.replaceAll( "<packaging>pom</packaging>",
             		"<packaging>pom</packaging><properties><addedProperty>addedValue</addedProperty></properties>" );
@@ -174,7 +176,7 @@ public class ProjectBuilderTest
             {
                 System.setProperty( DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, initialValue );
             }
-            FileUtils.deleteDirectory( tempDir );
+            FileUtils.deleteDirectory( tempDir.toFile() );
         }
     }
 
@@ -304,7 +306,7 @@ public class ProjectBuilderTest
         return null;
     }
 
-    private void assertResultShowNoError(List<ProjectBuildingResult> results)
+    private void assertResultShowNoError( List<ProjectBuildingResult> results )
     {
         for ( ProjectBuildingResult result : results )
         {
@@ -321,8 +323,8 @@ public class ProjectBuilderTest
         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();
+        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() );