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 2020/01/09 20:45:38 UTC
[maven] 01/01: [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 MNG-6842
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 5670dfa909921b94fa987c23d6e15004071a2373
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 4833b00..da43088 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;
@@ -39,7 +41,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
@@ -142,19 +143,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>" );
@@ -173,7 +175,7 @@ public class ProjectBuilderTest
{
System.setProperty( DefaultProjectBuilder.DISABLE_GLOBAL_MODEL_CACHE_SYSTEM_PROPERTY, initialValue );
}
- FileUtils.deleteDirectory( tempDir );
+ FileUtils.deleteDirectory( tempDir.toFile() );
}
}
@@ -303,7 +305,7 @@ public class ProjectBuilderTest
return null;
}
- private void assertResultShowNoError(List<ProjectBuildingResult> results)
+ private void assertResultShowNoError( List<ProjectBuildingResult> results )
{
for ( ProjectBuildingResult result : results )
{
@@ -320,8 +322,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() );