Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/it/skinny-wars-javaee5/ear-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,28 @@ under the License.
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Comment thread
mabrarov marked this conversation as resolved.
<version>2.5</version>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module1</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module2</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module</artifactId>
<artifactId>war-module3</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
Expand Down
23 changes: 21 additions & 2 deletions src/it/skinny-wars-javaee5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,26 @@ under the License.
<description>Test Skinny WAR generation</description>

<modules>
<module>ear-module</module>
<module>war-module</module>
<module>ear-module</module>
<module>war-module1</module>
<module>war-module2</module>
<module>war-module3</module>
</modules>

<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-ear-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
153 changes: 104 additions & 49 deletions src/it/skinny-wars-javaee5/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,128 @@ 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() )
assertJar( String fileName, String[] includedEntries, String[] excludedEntries, boolean assertManifest,
String[] expectedClassPathElements )
{
throw new IllegalStateException( "Missing file: " + jarFile );
}
File jarFile = new File( basedir, fileName );
System.out.println( "Checking for existence of " + jarFile );
if ( !jarFile.isFile() )
{
throw new IllegalStateException( "Missing file: " + jarFile );
}

JarFile jar = new JarFile( 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 )
if ( includedEntries != null )
{
throw new IllegalStateException( "Missing archive entry: " + included );
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 + ". Artifact: " + fileName );
}
}
}
}

Manifest manifest = jar.getManifest();
String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path");
if ( manifestClassPath != null && manifestClassPath.equals("lib/commons-lang-commons-lang-2.5.jar") )
{
throw new IllegalStateException( "Superfluous entry in war MANIFEST.MF: commons-lang-commons-lang-2.5.jar");
}
if ( excludedEntries != null )
{
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
+ ". Artifact: " + fileName );
}
}
}

String[] excludedEntries = {
"WEB-INF/lib/commons-lang-2.5.jar"
};
for ( String excluded : excludedEntries )
{
System.out.println( "Checking for excluded artifact " + excluded );
if ( jar.getEntry( excluded ) != null )
if ( assertManifest )
{
throw new IllegalStateException( "Archive entry should be excluded: " + excluded );
Manifest manifest = jar.getManifest();
String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path");
if ( expectedClassPathElements == null)
{
if ( manifestClassPath != null )
{
throw new IllegalStateException( "Superfluous Class-Path entry in MANIFEST.MF of artifact: "
+ fileName );
}
}
else
{
if ( manifestClassPath == null )
{
throw new IllegalStateException( "Missing Class-Path entry in MANIFEST.MF of artifact: "
+ fileName );
}
manifestClassPath = manifestClassPath.trim();
String[] actualClassPathElements = manifestClassPath.length() == 0 ?
new String[0] : manifestClassPath.split( " " );
if ( !Arrays.equals( expectedClassPathElements, actualClassPathElements ) )
{
throw new IllegalStateException( "Invalid Class-Path entry in MANIFEST.MF of artifact: "
+ fileName
+ ". Expected: " + Arrays.toString( expectedClassPathElements )
+ ". Actual: " + Arrays.toString( actualClassPathElements ) );
}
}
}
}

jar.close();
String[] includedEntries = {
"WEB-INF/web.xml",
"META-INF/MANIFEST.MF",
"WEB-INF/lib/commons-lang-2.6.jar"
};

String[] excludedEntries = {};

File jarFile = new File( basedir, "war-module/target/war-module-1.0.war" );
System.out.println( "Checking for existence of " + jarFile );
if ( !jarFile.isFile() )
{
throw new IllegalStateException( "Missing file: " + jarFile );
}
String[] expectedClassPathElements = { "commons-lang-2.6.jar" };

JarFile jar = new JarFile( jarFile );
assertJar( "war-module1/target/war-module1-1.0.war", includedEntries, excludedEntries, true,
expectedClassPathElements );

String[] includedEntries = {
assertJar( "war-module2/target/war-module2-1.0.war", includedEntries, excludedEntries, true, null );

String[] warModule3IncludedEntries = {
"WEB-INF/web.xml",
"META-INF/MANIFEST.MF",
"WEB-INF/lib/commons-lang-2.5.jar"
"WEB-INF/lib/commons-io-2.6.jar"
};
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 );
}
}

jar.close();
String[] warModuleExcludedEntries = {
"WEB-INF/lib/commons-lang-2.6.jar",
"WEB-INF/lib/commons-collections4-4.2.jar"
};

String[] warModule3ExpectedClassPathElements = { "commons-io-2.6.jar" };

assertJar( "war-module3/target/war-module3-1.0.war", warModule3IncludedEntries, warModuleExcludedEntries, true,
warModule3ExpectedClassPathElements );

String earBaseDir = "ear-module/target/ear-module-1.0/";
String earLibDir = earBaseDir + "lib/";

assertJar( earLibDir + "commons-lang-commons-lang-2.6.jar", null, null, false, null );

assertJar( earLibDir + "org.apache.commons-commons-collections4-4.2.jar", null, null, false, null );

String[] includedEntries = {
"WEB-INF/web.xml",
"META-INF/MANIFEST.MF"
};

String[] warModule1ExpectedClassPathElements = { "lib/commons-lang-commons-lang-2.6.jar" };

assertJar( earBaseDir + "org.apache.maven.its.ear.skinnywars-war-module1-1.0.war", includedEntries,
warModuleExcludedEntries, true, warModule1ExpectedClassPathElements );

assertJar( earBaseDir + "org.apache.maven.its.ear.skinnywars-war-module2-1.0.war", includedEntries,
warModuleExcludedEntries, true, null );

assertJar( earBaseDir + "org.apache.maven.its.ear.skinnywars-war-module3-1.0.war",
warModule3IncludedEntries, warModuleExcludedEntries, true, warModule3ExpectedClassPathElements );

return true;
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ under the License.
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module</artifactId>
<artifactId>war-module1</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
<version>2.6</version>
</dependency>
</dependencies>

Expand All @@ -40,7 +40,13 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>@mavenWarPluginVersion@</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
37 changes: 37 additions & 0 deletions src/it/skinny-wars-javaee5/war-module2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module2</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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.
-->
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app >
</web-app>
53 changes: 53 additions & 0 deletions src/it/skinny-wars-javaee5/war-module3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.ear.skinnywars</groupId>
<artifactId>war-module3</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading