From dev-return-127061-archive-asf-public=cust-asf.ponee.io@maven.apache.org Sat Nov 17 13:00:08 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1058F180676 for ; Sat, 17 Nov 2018 13:00:07 +0100 (CET) Received: (qmail 83931 invoked by uid 500); 17 Nov 2018 12:00:06 -0000 Mailing-List: contact dev-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Developers List" Reply-To: "Maven Developers List" Delivered-To: mailing list dev@maven.apache.org Received: (qmail 83907 invoked by uid 99); 17 Nov 2018 12:00:06 -0000 Received: from mail-relay.apache.org (HELO mailrelay2-lw-us.apache.org) (207.244.88.137) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2018 12:00:06 +0000 Received: from desktop-2khsk44 (5ED6B990.cm-7-7c.dynamic.ziggo.nl [94.214.185.144]) by mailrelay2-lw-us.apache.org (ASF Mail Server at mailrelay2-lw-us.apache.org) with ESMTPSA id 1D2212E29; Sat, 17 Nov 2018 12:00:04 +0000 (UTC) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "commits@maven.apache.org" , tibordigana@apache.org, dev@maven.apache.org Subject: Re: [maven-surefire] 01/01: [SUREFIRE-1531] Option to disable Java 9 modules References: <154245088248.27977.13283779848284286537@gitbox.apache.org> <20181117103442.91C25850D1@gitbox.apache.org> Date: Sat, 17 Nov 2018 13:00:10 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Robert Scholte" Organization: Apache Software Foundation Message-ID: In-Reply-To: <20181117103442.91C25850D1@gitbox.apache.org> User-Agent: Opera Mail/12.18 (Win64) On Sat, 17 Nov 2018 11:34:43 +0100, wrote: > 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 f333b7d9e89ddfe086fd1cb930df0f77a0edbc96 > Author: Lukas Krecan > 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 > +++++++++++++++------- > .../AbstractSurefireMojoJava7PlusTest.java | 12 +++++ > .../plugin/surefire/AbstractSurefireMojoTest.java | 12 +++++ > .../maven/plugin/surefire/MojoMocklessTest.java | 12 +++++ > .../maven/plugin/surefire/SurefirePlugin.java | 23 ++++++++++ > 6 files changed, 119 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 > module-info.java is used in project. > + *
> + * Enabled by default. > + * If enabled, module-info.java exists and executes with JDK > 9+, modular path is used. > + * > + * @since 3.0.0-M2 > + */ > + @Parameter( property = "failsafe.useJigsawModules", defaultValue = > "true" ) > + private boolean useJigsawModules; > + I think we should avoid referring to Jigsaw, that was the name of the project. I'd prefer useJavaModules instead, or maybe even useModulePath. > @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 suiteXmlFiles() > { > return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : > Collections.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 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-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java > index f73124a..b3dc339 100644 > --- > a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java > +++ > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java > @@ -560,6 +560,18 @@ public class AbstractSurefireMojoJava7PlusTest > } > @Override > + protected boolean useJigsawModules() > + { > + return false; > + } > + > + @Override > + protected void setUseJigsawModules( boolean useJigsawModules ) > + { > + > + } > + > + @Override > protected Artifact getMojoArtifact() > { > return null; > diff --git > a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java > index de62c60..8514269 100644 > --- > a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java > +++ > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java > @@ -705,6 +705,18 @@ public class AbstractSurefireMojoTest > } > @Override > + protected boolean useJigsawModules() > + { > + return false; > + } > + > + @Override > + protected void setUseJigsawModules( boolean useJigsawModules ) > + { > + > + } > + > + @Override > protected Artifact getMojoArtifact() > { > return null; > diff --git > a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java > index 597527b..e555b00 100644 > --- > a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java > +++ > b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java > @@ -612,6 +612,18 @@ public class MojoMocklessTest > } > @Override > + protected boolean useJigsawModules() > + { > + return false; > + } > + > + @Override > + protected void setUseJigsawModules( boolean useJigsawModules ) > + { > + > + } > + > + @Override > protected Artifact getMojoArtifact() > { > return null; > 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 > module-info.java is used in project. > + *
> + * Enabled by default. > + * If enabled, module-info.java 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 suiteXmlFiles() > { > return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : > Collections.emptyList(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org