You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2018/11/17 10:19:34 UTC
[maven-surefire] branch SUREFIRE-1531 updated (c39b00b -> 01dd0ea)
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a change to branch SUREFIRE-1531
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.
discard c39b00b [SUREFIRE-1531] Option to disable Java 9 modules
new 01dd0ea [SUREFIRE-1531] Option to disable Java 9 modules
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (c39b00b)
\
N -- N -- N refs/heads/SUREFIRE-1531 (01dd0ea)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
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.
Summary of changes:
.../maven/plugin/failsafe/IntegrationTestMojo.java | 23 ++++++++
.../plugin/surefire/AbstractSurefireMojo.java | 65 +++++++++-------------
.../maven/plugin/surefire/SurefirePlugin.java | 23 ++++++++
3 files changed, 73 insertions(+), 38 deletions(-)
[maven-surefire] 01/01: [SUREFIRE-1531] Option to disable Java 9
modules
Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch SUREFIRE-1531
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 01dd0eac30dde407e0901a67bf550b436c7affe7
Author: Lukas Krecan <lu...@krecan.net>
AuthorDate: Sun Jul 1 08:54:22 2018 +0200
[SUREFIRE-1531] Option to disable Java 9 modules
---
.../maven/plugin/failsafe/IntegrationTestMojo.java | 23 ++++++++++
.../plugin/surefire/AbstractSurefireMojo.java | 53 +++++++++++++++-------
.../maven/plugin/surefire/SurefirePlugin.java | 23 ++++++++++
3 files changed, 83 insertions(+), 16 deletions(-)
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index 52f9052..42b4cc6 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -370,6 +370,17 @@ public class IntegrationTestMojo
@Parameter( property = "failsafe.shutdown", defaultValue = "testset" )
private String shutdown;
+ /**
+ * Disables Jigsaw (Java 9) modular path even if <i>module-info.java</i> is used in project.
+ * <br>
+ * Enabled by default.
+ * If enabled, <i>module-info.java</i> exists and executes with JDK 9+, modular path is used.
+ *
+ * @since 3.0.0-M2
+ */
+ @Parameter( property = "failsafe.useJigsawModules", defaultValue = "true" )
+ private boolean useJigsawModules;
+
@Override
protected int getRerunFailingTestsCount()
{
@@ -801,6 +812,18 @@ public class IntegrationTestMojo
}
@Override
+ protected boolean useJigsawModules()
+ {
+ return useJigsawModules;
+ }
+
+ @Override
+ protected void setUseJigsawModules( boolean useJigsawModules )
+ {
+ this.useJigsawModules = useJigsawModules;
+ }
+
+ @Override
protected final List<File> suiteXmlFiles()
{
return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : Collections.<File>emptyList();
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 319f21d..4a1a213 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
@@ -104,6 +104,7 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
+import static java.lang.Boolean.TRUE;
import static java.lang.Thread.currentThread;
import static java.util.Arrays.asList;
import static java.util.Collections.addAll;
@@ -728,6 +729,9 @@ public abstract class AbstractSurefireMojo
@Parameter( property = "dependenciesToScan" )
private String[] dependenciesToScan;
+ /**
+ *
+ */
@Component
private ToolchainManager toolchainManager;
@@ -787,6 +791,10 @@ public abstract class AbstractSurefireMojo
protected abstract String getReportSchemaLocation();
+ protected abstract boolean useJigsawModules();
+
+ protected abstract void setUseJigsawModules( boolean useJigsawModules );
+
/**
* This plugin MOJO artifact.
*
@@ -954,7 +962,7 @@ public abstract class AbstractSurefireMojo
if ( !getTestClassesDirectory().exists()
&& ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) )
{
- if ( Boolean.TRUE.equals( getFailIfNoTests() ) )
+ if ( TRUE.equals( getFailIfNoTests() ) )
{
throw new MojoFailureException( "No tests to run!" );
}
@@ -1123,17 +1131,18 @@ public abstract class AbstractSurefireMojo
RunOrderParameters runOrderParameters =
new RunOrderParameters( getRunOrder(), getStatisticsFile( getConfigChecksum() ) );
+ Platform platform = PLATFORM.withJdkExecAttributesForTests( getEffectiveJvm() );
if ( isNotForking() )
{
createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
InPluginVMSurefireStarter surefireStarter =
- createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters, scanResult );
+ createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters, scanResult, platform );
return surefireStarter.runSuitesInProcess( scanResult );
}
else
{
- ForkConfiguration forkConfiguration = getForkConfiguration();
+ ForkConfiguration forkConfiguration = createForkConfiguration( platform );
if ( getConsoleLogger().isDebugEnabled() )
{
showMap( getEnvironmentVariables(), "environment variable" );
@@ -1144,7 +1153,7 @@ public abstract class AbstractSurefireMojo
try
{
forkStarter = createForkStarter( provider, forkConfiguration, classLoaderConfiguration,
- runOrderParameters, getConsoleLogger(), scanResult );
+ runOrderParameters, getConsoleLogger(), scanResult, platform );
return forkStarter.run( effectiveProperties, scanResult );
}
@@ -1231,6 +1240,13 @@ public abstract class AbstractSurefireMojo
return new File( getClassesDirectory(), "module-info.class" );
}
+ private boolean canExecuteProviderWithJigsaw( Platform platform )
+ {
+ return useJigsawModules()
+ && platform.getJdkExecAttributesForTests().isJava9AtLeast()
+ && existsModuleDescriptor();
+ }
+
/**
* Converts old TestNG configuration parameters over to new properties based configuration
* method. (if any are defined the old way)
@@ -1683,18 +1699,18 @@ public abstract class AbstractSurefireMojo
private StartupConfiguration createStartupConfiguration( @Nonnull ProviderInfo provider, boolean isInprocess,
@Nonnull ClassLoaderConfiguration classLoaderConfiguration,
- @Nonnull DefaultScanResult scanResult )
+ @Nonnull DefaultScanResult scanResult,
+ @Nonnull Platform platform )
throws MojoExecutionException
{
try
{
- File moduleDescriptor = getModuleDescriptor();
Set<Artifact> providerArtifacts = provider.getProviderClasspath();
String providerName = provider.getProviderName();
- if ( moduleDescriptor.exists() && !isInprocess )
+ if ( canExecuteProviderWithJigsaw( platform ) && !isInprocess )
{
return newStartupConfigWithModularPath( classLoaderConfiguration, providerArtifacts, providerName,
- moduleDescriptor, scanResult );
+ getModuleDescriptor(), scanResult );
}
else
{
@@ -2107,11 +2123,11 @@ public abstract class AbstractSurefireMojo
private ForkStarter createForkStarter( @Nonnull ProviderInfo provider, @Nonnull ForkConfiguration forkConfiguration,
@Nonnull ClassLoaderConfiguration classLoaderConfiguration,
@Nonnull RunOrderParameters runOrderParameters, @Nonnull ConsoleLogger log,
- @Nonnull DefaultScanResult scanResult )
+ @Nonnull DefaultScanResult scanResult, @Nonnull Platform platform )
throws MojoExecutionException, MojoFailureException
{
StartupConfiguration startupConfiguration =
- createStartupConfiguration( provider, false, classLoaderConfiguration, scanResult );
+ createStartupConfiguration( provider, false, classLoaderConfiguration, scanResult, platform );
String configChecksum = getConfigChecksum();
StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum, true );
ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters );
@@ -2122,11 +2138,12 @@ public abstract class AbstractSurefireMojo
private InPluginVMSurefireStarter createInprocessStarter( @Nonnull ProviderInfo provider,
@Nonnull ClassLoaderConfiguration classLoaderConfig,
@Nonnull RunOrderParameters runOrderParameters,
- @Nonnull DefaultScanResult scanResult )
+ @Nonnull DefaultScanResult scanResult,
+ @Nonnull Platform platform )
throws MojoExecutionException, MojoFailureException
{
StartupConfiguration startupConfiguration =
- createStartupConfiguration( provider, true, classLoaderConfig, scanResult );
+ createStartupConfiguration( provider, true, classLoaderConfig, scanResult, platform );
String configChecksum = getConfigChecksum();
StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum, false );
ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters );
@@ -2135,7 +2152,7 @@ public abstract class AbstractSurefireMojo
}
@Nonnull
- private ForkConfiguration getForkConfiguration() throws MojoFailureException
+ private ForkConfiguration createForkConfiguration( Platform platform )
{
File tmpDir = getSurefireTempDir();
@@ -2143,9 +2160,7 @@ public abstract class AbstractSurefireMojo
Classpath bootClasspath = getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact );
- Platform platform = PLATFORM.withJdkExecAttributesForTests( getEffectiveJvm() );
-
- if ( platform.getJdkExecAttributesForTests().isJava9AtLeast() && existsModuleDescriptor() )
+ if ( canExecuteProviderWithJigsaw( platform ) )
{
return new ModularClasspathForkConfiguration( bootClasspath,
tmpDir,
@@ -2414,6 +2429,7 @@ public abstract class AbstractSurefireMojo
checksum.add( getForkedProcessExitTimeoutInSeconds() );
checksum.add( getRerunFailingTestsCount() );
checksum.add( getTempDir() );
+ checksum.add( useJigsawModules() );
addPluginSpecificChecksumItems( checksum );
return checksum.getSha1();
}
@@ -3479,6 +3495,11 @@ public abstract class AbstractSurefireMojo
this.dependenciesToScan = dependenciesToScan;
}
+ public PluginDescriptor getPluginDescriptor()
+ {
+ return pluginDescriptor;
+ }
+
public MavenProject getProject()
{
return project;
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 73ea01e..7fbbe20 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -349,6 +349,17 @@ public class SurefirePlugin
@Parameter( property = "surefire.shutdown", defaultValue = "testset" )
private String shutdown;
+ /**
+ * Disables Jigsaw (Java 9) modular path even if <i>module-info.java</i> is used in project.
+ * <br>
+ * Enabled by default.
+ * If enabled, <i>module-info.java</i> exists and executes with JDK 9+, modular path is used.
+ *
+ * @since 3.0.0-M2
+ */
+ @Parameter( property = "surefire.useJigsawModules", defaultValue = "true" )
+ private boolean useJigsawModules;
+
@Override
protected int getRerunFailingTestsCount()
{
@@ -703,6 +714,18 @@ public class SurefirePlugin
}
@Override
+ protected boolean useJigsawModules()
+ {
+ return useJigsawModules;
+ }
+
+ @Override
+ protected void setUseJigsawModules( boolean useJigsawModules )
+ {
+ this.useJigsawModules = useJigsawModules;
+ }
+
+ @Override
protected final List<File> suiteXmlFiles()
{
return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : Collections.<File>emptyList();