[MEAR-216] - Handling test JARs as regular JARs
diff --git a/pom.xml b/pom.xml
index ac06435..14a4da4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@
<mavenWarPluginVersion>2.1.1</mavenWarPluginVersion>
<mavenCompilerPluginVersion>2.5.1</mavenCompilerPluginVersion>
<mavenEjbPluginVersion>2.3</mavenEjbPluginVersion>
+ <mavenJarPluginVersion>3.2.0</mavenJarPluginVersion>
<invoker.skip>false</invoker.skip>
<invoker.install.skip>${invoker.skip}</invoker.install.skip>
<invoker.it.skip>${invoker.skip}</invoker.it.skip>
@@ -286,6 +287,7 @@
<extraArtifact>org.apache.maven.plugins:maven-war-plugin:${mavenWarPluginVersion}:jar</extraArtifact>
<extraArtifact>org.apache.maven.plugins:maven-compiler-plugin:${mavenCompilerPluginVersion}:jar</extraArtifact>
<extraArtifact>org.apache.maven.plugins:maven-ejb-plugin:${mavenEjbPluginVersion}:jar</extraArtifact>
+ <extraArtifact>org.apache.maven.plugins:maven-jar-plugin:${mavenJarPluginVersion}:jar</extraArtifact>
</extraArtifacts>
<skipInstallation>${invoker.install.skip}</skipInstallation>
<skipInvocation>${invoker.it.skip}</skipInvocation>
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java b/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
index 161e6bc..be8bfc2 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
@@ -39,7 +39,7 @@
*/
public static final List<String> STANDARD_ARTIFACT_TYPE =
Collections.unmodifiableList( Arrays.asList( "jar", "ejb", "par", "ejb-client", "app-client", "rar", "war",
- "sar", "wsr", "har" ) );
+ "sar", "wsr", "har", "test-jar" ) );
/**
* Creates a new {@link EarModule} based on the specified {@link Artifact} and the specified execution
@@ -70,7 +70,7 @@
throw new UnknownArtifactTypeException( e.getMessage() + " for " + artifact.getArtifactId() );
}
- if ( "jar".equals( artifactType ) )
+ if ( "jar".equals( artifactType ) || "test-jar".equals( artifactType ) )
{
return new JarModule( artifact, defaultLibBundleDir, includeInApplicationXml );
}
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 91ca4be..7d7a959 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
@@ -995,4 +995,24 @@
new String[][] { { "jar-sample-two-1.0.jar" }, { jarSampleThreeLibrary, jarSampleTwoLibrary } },
true );
}
+
+ /**
+ * Ensures that test JAR dependency of WAR is handled as regular JAR in terms of packaging and manifest modification
+ * when skinnyWars option is turned on.
+ */
+ public void testProject092()
+ throws Exception
+ {
+ final String warModule = "eartest-war-sample-two-1.0.war";
+ final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
+ final String jarSampleThreeLibrary = "lib/eartest-jar-sample-three-with-deps-1.0.jar";
+ final String jarSampleFourTestLibrary = "lib/eartest-jar-sample-four-1.0-tests.jar";
+ doTestProject( "project-092", "ear",
+ new String[] { warModule, jarSampleTwoLibrary, jarSampleThreeLibrary, jarSampleFourTestLibrary },
+ new boolean[] { false, false, false, false },
+ new String[] { warModule },
+ new boolean[] { false },
+ new String[][] { { jarSampleFourTestLibrary, jarSampleThreeLibrary, jarSampleTwoLibrary } },
+ true );
+ }
}
diff --git a/src/test/resources/projects/project-092/ear/expected-META-INF/application.xml b/src/test/resources/projects/project-092/ear/expected-META-INF/application.xml
new file mode 100644
index 0000000..bfbbff0
--- /dev/null
+++ b/src/test/resources/projects/project-092/ear/expected-META-INF/application.xml
@@ -0,0 +1,29 @@
+<?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-092</display-name>
+ <module>
+ <web>
+ <web-uri>eartest-war-sample-two-1.0.war</web-uri>
+ <context-root>/war-sample-two</context-root>
+ </web>
+ </module>
+ <library-directory>lib</library-directory>
+</application>
diff --git a/src/test/resources/projects/project-092/ear/pom.xml b/src/test/resources/projects/project-092/ear/pom.xml
new file mode 100644
index 0000000..8839f0c
--- /dev/null
+++ b/src/test/resources/projects/project-092/ear/pom.xml
@@ -0,0 +1,57 @@
+<?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-092-parent</artifactId>
+ <version>99.0</version>
+ </parent>
+ <artifactId>maven-ear-plugin-test-project-092</artifactId>
+ <packaging>ear</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-two</artifactId>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-two</artifactId>
+ <type>pom</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>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/test/resources/projects/project-092/jar/pom.xml b/src/test/resources/projects/project-092/jar/pom.xml
new file mode 100644
index 0000000..b012806
--- /dev/null
+++ b/src/test/resources/projects/project-092/jar/pom.xml
@@ -0,0 +1,54 @@
+<?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-092-parent</artifactId>
+ <version>99.0</version>
+ </parent>
+ <groupId>eartest</groupId>
+ <artifactId>jar-sample-four</artifactId>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>jar-sample-three-with-deps</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>test-jar</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/test/resources/projects/project-092/pom.xml b/src/test/resources/projects/project-092/pom.xml
new file mode 100644
index 0000000..1ab7d0b
--- /dev/null
+++ b/src/test/resources/projects/project-092/pom.xml
@@ -0,0 +1,76 @@
+<?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-092-parent</artifactId>
+ <version>99.0</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>jar</module>
+ <module>war</module>
+ <module>ear</module>
+ </modules>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>jar-sample-three-with-deps</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>jar-sample-four</artifactId>
+ <version>1.0</version>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-two</artifactId>
+ <version>1.0</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-two</artifactId>
+ <version>1.0</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>@mavenWarPluginVersion@</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>@mavenJarPluginVersion@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/src/test/resources/projects/project-092/war/pom.xml b/src/test/resources/projects/project-092/war/pom.xml
new file mode 100644
index 0000000..2199dae
--- /dev/null
+++ b/src/test/resources/projects/project-092/war/pom.xml
@@ -0,0 +1,40 @@
+<?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-092-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-four</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/test/resources/projects/project-092/war/src/main/webapp/WEB-INF/web.xml b/src/test/resources/projects/project-092/war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..fbbf307
--- /dev/null
+++ b/src/test/resources/projects/project-092/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>