You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2020/10/07 14:39:21 UTC

[GitHub] [maven-ear-plugin] elharo commented on a change in pull request #19: [MEAR-267] - Fixed detection if JAR module is included into classpath of particular EAR module manifest

elharo commented on a change in pull request #19:
URL: https://github.com/apache/maven-ear-plugin/pull/19#discussion_r501064051



##########
File path: src/main/java/org/apache/maven/plugins/ear/EarMojo.java
##########
@@ -946,4 +946,31 @@ private void deleteOutdatedResources( final Collection<String> outdatedResources
             }
         }
     }
+
+    /**
+     * Searches JAR module in the list of classpath elements.

Review comment:
       searches the JAR module or searches for a JAR module? 

##########
File path: src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
##########
@@ -119,61 +128,72 @@ protected File executeMojo( final String projectName, final Properties propertie
     protected File executeMojo( final String projectName, final Properties properties )
         throws VerificationException, IOException
     {
-        return executeMojo( projectName, properties, true );
+        return executeMojo( projectName, properties, true, true );
     }
 
     /**
-     * Executes the specified projects and asserts the given artifacts. Assert the deployment descriptors are valid
-     * 
+     * Executes the specified projects and asserts the given artifacts. Asserts the deployment descriptors are valid.
+     * Asserts Class-Path entry of manifest of EAR modules.
+     *
      * @param projectName the project to test
+     * @param earModuleName the name of 1st level EAR module in multi-module project or null if project is single-module
      * @param expectedArtifacts the list of artifacts to be found in the EAR archive
      * @param artifactsDirectory whether the artifact is an exploded artifactsDirectory or not
+     * @param moduleArtifacts the list of artifacts representing EAR modules which manifest needs to be asserted or
+     *                        {@code null} if there is no need to validate Class-Path entry of EAR modules manifests
+     * @param moduleArtifactsDirectory whether the artifact from {@code moduleArtifacts} list is an exploded or not.
+     *                                 Can be {@code null} if {@code moduleArtifacts} is {@code null}
+     * @param expectedClassPathElements the list of elements of Class-Path entry of manifest. Rows should match
+     *                                  modules passed in {@code moduleArtifacts} parameter. Can be {@code null} if
+     *                                  {@code moduleArtifacts} is {@code null}
+     * @param cleanBeforeExecute call clean plugin before execution
      * @return the base directory of the project
      */
-    protected File doTestProject( final String projectName, final String[] expectedArtifacts,
-                                  final boolean[] artifactsDirectory )
+    protected File doTestProject( final String projectName, final String earModuleName,
+                                  final String[] expectedArtifacts, boolean[] artifactsDirectory,
+                                  final String[] moduleArtifacts, boolean[] moduleArtifactsDirectory,
+                                  final String[][] expectedClassPathElements,
+                                  final boolean cleanBeforeExecute )
         throws VerificationException, IOException
     {
-        final File baseDir = executeMojo( projectName, new Properties() );
-        assertEarArchive( baseDir, projectName );
-        assertEarDirectory( baseDir, projectName );
-        
-        assertArchiveContent( baseDir, projectName, expectedArtifacts, artifactsDirectory );
-        
-        assertDeploymentDescriptors( baseDir, projectName );
-        
-        return baseDir;
+        final File baseDir = executeMojo( projectName, new Properties(), true, cleanBeforeExecute );
+
+        final File earModuleDir = getEarModuleDirectory( baseDir, earModuleName );
+        assertEarArchive( earModuleDir, projectName );
+        assertEarDirectory( earModuleDir, projectName );
+        assertArchiveContent( earModuleDir, projectName, expectedArtifacts, artifactsDirectory );
+        assertDeploymentDescriptors( earModuleDir, projectName );
+        assertClassPathElements( earModuleDir, projectName, moduleArtifacts, moduleArtifactsDirectory, expectedClassPathElements );
 
+        return baseDir;
     }
 
     /**
-     * Executes the specified projects and asserts the given artifacts as artifacts (non directory)
-     * 
+     * Executes the specified projects and asserts the given artifacts. Assert the deployment descriptors are valid

Review comment:
       period at end

##########
File path: src/main/java/org/apache/maven/plugins/ear/EarMojo.java
##########
@@ -946,4 +946,31 @@ private void deleteOutdatedResources( final Collection<String> outdatedResources
             }
         }
     }
+
+    /**
+     * Searches JAR module in the list of classpath elements.
+     *
+     * @param classPathElements classpath elements to search among.
+     * @param module module to find among classpath elements defined by {@code classPathElements}
+     * @return -1 if {@code module} was not found in {@code classPathElements} or index of item of
+     * {@code classPathElements} which matches {@code module}
+     */
+    private int findModuleInClassPathElements( final List<String> classPathElements, final JarModule module )
+    {
+        if ( classPathElements.isEmpty() )
+        {
+            return -1;
+        }
+        int moduleClassPathIndex = classPathElements.indexOf( module.getBundleFileName() );
+        if ( moduleClassPathIndex != -1 )
+        {
+            return moduleClassPathIndex;
+        }
+        return classPathElements.indexOf( getArtifactFileName( module ) );
+    }
+
+    private String getArtifactFileName( final EarModule module )

Review comment:
       inline this

##########
File path: src/main/java/org/apache/maven/plugins/ear/EarMojo.java
##########
@@ -946,4 +946,31 @@ private void deleteOutdatedResources( final Collection<String> outdatedResources
             }
         }
     }
+
+    /**
+     * Searches JAR module in the list of classpath elements.
+     *
+     * @param classPathElements classpath elements to search among.

Review comment:
       no period since not a complete sentence

##########
File path: src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
##########
@@ -119,61 +128,72 @@ protected File executeMojo( final String projectName, final Properties propertie
     protected File executeMojo( final String projectName, final Properties properties )
         throws VerificationException, IOException
     {
-        return executeMojo( projectName, properties, true );
+        return executeMojo( projectName, properties, true, true );
     }
 
     /**
-     * Executes the specified projects and asserts the given artifacts. Assert the deployment descriptors are valid
-     * 
+     * Executes the specified projects and asserts the given artifacts. Asserts the deployment descriptors are valid.
+     * Asserts Class-Path entry of manifest of EAR modules.
+     *
      * @param projectName the project to test
+     * @param earModuleName the name of 1st level EAR module in multi-module project or null if project is single-module
      * @param expectedArtifacts the list of artifacts to be found in the EAR archive
      * @param artifactsDirectory whether the artifact is an exploded artifactsDirectory or not
+     * @param moduleArtifacts the list of artifacts representing EAR modules which manifest needs to be asserted or

Review comment:
       I don't follow. Can you rephrase?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org