Merge branch 'mear-153'
diff --git a/pom.xml b/pom.xml
index c6b9207..8607f9c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +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>
+ <mavenWarPluginVersion>3.3.1</mavenWarPluginVersion>
<mavenCompilerPluginVersion>2.5.1</mavenCompilerPluginVersion>
<mavenEjbPluginVersion>2.3</mavenEjbPluginVersion>
<mavenRarPluginVersion>2.4</mavenRarPluginVersion>
@@ -94,6 +94,7 @@
<invoker.skip>false</invoker.skip>
<invoker.install.skip>${invoker.skip}</invoker.install.skip>
<invoker.it.skip>${invoker.skip}</invoker.it.skip>
+ <invoker.cloneClean>true</invoker.cloneClean>
</properties>
<dependencies>
@@ -158,6 +159,12 @@
<version>3.3.3</version>
</dependency>
<dependency>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-plexus</artifactId>
+ <version>1.4.3.2</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<version>1.6</version>
@@ -181,12 +188,6 @@
<version>4.13.1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.28.2</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -293,6 +294,7 @@
</extraArtifacts>
<skipInstallation>${invoker.install.skip}</skipInstallation>
<skipInvocation>${invoker.it.skip}</skipInvocation>
+ <cloneClean>${invoker.cloneClean}</cloneClean>
</configuration>
</plugin>
<plugin>
diff --git a/src/it/MEAR-243-skinny-wars-provided/war-module/pom.xml b/src/it/MEAR-243-skinny-wars-provided/war-module/pom.xml
index c6be50e..9604026 100644
--- a/src/it/MEAR-243-skinny-wars-provided/war-module/pom.xml
+++ b/src/it/MEAR-243-skinny-wars-provided/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/filenamemapping-usage-fail/war-module/pom.xml b/src/it/filenamemapping-usage-fail/war-module/pom.xml
index c6be50e..9604026 100644
--- a/src/it/filenamemapping-usage-fail/war-module/pom.xml
+++ b/src/it/filenamemapping-usage-fail/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/non-skinny-wars/war-module/pom.xml b/src/it/non-skinny-wars/war-module/pom.xml
index 10c4b6c..58254c1 100644
--- a/src/it/non-skinny-wars/war-module/pom.xml
+++ b/src/it/non-skinny-wars/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-filenamemapping-full/war-module/pom.xml b/src/it/skinny-wars-filenamemapping-full/war-module/pom.xml
index c6be50e..9604026 100644
--- a/src/it/skinny-wars-filenamemapping-full/war-module/pom.xml
+++ b/src/it/skinny-wars-filenamemapping-full/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-filenamemapping-no-version/war-module/pom.xml b/src/it/skinny-wars-filenamemapping-no-version/war-module/pom.xml
index c6be50e..9604026 100644
--- a/src/it/skinny-wars-filenamemapping-no-version/war-module/pom.xml
+++ b/src/it/skinny-wars-filenamemapping-no-version/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-javaee5/war-module/pom.xml b/src/it/skinny-wars-javaee5/war-module/pom.xml
index ab808a3..9604026 100644
--- a/src/it/skinny-wars-javaee5/war-module/pom.xml
+++ b/src/it/skinny-wars-javaee5/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>3.1.0</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-timestamp/ear-module/pom.xml b/src/it/skinny-wars-timestamp/ear-module/pom.xml
index 7da0166..f279c71 100644
--- a/src/it/skinny-wars-timestamp/ear-module/pom.xml
+++ b/src/it/skinny-wars-timestamp/ear-module/pom.xml
@@ -40,7 +40,13 @@
</dependency>
<dependency>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
- <artifactId>war-module</artifactId>
+ <artifactId>war-module-one</artifactId>
+ <version>1.0</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.its.ear.skinnywars</groupId>
+ <artifactId>war-module-two</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
diff --git a/src/it/skinny-wars-timestamp/pom.xml b/src/it/skinny-wars-timestamp/pom.xml
index b1c8946..4980a14 100644
--- a/src/it/skinny-wars-timestamp/pom.xml
+++ b/src/it/skinny-wars-timestamp/pom.xml
@@ -30,8 +30,8 @@
<description>Test Skinny WAR generation</description>
<modules>
- <module>ear-module</module>
- <module>war-module</module>
+ <module>ear-module</module>
+ <module>war-module-one</module>
+ <module>war-module-two</module>
</modules>
-
</project>
diff --git a/src/it/skinny-wars-timestamp/verify.bsh b/src/it/skinny-wars-timestamp/verify.bsh
index f9a7270..3b9307d 100644
--- a/src/it/skinny-wars-timestamp/verify.bsh
+++ b/src/it/skinny-wars-timestamp/verify.bsh
@@ -20,78 +20,108 @@
import java.io.*;
import java.util.*;
import java.util.jar.*;
-import java.util.regex.*;
-File jarFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-1.0.war" );
-System.out.println( "Checking for existence of " + jarFile );
-if ( !jarFile.isFile() )
+assertFileExists( File file )
{
- throw new IllegalStateException( "Missing file: " + jarFile );
-}
-
-JarFile jar = new JarFile( jarFile );
-
-String[] includedEntries = {
- "WEB-INF/web.xml",
- "META-INF/MANIFEST.MF"
-};
-for ( String included : includedEntries )
-{
- System.out.println( "Checking for included archive entry " + included );
- if ( jar.getEntry( included ) == null )
+ System.out.println( "Checking for existence of " + file );
+ if ( !file.isFile() )
{
- throw new IllegalStateException( "Missing archive entry: " + included );
+ throw new IllegalStateException( "Missing file: " + file );
}
}
-Manifest manifest = jar.getManifest();
-String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path");
-System.out.println( "manifestClassPath: " + manifestClassPath );
-if ( !manifestClassPath.equals("commons-lang-commons-lang-2.5.jar eartest-jar-sample-one-1.0-20150825.210557-91.jar") )
+assertIncludes( File file, String[] includedEntries )
{
- throw new IllegalStateException( "Missing entry in war MANIFEST.MF: commons-lang-commons-lang-2.5.jar eartest-jar-sample-one-1.0-20150825.210557-91.jar");
-}
-
-String[] excludedEntries = {
- "WEB-INF/lib/commons-lang-2.5.jar",
- "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar"
-};
-for ( String excluded : excludedEntries )
-{
- System.out.println( "Checking for excluded artifact " + excluded );
- if ( jar.getEntry( excluded ) != null )
+ JarFile jar = new JarFile( file );
+ try
{
- throw new IllegalStateException( "Archive entry should be excluded: " + excluded );
+ for ( String included : includedEntries )
+ {
+ System.out.println( "Checking for included archive entry " + included );
+ if ( jar.getEntry( included ) == null )
+ {
+ throw new IllegalStateException( "Missing archive entry: " + included );
+ }
+ }
+ }
+ finally
+ {
+ jar.close();
}
}
-jar.close();
-
-
-File jarFile = new File( basedir, "war-module/target/war-module-1.0.war" );
-System.out.println( "Checking for existence of " + jarFile );
-if ( !jarFile.isFile() )
+assertExcludes( File file, String[] excludedEntries )
{
- throw new IllegalStateException( "Missing file: " + jarFile );
-}
-
-JarFile jar = new JarFile( jarFile );
-
-String[] includedEntries = {
- "WEB-INF/web.xml",
- "META-INF/MANIFEST.MF",
- "WEB-INF/lib/commons-lang-2.5.jar",
- "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar"
-};
-for ( String included : includedEntries )
-{
- System.out.println( "Checking for included archive entry " + included );
- if ( jar.getEntry( included ) == null )
+ JarFile jar = new JarFile( file );
+ try
{
- throw new IllegalStateException( "Missing archive entry: " + included );
+ for ( String excluded : excludedEntries )
+ {
+ System.out.println( "Checking for excluded artifact " + excluded );
+ if ( jar.getEntry( excluded ) != null )
+ {
+ throw new IllegalStateException( "Archive entry should be excluded: " + excluded );
+ }
+ }
+ }
+ finally
+ {
+ jar.close();
}
}
-jar.close();
+assertManifestClassPath( File file, String classPath )
+{
+ JarFile jar = new JarFile( file );
+ try
+ {
+ Manifest manifest = jar.getManifest();
+ String manifestClassPath = manifest.getMainAttributes().getValue( "Class-Path" );
+ System.out.println( "manifestClassPath: " + manifestClassPath );
+ if ( !( classPath == null && manifestClassPath == null
+ || manifestClassPath != null && manifestClassPath.equals( classPath ) ) )
+ {
+ throw new IllegalStateException( "Missing entry in war MANIFEST.MF: " + classPath );
+ }
+ }
+ finally
+ {
+ jar.close();
+ }
+}
+
+File warOneFile = new File( basedir, "war-module-one/target/war-module-one-1.0.war" );
+assertFileExists( warOneFile );
+assertIncludes( warOneFile, new String[] { "WEB-INF/web.xml",
+ "META-INF/MANIFEST.MF",
+ "WEB-INF/lib/commons-lang-2.5.jar",
+ "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" } );
+assertManifestClassPath( warOneFile, "commons-lang-2.5.jar jar-sample-one-1.0-20150825.210557-91.jar" );
+
+File warTwoFile = new File( basedir, "war-module-two/target/war-module-two-1.0.war" );
+assertFileExists( warTwoFile );
+assertIncludes( warTwoFile, new String[] { "WEB-INF/web.xml",
+ "META-INF/MANIFEST.MF",
+ "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar" } );
+assertExcludes( warTwoFile, new String[] { "WEB-INF/lib/commons-lang-2.5.jar" } );
+assertManifestClassPath( warTwoFile, "jar-sample-one-1.0-SNAPSHOT.jar" );
+
+File warModuleOneFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-one-1.0.war" );
+assertFileExists( warModuleOneFile );
+assertIncludes( warModuleOneFile, new String[] { "WEB-INF/web.xml",
+ "META-INF/MANIFEST.MF" } );
+assertExcludes( warModuleOneFile, new String[] { "WEB-INF/lib/commons-lang-2.5.jar",
+ "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar",
+ "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" } );
+assertManifestClassPath( warModuleOneFile, "commons-lang-commons-lang-2.5.jar eartest-jar-sample-one-1.0-20150825.210557-91.jar" );
+
+File warModuleTwoFile = new File( basedir, "ear-module/target/ear-module-1.0/org.apache.maven.its.ear.skinnywars-war-module-two-1.0.war" );
+assertFileExists( warModuleTwoFile );
+assertIncludes( warModuleTwoFile, new String[] { "WEB-INF/web.xml",
+ "META-INF/MANIFEST.MF" } );
+assertExcludes( warModuleTwoFile, new String[] { "WEB-INF/lib/commons-lang-2.5.jar",
+ "WEB-INF/lib/jar-sample-one-1.0-SNAPSHOT.jar",
+ "WEB-INF/lib/jar-sample-one-1.0-20150825.210557-91.jar" } );
+assertManifestClassPath( warModuleTwoFile, "eartest-jar-sample-one-1.0-20150825.210557-91.jar commons-lang-commons-lang-2.5.jar" );
return true;
diff --git a/src/it/skinny-wars-timestamp/war-module/pom.xml b/src/it/skinny-wars-timestamp/war-module-one/pom.xml
similarity index 79%
rename from src/it/skinny-wars-timestamp/war-module/pom.xml
rename to src/it/skinny-wars-timestamp/war-module-one/pom.xml
index 82cce9e..553f3bc 100644
--- a/src/it/skinny-wars-timestamp/war-module/pom.xml
+++ b/src/it/skinny-wars-timestamp/war-module-one/pom.xml
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
- <artifactId>war-module</artifactId>
+ <artifactId>war-module-one</artifactId>
<version>1.0</version>
<packaging>war</packaging>
@@ -45,7 +45,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
+ <configuration>
+ <outputFileNameMapping>@{artifactId}@-@{version}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-timestamp/war-module/src/main/webapp/WEB-INF/web.xml b/src/it/skinny-wars-timestamp/war-module-one/src/main/webapp/WEB-INF/web.xml
similarity index 100%
rename from src/it/skinny-wars-timestamp/war-module/src/main/webapp/WEB-INF/web.xml
rename to src/it/skinny-wars-timestamp/war-module-one/src/main/webapp/WEB-INF/web.xml
diff --git a/src/it/skinny-wars-timestamp/war-module/pom.xml b/src/it/skinny-wars-timestamp/war-module-two/pom.xml
similarity index 68%
copy from src/it/skinny-wars-timestamp/war-module/pom.xml
copy to src/it/skinny-wars-timestamp/war-module-two/pom.xml
index 82cce9e..b719677 100644
--- a/src/it/skinny-wars-timestamp/war-module/pom.xml
+++ b/src/it/skinny-wars-timestamp/war-module-two/pom.xml
@@ -23,17 +23,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
- <artifactId>war-module</artifactId>
+ <artifactId>war-module-two</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.5</version>
- </dependency>
- <dependency>
<groupId>eartest</groupId>
<artifactId>jar-sample-one</artifactId>
<version>1.0-SNAPSHOT</version>
@@ -45,7 +40,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
+ <configuration>
+ <outputFileNameMapping>@{artifactId}@-@{baseVersion}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathLayoutType>custom</classpathLayoutType>
+ <customClasspathLayout>$${artifact.artifactId}-$${artifact.baseVersion}$${dashClassifier?}.$${artifact.extension}</customClasspathLayout>
+ </manifest>
+ </archive>
+ </configuration>
</plugin>
</plugins>
</build>
diff --git a/src/it/skinny-wars-timestamp/war-module/src/main/webapp/WEB-INF/web.xml b/src/it/skinny-wars-timestamp/war-module-two/src/main/webapp/WEB-INF/web.xml
similarity index 100%
copy from src/it/skinny-wars-timestamp/war-module/src/main/webapp/WEB-INF/web.xml
copy to src/it/skinny-wars-timestamp/war-module-two/src/main/webapp/WEB-INF/web.xml
diff --git a/src/it/skinny-wars/war-module/pom.xml b/src/it/skinny-wars/war-module/pom.xml
index c6be50e..9604026 100644
--- a/src/it/skinny-wars/war-module/pom.xml
+++ b/src/it/skinny-wars/war-module/pom.xml
@@ -40,7 +40,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.1.1</version>
+ <version>@mavenWarPluginVersion@</version>
</plugin>
</plugins>
</build>
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 a474d08..258a1cc 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -40,6 +40,7 @@
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
@@ -56,6 +57,7 @@
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.MavenResourcesExecution;
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
+import org.apache.maven.shared.mapping.MappingUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
@@ -70,6 +72,7 @@
import org.codehaus.plexus.archiver.zip.ZipArchiver;
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
import org.codehaus.plexus.components.io.filemappers.FileMapper;
+import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
@@ -85,6 +88,12 @@
extends AbstractEarMojo
{
/**
+ * Default file name mapping used by artifacts located in local repository.
+ */
+ private static final String ARTIFACT_DEFAULT_FILE_NAME_MAPPING =
+ "@{artifactId}@-@{version}@@{dashClassifier?}@.@{extension}@";
+
+ /**
* Single directory for extra files to include in the EAR.
*/
@Parameter( defaultValue = "${basedir}/src/main/application", required = true )
@@ -836,14 +845,35 @@
{
getLog().debug( "module does not exist with original file name." );
artifact = new File( workLibDir, jm.getBundleFileName() );
- getLog().debug( "Artifact with mapping:" + artifact.getAbsolutePath() );
+ getLog().debug( "Artifact with mapping: " + artifact.getAbsolutePath() );
}
if ( !artifact.exists() )
{
getLog().debug( "Artifact with mapping does not exist." );
artifact = new File( workLibDir, jm.getArtifact().getFile().getName() );
- getLog().debug( "Artifact with original file name:" + artifact.getAbsolutePath() );
+ getLog().debug( "Artifact with original file name: " + artifact.getAbsolutePath() );
+ }
+
+ if ( !artifact.exists() )
+ {
+ getLog().debug( "Artifact with original file name does not exist." );
+ final Artifact jmArtifact = jm.getArtifact();
+ if ( jmArtifact.isSnapshot() )
+ {
+ try
+ {
+ artifact = new File( workLibDir, MappingUtils
+ .evaluateFileNameMapping( ARTIFACT_DEFAULT_FILE_NAME_MAPPING, jmArtifact ) );
+ getLog()
+ .debug( "Artifact with default mapping file name: " + artifact.getAbsolutePath() );
+ }
+ catch ( InterpolationException e )
+ {
+ getLog().warn( "Failed to evaluate file name for [" + jm + "] module using mapping: "
+ + ARTIFACT_DEFAULT_FILE_NAME_MAPPING );
+ }
+ }
}
if ( artifact.exists() )
@@ -986,11 +1016,29 @@
{
return moduleClassPathIndex;
}
- moduleClassPathIndex = classPathElements.indexOf( module.getArtifact().getFile().getName() );
+ final Artifact artifact = module.getArtifact();
+ moduleClassPathIndex = classPathElements.indexOf( artifact.getFile().getName() );
if ( moduleClassPathIndex != -1 )
{
return moduleClassPathIndex;
}
+ if ( artifact.isSnapshot() )
+ {
+ try
+ {
+ moduleClassPathIndex = classPathElements
+ .indexOf( MappingUtils.evaluateFileNameMapping( ARTIFACT_DEFAULT_FILE_NAME_MAPPING, artifact ) );
+ if ( moduleClassPathIndex != -1 )
+ {
+ return moduleClassPathIndex;
+ }
+ }
+ catch ( InterpolationException e )
+ {
+ getLog().warn( "Failed to evaluate file name for [" + module + "] module using mapping: "
+ + ARTIFACT_DEFAULT_FILE_NAME_MAPPING );
+ }
+ }
return classPathElements.indexOf( module.getUri() );
}
}