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 2020/06/30 13:46:35 UTC

[maven-surefire] branch surefire-1809 created (now 70f2e36)

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

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


      at 70f2e36  fixed the IF condition in findModuleDescriptor()

This branch includes the following new commits:

     new 70f2e36  fixed the IF condition in findModuleDescriptor()

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: fixed the IF condition in findModuleDescriptor()

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

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

commit 70f2e366667e3804d140ed7bd3943bc553ddf3b8
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Jun 30 15:46:27 2020 +0200

    fixed the IF condition in findModuleDescriptor()
---
 .../maven/plugin/surefire/AbstractSurefireMojo.java    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

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 38d34fb..64975b4 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
@@ -119,6 +119,7 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.zip.ZipFile;
 
 import static java.lang.Boolean.TRUE;
 import static java.lang.Integer.parseInt;
@@ -1397,7 +1398,10 @@ public abstract class AbstractSurefireMojo
 
     private ResolvePathResultWrapper findModuleDescriptor( File jdkHome, File buildPath, boolean isMainDescriptor )
     {
-        if ( buildPath.isDirectory() && !new File( buildPath, "module-info.class" ).exists() )
+        boolean isJpmsModule =
+            buildPath.isDirectory() ? new File( buildPath, "module-info.class" ).exists() : isModule( buildPath );
+
+        if ( !isJpmsModule )
         {
             return new ResolvePathResultWrapper( null, isMainDescriptor );
         }
@@ -1415,6 +1419,18 @@ public abstract class AbstractSurefireMojo
         }
     }
 
+    private static boolean isModule( File jar )
+    {
+        try ( ZipFile zip = new ZipFile( jar ) )
+        {
+            return zip.getEntry( "module-info.class" ) != null;
+        }
+        catch ( IOException e )
+        {
+            return false;
+        }
+    }
+
     private boolean canExecuteProviderWithModularPath( @Nonnull Platform platform,
                                                        @Nonnull ResolvePathResultWrapper resolvedJavaModularityResult )
     {