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

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 056f75e  [MEAR-287] Fixed failure when destination directory exists 
(#17)
056f75e is described below

commit 056f75ec9df83a37800ababd93368317c25aa185
Author: Mikhail Gavrilov <mjgavri...@gmail.com>
AuthorDate: Mon Oct 12 15:58:33 2020 +0300

    [MEAR-287] Fixed failure when destination directory exists (#17)
    
    * Fixed failure when destination directory exists
    
    * MEAR-287: do not fail if directory already exists
    
    * [MEAR-287] - Integration test for building the same EAR when results of 
previous build exist in target location
    
    * [MEAR-287] - Refactoring of logging when modifying manifest of EAR modules
    
    * [MEAR-287] - Removed meaningless JavaDoc @throws part from integration 
tests
    
    Co-authored-by: Mikhail Gavrilov <mikhail.gavri...@aciworldwide.com>
    Co-authored-by: Marat Abrarov <abra...@gmail.com>
---
 pom.xml                                            |   3 +-
 .../java/org/apache/maven/plugins/ear/EarMojo.java |  26 ++---
 .../maven/plugins/ear/it/AbstractEarPluginIT.java  |  46 ++++++---
 .../org/apache/maven/plugins/ear/it/EarMojoIT.java | 113 ++++-----------------
 .../ear/expected-META-INF/application.xml          |  32 ++++++
 .../resources/projects/project-088/ear/pom.xml     |  62 +++++++++++
 src/test/resources/projects/project-088/pom.xml    |  64 ++++++++++++
 .../resources/projects/project-088/war/pom.xml     |  39 +++++++
 .../war/src/main/webapp/WEB-INF/web.xml            |  24 +++++
 9 files changed, 290 insertions(+), 119 deletions(-)

diff --git a/pom.xml b/pom.xml
index 372c0b5..aae6f4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,7 @@
     <javaVersion>7</javaVersion>
     <surefire.version>2.22.2</surefire.version>
     
<project.build.outputTimestamp>2020-09-26T20:10:30Z</project.build.outputTimestamp>
+    <mavenWarPluginVersion>2.1.1</mavenWarPluginVersion>
     <invoker.skip>false</invoker.skip>
     <invoker.install.skip>${invoker.skip}</invoker.install.skip>
     <invoker.it.skip>${invoker.skip}</invoker.it.skip>
@@ -280,7 +281,7 @@
                 <goal>package</goal>
               </goals>
               <extraArtifacts>
-                
<extraArtifact>org.apache.maven.plugins:maven-war-plugin:2.1.1:jar</extraArtifact>
+                
<extraArtifact>org.apache.maven.plugins:maven-war-plugin:${mavenWarPluginVersion}:jar</extraArtifact>
                 
<extraArtifact>org.apache.maven.plugins:maven-compiler-plugin:2.5.1:jar</extraArtifact>
                 
<extraArtifact>org.apache.maven.plugins:maven-ejb-plugin:2.3:jar</extraArtifact>
               </extraArtifacts>
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java 
b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
index 3bc47ae..3e4ef05 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -443,7 +443,7 @@ public class EarMojo
                 {
                     getLog().info( "Copying artifact [" + module + "] to [" + 
module.getUri() + "] (unpacked)" );
                     // Make sure that the destination is a directory to avoid 
plexus nasty stuff :)
-                    if ( !destinationFile.mkdirs() )
+                    if ( !destinationFile.isDirectory() && 
!destinationFile.mkdirs() )
                     {
                         throw new MojoExecutionException( "Error creating " + 
destinationFile );
                     }
@@ -749,19 +749,21 @@ public class EarMojo
                 // Create a temporary work directory
                 // MEAR-167 use uri as directory to prevent merging of 
artifacts with the same artifactId
                 workDirectory = new File( new File( getTempFolder(), "temp" ), 
module.getUri() );
-                if ( workDirectory.mkdirs() )
+                if ( !workDirectory.isDirectory() )
                 {
-                    getLog().debug( "Created a temporary work directory: " + 
workDirectory.getAbsolutePath() );
-
-                    // Unpack the archive to a temporary work directory
-                    zipUnArchiver.setSourceFile( original );
-                    zipUnArchiver.setDestDirectory( workDirectory );
-                    zipUnArchiver.extract();
-                }
-                else
-                {
-                    throw new MojoFailureException( "Failed to create 
directory " + workDirectory );
+                    if ( workDirectory.mkdirs() )
+                    {
+                        getLog().debug( "Created a temporary work directory: " 
+ workDirectory.getAbsolutePath() );
+                    }
+                    else
+                    {
+                        throw new MojoFailureException( "Failed to create 
directory " + workDirectory );
+                    }
                 }
+                // Unpack the archive to a temporary work directory
+                zipUnArchiver.setSourceFile( original );
+                zipUnArchiver.setDestDirectory( workDirectory );
+                zipUnArchiver.extract();
             }
             else
             {
diff --git 
a/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java 
b/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
index d30599f..445df00 100644
--- a/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
+++ b/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
@@ -68,14 +68,17 @@ public abstract class AbstractEarPluginIT
      * @param projectName the name of the project
      * @param properties extra properties to be used by the embedder
      * @param expectNoError true/false
+     * @param cleanBeforeExecute call clean plugin before execution
      * @return the base directory of the project
      */
-    protected File executeMojo( final String projectName, final Properties 
properties, boolean expectNoError ) throws VerificationException, IOException
+    protected File executeMojo( final String projectName, final Properties 
properties, boolean expectNoError,
+                                boolean cleanBeforeExecute ) throws 
VerificationException, IOException
     {
         System.out.println( "  Building: " + projectName );
 
         File testDir = getTestDir( projectName );
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( cleanBeforeExecute );
         // Let's add alternate settings.xml setting so that the latest 
dependencies are used
         String localRepo = System.getProperty( "localRepositoryPath" );
         verifier.setLocalRepo( localRepo );
@@ -119,31 +122,48 @@ public abstract class AbstractEarPluginIT
     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
-     * 
+     *
      * @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 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,
+                                  final boolean[] artifactsDirectory, 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 );
-        
+        final File baseDir = executeMojo( projectName, new Properties(), true, 
cleanBeforeExecute );
+        final File earDir = earModuleName == null ? baseDir : new File( 
baseDir, earModuleName );
+        assertEarArchive( earDir, projectName );
+        assertEarDirectory( earDir, projectName );
+
+        assertArchiveContent( earDir, projectName, expectedArtifacts, 
artifactsDirectory );
+
+        assertDeploymentDescriptors( earDir, projectName );
+
         return baseDir;
+    }
 
+    /**
+     * Executes the specified projects and asserts the given artifacts. Assert 
the deployment descriptors are valid
+     *
+     * @param projectName the project to test
+     * @param expectedArtifacts the list of artifacts to be found in the EAR 
archive
+     * @param artifactsDirectory whether the artifact is an exploded 
artifactsDirectory or not
+     * @return the base directory of the project
+     */
+    protected File doTestProject( final String projectName, final String[] 
expectedArtifacts,
+                                  final boolean[] artifactsDirectory )
+        throws VerificationException, IOException
+    {
+        return doTestProject( projectName, null, expectedArtifacts, 
artifactsDirectory, true );
     }
 
     /**
diff --git a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java 
b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
index fb1e5f5..ad0e0c1 100644
--- a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
+++ b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
@@ -38,7 +38,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a single EJB and no configuration.
-     * @throws Exception in case of an error.
      */
     public void testProject001()
         throws Exception
@@ -48,7 +47,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a customized artifact location and a customized 
artifact name.
-     * @throws Exception in case of an error.
      */
     public void testProject002()
         throws Exception
@@ -59,7 +57,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a default bundle directory for <tt>java</tt> modules.
-     * @throws Exception in case of an error.
      */
     public void testProject003()
         throws Exception
@@ -70,7 +67,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a default bundle directory for _java_ modules and a 
custom location overriding the default.
-     * @throws Exception in case of an error.
      */
     public void testProject004()
         throws Exception
@@ -81,7 +77,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom URI.
-     * @throws Exception in case of an error.
      */
     public void testProject005()
         throws Exception
@@ -91,7 +86,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with an excluded module.
-     * @throws Exception in case of an error.
      */
     public void testProject006()
         throws Exception
@@ -102,7 +96,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a classified artifact and no extra configuration.
-     * @throws Exception in case of an error.
      */
     public void testProject007()
         throws Exception
@@ -112,7 +105,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for J2EE 1.3.
-     * @throws Exception in case of an error.
      */
     public void testProject008()
         throws Exception
@@ -122,7 +114,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for J2EE 1.4.
-     * @throws Exception in case of an error.
      */
     public void testProject009()
         throws Exception
@@ -132,7 +123,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for Java EE 5.
-     * @throws Exception in case of an error.
      */
     public void testProject010()
         throws Exception
@@ -142,7 +132,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that deployment descriptor default settings 
are applied.
-     * @throws Exception in case of an error.
      */
     public void testProject011()
         throws Exception
@@ -152,7 +141,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that EAR resources are bundled within the 
EAR.
-     * @throws Exception in case of an error.
      */
     public void testProject012()
         throws Exception
@@ -162,7 +150,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that EAR resources in a customized 
resources directory are bundled within the EAR.
-     * @throws Exception in case of an error.
      */
     public void testProject013()
         throws Exception
@@ -172,7 +159,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that EAR resources are bundled within the 
EAR using includes and excludes.
-     * @throws Exception in case of an error.
      */
     public void testProject014()
         throws Exception
@@ -182,7 +168,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that default manifest is taken into account.
-     * @throws Exception in case of an error.
      */
     public void testProject015()
         throws Exception
@@ -196,7 +181,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that custom manifest is taken into account.
-     * @throws Exception in case of an error.
      */
     public void testProject016()
         throws Exception
@@ -219,7 +203,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that custom application.xml is taken into 
account.
-     * @throws Exception in case of an error.
      */
     public void testProject017()
         throws Exception
@@ -229,7 +212,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom final name.
-     * @throws Exception in case of an error.
      */
     public void testProject018()
         throws Exception
@@ -241,7 +223,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with unpacked archives using the unpackTypes.
-     * @throws Exception in case of an error.
      */
     public void testProject019()
         throws Exception
@@ -252,7 +233,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with unpacked archives using the unpack module attribute.
-     * @throws Exception in case of an error.
      */
     public void testProject020()
         throws Exception
@@ -263,7 +243,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with unpacked archives using both unpackTypes and the 
unpack module attribute.
-     * @throws Exception in case of an error.
      */
     public void testProject021()
         throws Exception
@@ -277,7 +256,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a classifier.
-     * @throws Exception in case of an error.
      */
     public void testProject022()
         throws Exception
@@ -289,7 +267,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that a single classified dependency is 
detected without specifying the classifier.
-     * @throws Exception in case of an error.
      */
     public void testProject023()
         throws Exception
@@ -301,7 +278,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that a single classified dependency is 
detected when specifying the classifier.
-     * @throws Exception in case of an error.
      */
     public void testProject024()
         throws Exception
@@ -314,7 +290,6 @@ public class EarMojoIT
     /**
      * Builds an EAR and make sure that a classified dependency with mutiple 
candidates is detected when specifying the
      * classifier.
-     * @throws Exception in case of an error.
      */
     public void testProject025()
         throws Exception
@@ -327,19 +302,17 @@ public class EarMojoIT
     /**
      * Builds an EAR and make sure that the build fails if a unclassifed 
module configuration with mutiple candidates is
      * specified.
-     * @throws Exception in case of an error.
      */
     public void testProject026()
         throws Exception
     {
-        final File baseDir = executeMojo( "project-026", new Properties(), 
false );
+        final File baseDir = executeMojo( "project-026", new Properties(), 
false, true );
         // Stupido, checks that the ear archive is not there
         assertFalse( "Execution should have failed", getEarArchive( baseDir, 
"project-026" ).exists() );
     }
 
     /**
      * Builds an EAR and make sure that provided dependencies are not included 
in the EAR.
-     * @throws Exception in case of an error.
      */
     public void testProject027()
         throws Exception
@@ -349,7 +322,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that test dependencies are not included in 
the EAR.
-     * @throws Exception in case of an error.
      */
     public void testProject028()
         throws Exception
@@ -359,7 +331,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and make sure that system dependencies are not included 
in the EAR.
-     * @throws Exception in case of an error.
      */
     public void testProject029()
         throws Exception
@@ -370,7 +341,6 @@ public class EarMojoIT
     /**
      * Builds an EAR and make sure that ejb-client dependencies are detected 
and not added by default in the generated
      * application.xml.
-     * @throws Exception in case of an error.
      */
     public void testProject030()
         throws Exception
@@ -382,7 +352,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with a Jboss 4 configuration specifying the security 
domain and the unauthenticated-principal to
      * use.
-     * @throws Exception in case of an error.
      */
     public void testProject031()
         throws Exception
@@ -393,7 +362,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 3.2 configuration specifying the jmx-name to 
use.
-     * @throws Exception in case of an error.
      */
     public void testProject032()
         throws Exception
@@ -404,7 +372,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 4 configuration and Jboss specific modules.
-     * @throws Exception in case of an error.
      */
     public void testProject033()
         throws Exception
@@ -415,7 +382,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with custom security settings.
-     * @throws Exception in case of an error.
      */
     public void testProject034()
         throws Exception
@@ -426,7 +392,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a full filename mapping and make sure that custom 
locations are not overridden.
-     * @throws Exception in case of an error.
      */
     public void testProject035()
         throws Exception
@@ -440,7 +405,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with a full filename mapping and make sure that groupIds 
with dots are replaced by dashes in
      * filenames.
-     * @throws Exception in case of an error.
      */
     public void testProject036()
         throws Exception
@@ -455,7 +419,6 @@ public class EarMojoIT
     /**
      * Builds an EAR and make sure that ejb-client dependencies are detected 
and added in the generated application.xml
      * if includeInApplicationXml is set.
-     * @throws Exception in case of an error.
      */
     public void testProject037()
         throws Exception
@@ -466,7 +429,6 @@ public class EarMojoIT
     /**
      * Builds an EAR and make sure that a non-classified dependency with 
mutiple candidates is detected when specifying
      * the mainArtifactId as classifier.
-     * @throws Exception in case of an error.
      */
     public void testProject038()
         throws Exception
@@ -477,7 +439,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 4 configuration specifying specifying the 
loader repository to use.
-     * @throws Exception in case of an error.
      */
     public void testProject039()
         throws Exception
@@ -487,7 +448,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for Java EE 5 
and an alternative deployment descriptor.
-     * @throws Exception in case of an error.
      */
     public void testProject040()
         throws Exception
@@ -497,7 +457,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 4.2 configuration specifying the module 
order to use.
-     * @throws Exception in case of an error.
      */
     public void testProject041()
         throws Exception
@@ -507,7 +466,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 4.2 configuration specifying a datasource to 
add.
-     * @throws Exception in case of an error.
      */
     public void testProject042()
         throws Exception
@@ -517,7 +475,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom descriptor location 
(generatedDescriptorLocation setting).
-     * @throws Exception in case of an error.
      */
     public void testProject043()
         throws Exception
@@ -530,7 +487,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom library-directory.
-     * @throws Exception in case of an error.
      */
     public void testProject044()
         throws Exception
@@ -540,7 +496,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and filter the content of the sources directory.
-     * @throws Exception in case of an error.
      */
     public void testProject045()
         throws Exception
@@ -554,7 +509,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and filter the content of the sources directory using a 
custom filter file.
-     * @throws Exception in case of an error.
      */
     public void testProject046()
         throws Exception
@@ -570,7 +524,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR and filter the content with a list of extensions.
-     * @throws Exception in case of an error.
      */
     public void testProject047()
         throws Exception
@@ -584,7 +537,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a JBoss 5 configuration containing library directory.
-     * @throws Exception in case of an error.
      */
     public void testProject048()
         throws Exception
@@ -594,7 +546,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a JBoss 4.2 configuration containing a library 
directory.
-     * @throws Exception in case of an error.
      */
     public void testProject049()
         throws Exception
@@ -604,7 +555,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 5 configuration containing a loader 
repository configuration definition.
-     * @throws Exception in case of an error.
      */
     public void testProject050()
         throws Exception
@@ -614,7 +564,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 5 configuration containing a loader 
repository class definition.
-     * @throws Exception in case of an error.
      */
     public void testProject051()
         throws Exception
@@ -624,7 +573,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 5 configuration containing a configuration 
parser class definition.
-     * @throws Exception in case of an error.
      */
     public void testProject052()
         throws Exception
@@ -634,7 +582,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a Jboss 5 configuration containing only the loader 
repo configuration
-     * @throws Exception in case of an error.
      */
     public void testProject053()
         throws Exception
@@ -644,7 +591,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for Java EE 5 
and no application.xml
-     * @throws Exception in case of an error.
      */
     public void testProject054()
         throws Exception
@@ -654,7 +600,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with jar dependencies added in application.xml.
-     * @throws Exception in case of an error.
      */
     public void testProject055()
         throws Exception
@@ -665,7 +610,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for J2EE 1.4 and 
an alternative deployment descriptor.
-     * @throws Exception in case of an error.
      */
     public void testProject056()
         throws Exception
@@ -675,7 +619,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a complete JBoss 4.2 configuration and validate it 
matches the DTD (MEAR-104).
-     * @throws Exception in case of an error.
      */
     public void testProject057()
         throws Exception
@@ -685,7 +628,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for Java EE 6.
-     * @throws Exception in case of an error.
      */
     public void testProject058()
         throws Exception
@@ -695,7 +637,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with no display name entry at all.
-     * @throws Exception in case of an error.
      */
     public void testProject059()
         throws Exception
@@ -705,8 +646,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with ejb-client packaged for J2EE 1.3 (MEAR-85)
-     *
-     * @throws Exception in case of an error.
      */
     public void testProject060()
         throws Exception
@@ -716,8 +655,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with ejb-client packaged for J2EE 1.4 (MEAR-85)
-     *
-     * @throws Exception in case of an error.
      */
     public void testProject061()
         throws Exception
@@ -727,8 +664,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with ejb-client packaged for JavaEE 5 (MEAR-85)
-     *
-     * @throws Exception in case of an error.
      */
     public void testProject062()
         throws Exception
@@ -738,8 +673,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with ejb-client packaged for JavaEE 6 (MEAR-85)
-     *
-     * @throws Exception in case of an error.
      */
     public void testProject063()
         throws Exception
@@ -749,8 +682,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with ejb-client packaged for JavaEE 5 and still put it in 
the root (MEAR-85)
-     *
-     * @throws Exception in case of an error.
      */
     public void testProject064()
         throws Exception
@@ -760,7 +691,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom moduleId.
-     * @throws Exception in case of an error.
      */
     public void testProject065()
         throws Exception
@@ -770,7 +700,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with generateModuleId enabled.
-     * @throws Exception in case of an error.
      */
     public void testProject066()
         throws Exception
@@ -780,7 +709,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with generateModuleId enabled and a custom module.
-     * @throws Exception in case of an error.
      */
     public void testProject067()
         throws Exception
@@ -790,7 +718,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with the no-version file name mapping.
-     * @throws Exception in case of an error.
      */
     public void testProject068()
         throws Exception
@@ -800,7 +727,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with a custom library-directory and JavaEE 6.
-     * @throws Exception in case of an error.
      */
     public void testProject069()
         throws Exception
@@ -810,7 +736,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with application-name and initialize-in-order tags.
-     * @throws Exception in case of an error.
      */
     public void testProject070()
         throws Exception
@@ -820,7 +745,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with application-name and initialize-in-order tags for 
unsupported version.
-     * @throws Exception in case of an error.
      */
     public void testProject071()
         throws Exception
@@ -830,7 +754,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with an application client module (app-client).
-     * @throws Exception in case of an error.
      */
     public void testProject072()
         throws Exception
@@ -840,7 +763,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with an application client module (app-client) and a 
default bundle directory for _java_ modules.
-     * @throws Exception in case of an error.
      */
     public void testProject073()
         throws Exception
@@ -852,7 +774,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with custom env entries settings and J2EE 1.3. Not 
supported by the specification so this should be
      * ignored.
-     * @throws Exception in case of an error.
      */
     public void testProject074()
         throws Exception
@@ -863,7 +784,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with custom env entries settings and J2EE 1.4. Not 
supported by the specification so this should be
      * ignored.
-     * @throws Exception in case of an error.
      */
     public void testProject075()
         throws Exception
@@ -874,7 +794,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with custom env entries settings and JavaEE 5. Not 
supported by the specification so this should be
      * ignored.
-     * @throws Exception in case of an error.
      */
     public void testProject076()
         throws Exception
@@ -884,7 +803,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with custom env entries settings and JavaEE 6.
-     * @throws Exception in case of an error.
      */
     public void testProject077()
         throws Exception
@@ -894,7 +812,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with the no version for ejb file name mapping.
-     * @throws Exception in case of an error.
      */
     public void testProject078()
         throws Exception
@@ -905,7 +822,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with the 'default' library directory mode. Uses the value 
of the defaultLibBundleDir.
-     * @throws Exception in case of an error.
      */
     public void testProject079()
         throws Exception
@@ -915,7 +831,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with the 'empty' library directory mode. Generate an 
empty library-directory element.
-     * @throws Exception in case of an error.
      */
     public void testProject080()
         throws Exception
@@ -925,7 +840,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with the 'none' library directory mode. Does not generate 
an library-directory element.
-     * @throws Exception in case of an error.
      */
     public void testProject081()
         throws Exception
@@ -935,7 +849,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with deployment descriptor configuration for JavaEE 7.
-     * @throws Exception in case of an error.
      */
     public void testProject082()
         throws Exception
@@ -946,7 +859,6 @@ public class EarMojoIT
     /**
      * Builds an EAR with a library directory and custom env entries. The 
library-directory element must come first
      * (MEAR-158).
-     * @throws Exception in case of an error.
      */
     public void testProject083()
         throws Exception
@@ -956,7 +868,6 @@ public class EarMojoIT
 
     /**
      * Support of an application id (MEAR-174).
-     * @throws Exception in case of an error.
      */
     public void testProject084()
         throws Exception
@@ -966,7 +877,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with custom ejbRef entries settings and JavaEE 6.
-     * @throws Exception in case of an error.
      */
     public void testProject085()
         throws Exception
@@ -976,7 +886,6 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with custom ejbRef entries plus lookup-name entry.
-     * @throws Exception in case of an error.
      */
     public void testProject086()
         throws Exception
@@ -986,11 +895,29 @@ public class EarMojoIT
 
     /**
      * Builds an EAR with resource-ref entries.
-     * @throws Exception in case of an error.
      */
     public void testProject087()
         throws Exception
     {
         doTestProject( "project-087", new String[] { 
"eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
     }
+
+    /**
+     * Builds WAR and EAR as part of multi-module project twice so that the 
2nd build is guaranteed to be performed when
+     * target directories and files exist.
+     */
+    public void testProject088()
+        throws Exception
+    {
+        final String[] expectedArtifacts = {
+            "eartest-war-sample-two-1.0.war",
+            "eartest-ejb-sample-one-1.0.jar",
+            "lib/eartest-jar-sample-two-1.0.jar" };
+        final boolean[] artifactsDirectory = { false, true, false };
+        // "Clean" build - target directories and files do not exist
+        // Pass cleanBeforeExecute parameter to ensure that target location is 
cleaned before Mojo execution
+        doTestProject( "project-088", "ear", expectedArtifacts, 
artifactsDirectory, true );
+        // "Dirty" build - target directories and files exist
+        doTestProject( "project-088", "ear", expectedArtifacts, 
artifactsDirectory, false );
+    }
 }
diff --git 
a/src/test/resources/projects/project-088/ear/expected-META-INF/application.xml 
b/src/test/resources/projects/project-088/ear/expected-META-INF/application.xml
new file mode 100644
index 0000000..f4d3407
--- /dev/null
+++ 
b/src/test/resources/projects/project-088/ear/expected-META-INF/application.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<application xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/application_6.xsd"; version="6">
+  <display-name>maven-ear-plugin-test-project-088</display-name>
+  <module>
+    <web>
+      <web-uri>eartest-war-sample-two-1.0.war</web-uri>
+      <context-root>/war-sample-two</context-root>
+    </web>
+  </module>
+  <module>
+    <ejb>eartest-ejb-sample-one-1.0.jar</ejb>
+  </module>
+  <library-directory>lib</library-directory>
+</application>
diff --git a/src/test/resources/projects/project-088/ear/pom.xml 
b/src/test/resources/projects/project-088/ear/pom.xml
new file mode 100644
index 0000000..5d4565c
--- /dev/null
+++ b/src/test/resources/projects/project-088/ear/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>ear</groupId>
+    <artifactId>maven-ear-plugin-test-project-088-parent</artifactId>
+    <version>99.0</version>
+  </parent>
+  <artifactId>maven-ear-plugin-test-project-088</artifactId>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>jar-sample-two</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>war-sample-two</artifactId>
+      <type>war</type>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <version>6</version>
+          <defaultLibBundleDir>lib</defaultLibBundleDir>
+          <skinnyWars>true</skinnyWars>
+          <unpackTypes>ejb</unpackTypes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/test/resources/projects/project-088/pom.xml 
b/src/test/resources/projects/project-088/pom.xml
new file mode 100644
index 0000000..ffb64a4
--- /dev/null
+++ b/src/test/resources/projects/project-088/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-088-parent</artifactId>
+  <version>99.0</version>
+  <packaging>pom</packaging>
+  <modules>
+    <module>war</module>
+    <module>ear</module>
+  </modules>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>eartest</groupId>
+        <artifactId>jar-sample-two</artifactId>
+        <version>1.0</version>
+      </dependency>
+      <dependency>
+        <groupId>eartest</groupId>
+        <artifactId>war-sample-two</artifactId>
+        <version>1.0</version>
+        <type>war</type>
+      </dependency>
+      <dependency>
+        <groupId>eartest</groupId>
+        <artifactId>ejb-sample-one</artifactId>
+        <version>1.0</version>
+        <type>ejb</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-war-plugin</artifactId>
+          <version>@mavenWarPluginVersion@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/src/test/resources/projects/project-088/war/pom.xml 
b/src/test/resources/projects/project-088/war/pom.xml
new file mode 100644
index 0000000..21d1967
--- /dev/null
+++ b/src/test/resources/projects/project-088/war/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>ear</groupId>
+    <artifactId>maven-ear-plugin-test-project-088-parent</artifactId>
+    <version>99.0</version>
+  </parent>
+  <groupId>eartest</groupId>
+  <artifactId>war-sample-two</artifactId>
+  <version>1.0</version>
+  <packaging>war</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>jar-sample-two</artifactId>
+    </dependency>
+  </dependencies>
+</project>
diff --git 
a/src/test/resources/projects/project-088/war/src/main/webapp/WEB-INF/web.xml 
b/src/test/resources/projects/project-088/war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..fbbf307
--- /dev/null
+++ 
b/src/test/resources/projects/project-088/war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
+         version="3.0">
+</web-app>

Reply via email to