You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2017/09/06 20:47:04 UTC
maven-surefire git commit: SUREFIRE-1262: extract
testClassesDirectory and test packages for ForkConfiguration with modulepath
Repository: maven-surefire
Updated Branches:
refs/heads/SUREFIRE-1262 bac0fb56a -> 569a9b7a8
SUREFIRE-1262: extract testClassesDirectory and test packages for ForkConfiguration with modulepath
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/569a9b7a
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/569a9b7a
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/569a9b7a
Branch: refs/heads/SUREFIRE-1262
Commit: 569a9b7a8d9c1d9102037ac1f233fcc8378e6d9e
Parents: bac0fb5
Author: rfscholte <rf...@apache.org>
Authored: Wed Sep 6 22:46:55 2017 +0200
Committer: rfscholte <rf...@apache.org>
Committed: Wed Sep 6 22:46:55 2017 +0200
----------------------------------------------------------------------
maven-surefire-common/pom.xml | 2 +-
.../maven/plugin/surefire/AbstractSurefireMojo.java | 16 ++++++++++++----
.../surefire/booterclient/ForkConfiguration.java | 12 +++++++-----
.../booterclient/ForkConfigurationTest.java | 10 +++++-----
pom.xml | 4 ++--
.../surefire/booter/ClasspathConfiguration.java | 12 ++++++++++--
6 files changed, 37 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/maven-surefire-common/pom.xml
----------------------------------------------------------------------
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 35a1055..5d06323 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -92,7 +92,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-java</artifactId>
- <version>0.9.3-SNAPSHOT</version>
+ <version>0.9.3</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index abf6bb5..be7dc62 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -21,7 +21,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -32,10 +31,13 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
+import org.apache.commons.lang3.StringUtils;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -1683,12 +1685,18 @@ public abstract class AbstractSurefireMojo
Classpath testClasspath = new Classpath( result.getClasspathElements() );
Classpath testModulepath = new Classpath( result.getModulepathElements().keySet() );
- Collection<String> packages = null;
+ Set<String> packages = new TreeSet<>();
+
+ for ( Object file : scanResult.getFiles() )
+ {
+ String className = (String) file;
+ packages.add( StringUtils.substringBeforeLast( className, "." ) );
+ }
classpathConfiguration =
new ClasspathConfiguration( testClasspath, testModulepath, providerClasspath, inprocClassPath,
- moduleDescriptor, packages, effectiveIsEnableAssertions(),
- isChildDelegation() );
+ moduleDescriptor, packages, getTestClassesDirectory(),
+ effectiveIsEnableAssertions(), isChildDelegation() );
getConsoleLogger().debug( testClasspath.getLogMessage( "test-classpath" ) );
getConsoleLogger().debug( testModulepath.getLogMessage( "test-modulepath" ) );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 419c771..8e614df 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -157,6 +157,7 @@ public class ForkConfiguration
testModulePath != null ? testModulePath.getClassPath() : null,
startupConfiguration.getClasspathConfiguration().getModuleDescriptor(),
startupConfiguration.getClasspathConfiguration().getPackages(),
+ startupConfiguration.getClasspathConfiguration().getPatchFile(),
startupConfiguration.getClassLoaderConfiguration().isManifestOnlyJarRequestedAndUsable(),
startupConfiguration.isShadefire(),
startupConfiguration.isProviderMainClass() ? startupConfiguration.getActualClassName()
@@ -165,7 +166,7 @@ public class ForkConfiguration
OutputStreamFlushableCommandline createCommandLine( List<String> classPath, List<String> modulePath,
File moduleDescriptor, Collection<String> packages,
- boolean useJar, boolean shadefire,
+ File patchFile, boolean useJar, boolean shadefire,
String providerThatHasMainMethod, int threadNumber )
throws SurefireBooterForkException
{
@@ -196,7 +197,8 @@ public class ForkConfiguration
try
{
File argsFile =
- createArgsFile( moduleDescriptor, modulePath, classPath, packages, providerThatHasMainMethod );
+ createArgsFile( moduleDescriptor, modulePath, classPath, packages, patchFile,
+ providerThatHasMainMethod );
cli.createArg().setValue( "@" + escapeToPlatformPath( argsFile.getAbsolutePath() ) );
}
@@ -346,7 +348,7 @@ public class ForkConfiguration
}
private File createArgsFile( File moduleDescriptor, List<String> modulePath, List<String> classPath,
- Collection<String> packages, String startClassName )
+ Collection<String> packages, File patchFile, String startClassName )
throws IOException
{
File file = File.createTempFile( "surefireargs", "", tempDirectory );
@@ -390,10 +392,10 @@ public class ForkConfiguration
writer.write( "--patch-module" );
writer.newLine();
- writer.append( moduleName ).append( '=' ).append( "target/test-classes" );
+ writer.append( moduleName ).append( '=' ).append( patchFile.getPath() );
writer.newLine();
- for ( String pckg : Collections.singletonList( "com.app" ) )
+ for ( String pckg : packages )
{
writer.write( "--add-exports" );
writer.newLine();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
index de1f012..20c5ba5 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
@@ -45,7 +45,7 @@ public class ForkConfigurationTest
File cpElement = getTempClasspathFile();
Commandline cli =
- config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), null, null, null, true, false, null, 1 );
+ config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), null, null, null, null, true, false, null, 1 );
String line = StringUtils.join( cli.getCommandline(), " " );
assertTrue( line.contains( "-jar" ) );
@@ -59,7 +59,7 @@ public class ForkConfigurationTest
ForkConfiguration forkConfiguration = getForkConfiguration( "abc\ndef", null );
final Commandline commandLine =
- forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), null, null, null, false, false,
+ forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), null, null, null, null, false, false,
null, 1 );
assertTrue( commandLine.toString().contains( "abc def" ) );
}
@@ -76,7 +76,7 @@ public class ForkConfigurationTest
File cwd = new File( baseDir, "fork_${surefire.forkNumber}" );
ForkConfiguration config = getForkConfiguration( null, "java", cwd.getCanonicalFile() );
- Commandline commandLine = config.createCommandLine( Collections.<String>emptyList(), null, null, null, true, false, null, 1 );
+ Commandline commandLine = config.createCommandLine( Collections.<String>emptyList(), null, null, null, null, true, false, null, 1 );
File forkDirectory = new File( baseDir, "fork_1" );
forkDirectory.deleteOnExit();
@@ -101,7 +101,7 @@ public class ForkConfigurationTest
try
{
- config.createCommandLine( Collections.<String>emptyList(), null, null, null, true, false, null, 1 );
+ config.createCommandLine( Collections.<String>emptyList(), null, null, null, null, true, false, null, 1 );
}
catch ( SurefireBooterForkException sbfe )
{
@@ -130,7 +130,7 @@ public class ForkConfigurationTest
try
{
- config.createCommandLine( Collections.<String>emptyList(), null, null, null, true, false, null, 1 );
+ config.createCommandLine( Collections.<String>emptyList(), null, null, null, null, true, false, null, 1 );
}
catch ( SurefireBooterForkException sbfe )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 567e763..7c1dba8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -364,8 +364,8 @@
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
- <artifactId>java16</artifactId>
- <version>1.1</version>
+ <artifactId>java17</artifactId>
+ <version>1.0</version>
</signature>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/569a9b7a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
index 74c76b3..4f61539 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
@@ -49,6 +49,8 @@ public class ClasspathConfiguration
private final File moduleDescriptor;
private final Collection<String> packages;
+
+ private final File patchFile;
/**
* The surefire classpath to use when invoking in-process with the plugin
@@ -88,12 +90,12 @@ public class ClasspathConfiguration
this.moduleDescriptor = null;
this.modulepathUrls = null;
this.packages = null;
+ this.patchFile = null;
}
public ClasspathConfiguration( Classpath testClasspath, Classpath testModulepath, Classpath surefireClassPathUrls,
Classpath inprocClasspath, File moduleDescriptor, Collection<String> packages,
- boolean enableAssertions,
- boolean childDelegation )
+ File patchFile, boolean enableAssertions, boolean childDelegation )
{
this.enableAssertions = enableAssertions;
this.childDelegation = childDelegation;
@@ -103,6 +105,7 @@ public class ClasspathConfiguration
this.surefireClasspathUrls = surefireClassPathUrls;
this.moduleDescriptor = moduleDescriptor;
this.packages = packages;
+ this.patchFile = patchFile;
}
public ClassLoader createMergedClassLoader()
@@ -153,4 +156,9 @@ public class ClasspathConfiguration
{
return packages;
}
+
+ public File getPatchFile()
+ {
+ return patchFile;
+ }
}