Hi Robert,
Sorry I have not seen your email before.
" useModulePath " sounds good. I will rename the property if no objections.

BR
Tibor

On Sat, Nov 17, 2018 at 1:00 PM Robert Scholte <rfscho...@apache.org> wrote:

> On Sat, 17 Nov 2018 11:34:43 +0100, <tibordig...@apache.org> 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 <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
> > +++++++++++++++-------
> >  .../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
> > <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;
> > +
>
>
> 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<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-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
> > <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();
>

Reply via email to