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/12/01 23:27:27 UTC

[maven-surefire] branch SUREFIRE-1605 created (now 9ea56f0)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch SUREFIRE-1605
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at 9ea56f0  [SUREFIRE-1605] NoClassDefFoundError (RunNotifier) with JDK 11

This branch includes the following new commits:

     new 9ea56f0  [SUREFIRE-1605] NoClassDefFoundError (RunNotifier) with JDK 11

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.



[maven-surefire] 01/01: [SUREFIRE-1605] NoClassDefFoundError (RunNotifier) with JDK 11

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-1605
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 9ea56f0847d572cacfb828dc70b090892ca82eee
Author: Tibor17 <ti...@apache.org>
AuthorDate: Sun Dec 2 00:27:12 2018 +0100

    [SUREFIRE-1605] NoClassDefFoundError (RunNotifier) with JDK 11
---
 .../maven/plugin/surefire/AbstractSurefireMojo.java | 21 +++++++++++++++++++--
 .../surefire/AbstractSurefireMojoJava7PlusTest.java |  4 +++-
 pom.xml                                             |  2 +-
 3 files changed, 23 insertions(+), 4 deletions(-)

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 b6ae1bb..6f973b8 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
@@ -89,6 +89,7 @@ import java.io.File;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -1709,8 +1710,16 @@ public abstract class AbstractSurefireMojo
             String providerName = provider.getProviderName();
             if ( canExecuteProviderWithModularPath( platform ) && !isInprocess )
             {
+                String jvmExecutable = platform.getJdkExecAttributesForTests().getJvmExecutable();
+                String javaHome = Paths.get( jvmExecutable )
+                        .toAbsolutePath()
+                        .normalize()
+                        .getParent()
+                        .getParent()
+                        .toString();
+
                 return newStartupConfigWithModularPath( classLoaderConfiguration, providerArtifacts, providerName,
-                        getModuleDescriptor(), scanResult );
+                        getModuleDescriptor(), scanResult, javaHome );
             }
             else
             {
@@ -1801,7 +1810,8 @@ public abstract class AbstractSurefireMojo
 
     private StartupConfiguration newStartupConfigWithModularPath(
             @Nonnull ClassLoaderConfiguration classLoaderConfiguration, @Nonnull Set<Artifact> providerArtifacts,
-            @Nonnull String providerName, @Nonnull File moduleDescriptor, @Nonnull DefaultScanResult scanResult )
+            @Nonnull String providerName, @Nonnull File moduleDescriptor, @Nonnull DefaultScanResult scanResult,
+            @Nonnull String javaHome )
             throws IOException
     {
         TestClassPath testClasspathWrapper = generateTestClasspath();
@@ -1816,9 +1826,16 @@ public abstract class AbstractSurefireMojo
         }
 
         ResolvePathsRequest<String> req = ResolvePathsRequest.ofStrings( testClasspath.getClassPath() )
+                .setJdkHome( javaHome )
                 .setMainModuleDescriptor( moduleDescriptor.getAbsolutePath() );
 
         ResolvePathsResult<String> result = getLocationManager().resolvePaths( req );
+        for ( Entry<String, Exception> entry : result.getPathExceptions().entrySet() )
+        {
+            getConsoleLogger()
+                    .warning( "Exception for '" + entry.getKey() + "' (probably JDK version < 9).",
+                            entry.getValue() );
+        }
 
         testClasspath = new Classpath( result.getClasspathElements() );
         Classpath testModulepath = new Classpath( result.getModulepathElements().keySet() );
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 6903995..c60faca 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
@@ -135,6 +135,7 @@ public class AbstractSurefireMojoJava7PlusTest
         ResolvePathsRequest<String> req = mock( ResolvePathsRequest.class );
         mockStatic( ResolvePathsRequest.class );
         when( ResolvePathsRequest.ofStrings( eq( testClasspath.toClasspath().getClassPath() ) ) ).thenReturn( req );
+        when( req.setJdkHome( anyString() ) ).thenReturn( req );
         when( req.setMainModuleDescriptor( eq( moduleInfo.getAbsolutePath() ) ) ).thenReturn( req );
 
         @SuppressWarnings( "unchecked" )
@@ -152,7 +153,8 @@ public class AbstractSurefireMojoJava7PlusTest
         when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
 
         StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigWithModularPath",
-                classLoaderConfiguration, providerClasspath, "org.asf.Provider", moduleInfo, scanResult );
+                classLoaderConfiguration, providerClasspath, "org.asf.Provider", moduleInfo, scanResult,
+                "" );
 
         verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
         verify( mojo, times( 1 ) ).isChildDelegation();
diff --git a/pom.xml b/pom.xml
index 09bce00..7aed0f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -239,7 +239,7 @@
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-java</artifactId>
-        <version>0.9.11</version>
+        <version>1.0.1</version>
       </dependency>
       <dependency>
         <groupId>org.junit.platform</groupId>