maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1481652 - in /maven/plugins/trunk/maven-shade-plugin/src: it/MSHADE-133/ it/MSHADE-133/src/ it/MSHADE-133/src/main/ it/MSHADE-133/src/main/resources/ main/java/org/apache/maven/plugins/shade/resource/ site/apt/examples/
Date Sun, 12 May 2013 21:28:46 GMT
Author: rfscholte
Date: Sun May 12 21:28:46 2013
New Revision: 1481652

URL: http://svn.apache.org/r1481652
Log:
[MSHADE-133] DontIncludeResourceTransformer only recognizes a single resource element 

Added:
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/logback.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/myConfig.yml
    maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/verify.groovy
Modified:
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java
    maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples/resource-transformers.apt.vm

Added: maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/pom.xml?rev=1481652&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/pom.xml Sun May 12 21:28:46 2013
@@ -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 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.shade</groupId>
+  <artifactId>MSHADE-133</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>shade</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers>
+                <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
+                  <resources>
+                    <resource>myConfig.yml</resource>
+                    <resource>logback.xml</resource>
+                  </resources>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/logback.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/logback.xml?rev=1481652&view=auto
==============================================================================
    (empty)

Added: maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/myConfig.yml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/src/main/resources/myConfig.yml?rev=1481652&view=auto
==============================================================================
    (empty)

Added: maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/verify.groovy?rev=1481652&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/verify.groovy (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-133/verify.groovy Sun May 12 21:28:46
2013
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+ def jarFile = new java.util.jar.JarFile( new File( basedir, "/target/MSHADE-133-1.0-SNAPSHOT.jar"
) )
+ assert jarFile.getJarEntry("myComfig.yml") == null
+ assert jarFile.getJarEntry("logback.xml") == null
+ 
\ No newline at end of file

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java?rev=1481652&r1=1481651&r2=1481652&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java
(original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/DontIncludeResourceTransformer.java
Sun May 12 21:28:46 2013
@@ -20,6 +20,7 @@ package org.apache.maven.plugins.shade.r
  */
 
 import org.apache.maven.plugins.shade.relocation.Relocator;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -34,13 +35,26 @@ public class DontIncludeResourceTransfor
     implements ResourceTransformer
 {
     String resource;
+    
+    List<String> resources;
 
     public boolean canTransformResource( String r )
     {
-        if ( r.endsWith( resource ) )
+        if ( StringUtils.isNotEmpty( resource ) && r.endsWith( resource ) )
         {
             return true;
         }
+        
+        if( resources != null )
+        {
+            for( String resourceEnd : resources )
+            {
+                if( r.endsWith( resourceEnd ) )
+                {
+                    return true;
+                }
+            }
+        }
 
         return false;
     }

Modified: maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples/resource-transformers.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples/resource-transformers.apt.vm?rev=1481652&r1=1481651&r2=1481652&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples/resource-transformers.apt.vm
(original)
+++ maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples/resource-transformers.apt.vm
Sun May 12 21:28:46 2013
@@ -280,7 +280,20 @@ Transformers in <<<org.apache.maven.plug
   </build>
   ...
 </project>
-+----- 
++-----
+
+  Since maven-shade-plugin-3.0 it is also possible to give a list of resources which should
not be included, like: 
+
++-----
+<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
+  <resources>
+    <resource>.txt</resource>
+    <resource>READ.me</resource>
+  </resources>
+</transformer>
++-----
+
+
 
 * Adding New Resources with the {IncludeResourceTransformer}
 



Mime
View raw message