maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1211419 - in /maven/plugins/trunk/maven-ear-plugin/src: it/packaging-excludes/ it/packaging-includes/ main/java/org/apache/maven/plugin/ear/
Date Wed, 07 Dec 2011 12:59:35 GMT
Author: dennisl
Date: Wed Dec  7 12:59:34 2011
New Revision: 1211419

URL: http://svn.apache.org/viewvc?rev=1211419&view=rev
Log:
[MEAR-87] Allow exclusion of artifacts when building the ear file

Added:
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml   (with props)
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh   (with props)
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml   (with props)
    maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh   (with props)
Modified:
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java

Added: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml?rev=1211419&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml Wed Dec  7 12:59:34
2011
@@ -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.packagingexcludes</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>ear</packaging>
+
+  <name>Maven EAR Plugin Integration Test :: packaging excludes</name> 
+  <description>Test EAR generation using packaging excludes</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.5</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <packagingExcludes>commons-lang-*.jar</packagingExcludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh?rev=1211419&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh Wed Dec  7 12:59:34
2011
@@ -0,0 +1,42 @@
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+File jarFile = new File( basedir, "target/test-1.0.ear" );
+System.out.println( "Checking for existence of " + jarFile );
+if ( !jarFile.isFile() )
+{
+    throw new IllegalStateException( "Missing file: " + jarFile );
+}
+
+JarFile jar = new JarFile( jarFile );
+
+String[] includedEntries = {
+    "META-INF/application.xml",
+    "META-INF/MANIFEST.MF"
+};
+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 );
+    }
+}
+
+String[] excludedEntries = {
+    "commons-lang-2.5.jar"
+};
+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
);
+    }
+}
+
+jar.close();
+
+return true;

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-excludes/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml?rev=1211419&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml Wed Dec  7 12:59:34
2011
@@ -0,0 +1,58 @@
+<?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.packagingincludes</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>ear</packaging>
+
+  <name>Maven EAR Plugin Integration Test :: packaging includes</name>
+  <description>Test EAR generation using packaging includes</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.4</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.5</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <packagingIncludes>commons-lang-*.jar,META-INF/**</packagingIncludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh?rev=1211419&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh Wed Dec  7 12:59:34
2011
@@ -0,0 +1,43 @@
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+File jarFile = new File( basedir, "target/test-1.0.ear" );
+System.out.println( "Checking for existence of " + jarFile );
+if ( !jarFile.isFile() )
+{
+    throw new IllegalStateException( "Missing file: " + jarFile );
+}
+
+JarFile jar = new JarFile( jarFile );
+
+String[] includedEntries = {
+    "commons-lang-2.5.jar",
+    "META-INF/application.xml",
+    "META-INF/MANIFEST.MF"
+};
+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 );
+    }
+}
+
+String[] excludedEntries = {
+    "commons-io-1.4.jar"
+};
+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
);
+    }
+}
+
+jar.close();
+
+return true;

Propchange: maven/plugins/trunk/maven-ear-plugin/src/it/packaging-includes/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?rev=1211419&r1=1211418&r2=1211419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
(original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
Wed Dec  7 12:59:34 2011
@@ -187,6 +187,29 @@ public class EarMojo
     private String classifier;
 
     /**
+     * A comma separated list of tokens to exclude when packaging the EAR.
+     * By default nothing is excluded. Note that you can use the Java Regular
+     * Expressions engine to include and exclude specific pattern using the
+     * expression %regex[].
+     * Hint: read the about (?!Pattern).
+     *
+     * @parameter
+     * @since 2.7
+     */
+    private String packagingExcludes;
+
+    /**
+     * A comma separated list of tokens to include when packaging the EAR.
+     * By default everything is included. Note that you can use the Java Regular
+     * Expressions engine to include and exclude specific pattern using the
+     * expression %regex[].
+     *
+     * @parameter
+     * @since 2.7
+     */
+    private String packagingIncludes;
+
+    /**
      * The directory to get the resources from.
      *
      * @parameter
@@ -447,7 +470,12 @@ public class EarMojo
             // Include custom manifest if necessary
             includeCustomManifestFile();
 
-            archiver.getArchiver().addDirectory( getWorkDirectory() );
+            getLog().debug(
+                "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from the generated
EAR." );
+            getLog().debug(
+                "Including " + Arrays.asList( getPackagingIncludes() ) + " in the generated
EAR." );
+
+            archiver.getArchiver().addDirectory( getWorkDirectory(), getPackagingIncludes(),
getPackagingExcludes() );
             archiver.createArchive( getProject(), archive );
 
             if ( classifier != null )
@@ -509,6 +537,40 @@ public class EarMojo
         return StringUtils.split( StringUtils.defaultString( earSourceIncludes ), "," );
     }
 
+    public String[] getPackagingExcludes()
+    {
+        if ( StringUtils.isEmpty( packagingExcludes ) )
+        {
+            return new String[0];
+        }
+        else
+        {
+            return StringUtils.split( packagingExcludes, "," );
+        }
+    }
+
+    public void setPackagingExcludes( String packagingExcludes )
+    {
+        this.packagingExcludes = packagingExcludes;
+    }
+
+    public String[] getPackagingIncludes()
+    {
+        if ( StringUtils.isEmpty( packagingIncludes ) )
+        {
+            return new String[]{"**"};
+        }
+        else
+        {
+            return StringUtils.split( packagingIncludes, "," );
+        }
+    }
+
+    public void setPackagingIncludes( String packagingIncludes )
+    {
+        this.packagingIncludes = packagingIncludes;
+    }
+
     private static File buildDestinationFile( File buildDir, String uri )
     {
         return new File( buildDir, uri );



Mime
View raw message