maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r574111 [3/3] - in /maven/sandbox/trunk/plugins: ./ maven-shade-plugin/ maven-shade-plugin/src/ maven-shade-plugin/src/main/ maven-shade-plugin/src/main/java/ maven-shade-plugin/src/main/java/org/ maven-shade-plugin/src/main/java/org/apache...
Date Mon, 10 Sep 2007 01:06:23 GMT
Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/PomWriter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/PomWriter.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/PomWriter.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/PomWriter.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.pom;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.maven.model.Model;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.jdom.output.Format;
+
+/** @author Jason van Zyl */
+public class PomWriter
+{
+    public static void write( Writer w,
+                              Model newModel )
+        throws IOException
+        {
+        write( w, newModel, false );
+    }
+
+    public static void write( Writer w,
+                              Model newModel,
+                              boolean namespaceDeclaration )
+        throws IOException
+    {
+        Element root = new Element( "project" );
+
+        if ( namespaceDeclaration )
+        {
+            String modelVersion = newModel.getModelVersion();
+
+            Namespace pomNamespace = Namespace.getNamespace( "", "http://maven.apache.org/POM/" + modelVersion );
+
+            root.setNamespace( pomNamespace );
+
+            Namespace xsiNamespace = Namespace.getNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
+
+            root.addNamespaceDeclaration( xsiNamespace );
+
+            if ( root.getAttribute( "schemaLocation", xsiNamespace ) == null )
+            {
+                root.setAttribute( "schemaLocation", "http://maven.apache.org/POM/" + modelVersion +
+                    " http://maven.apache.org/maven-v" + modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
+            }
+        }
+
+        Document doc = new Document( root );
+
+        MavenJDOMWriter writer = new MavenJDOMWriter();
+
+        String encoding = newModel.getModelEncoding() != null ? newModel.getModelEncoding() : "UTF-8";
+
+        Format format = Format.getPrettyFormat().setEncoding( encoding );
+
+        writer.write( newModel, doc, w, format );
+    }    
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/Relocator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/Relocator.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/Relocator.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/Relocator.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.relocation;
+
+/** @author Jason van Zyl */
+public interface Relocator
+{
+    String ROLE = Relocator.class.getName();
+
+    boolean canRelocate( String clazz );
+
+    String relocate( String clazz );
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.relocation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/** @author Jason van Zyl */
+public class SimpleRelocator
+    implements Relocator
+{
+    private String pattern;
+
+    private List excludes;
+
+    public SimpleRelocator( String pattern,
+                            List excludes )
+    {
+        this.pattern = pattern.replace( '.', '/' );
+
+        if ( excludes != null )
+        {
+            this.excludes = new ArrayList();
+
+            for ( Iterator i = excludes.iterator(); i.hasNext(); )
+            {
+                String e = (String) i.next();
+
+                this.excludes.add( e.replace( '.', '/' ) );
+            }
+        }
+    }
+
+    public boolean canRelocate( String clazz )
+    {
+        if ( excludes != null )
+        {
+            for ( Iterator i = excludes.iterator(); i.hasNext(); )
+            {
+                String exclude = (String) i.next();
+
+                // Remember we have converted "." -> "/" in the constructor. So ".*" is really "/*"
+                if ( exclude.endsWith( "/*" ) && clazz.startsWith( exclude.substring( 0, exclude.length() - 2 ) ) )
+                {
+                    return false;
+                }
+                else if ( clazz.equals( exclude ) )
+                {
+                    return false;
+                }
+            }
+        }
+
+        return clazz.startsWith( pattern );
+    }
+
+    public String relocate( String clazz )
+    {
+        return "hidden/" + clazz;
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+
+/**
+ * Prevents duplicate copies of the license
+ *
+ */
+public class ApacheLicenseResourceTransformer
+    implements ResourceTransformer
+{
+    Set entries = new HashSet();
+    
+    public boolean canTransformResource( String resource )
+    {
+        String s = resource.toLowerCase();
+
+        if ( s.startsWith( "meta-inf/license.txt" ) || s.equals( "meta-inf/license" ))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void processResource( InputStream is )
+        throws IOException
+    {
+       
+    }
+
+    public boolean hasTransformedResource()
+    {
+        return false;
+    }
+
+    public void modifyOutputStream( JarOutputStream os )
+        throws IOException
+    {
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+public class ApacheNoticeResourceTransformer
+    implements ResourceTransformer
+{
+    Set entries = new HashSet();
+    String projectName;
+    
+    String preamble1 = 
+          "// ------------------------------------------------------------------\n"
+        + "// NOTICE file corresponding to the section 4d of The Apache License,\n"
+        + "// Version 2.0, in this case for ";
+    
+    String preamble2 = "\n// ------------------------------------------------------------------\n\n";
+        
+    String preamble3 = "This product includes software developed at\n" +
+        "Apache Software Foundation (http://www.apache.org/).\n";
+
+    String copyright;
+    
+    public boolean canTransformResource( String resource )
+    {
+        String s = resource.toLowerCase();
+
+        if (s.equals( "meta-inf/notice.txt" ) || s.equals( "meta-inf/notice" ) )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void processResource( InputStream is )
+        throws IOException
+    {
+        copyright = projectName + "\nCopyright 2006-2007 Apache Software Foundation\n";
+        
+        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+        
+        String line = reader.readLine();
+        StringBuffer sb = new StringBuffer();
+        while (line != null) {
+            line = line.trim();
+            
+            if (!line.startsWith("//")) {
+                if (line.length() > 0) {
+                    sb.append(line).append("\n");
+                } else {
+                    entries.add(sb.toString());
+                    sb = new StringBuffer();
+                }
+            }
+            
+            line = reader.readLine();
+        }
+        
+        entries.remove(preamble3);
+        entries.remove(copyright);
+    }
+
+    public boolean hasTransformedResource()
+    {
+        return true;
+    }
+
+    public void modifyOutputStream( JarOutputStream jos )
+        throws IOException
+    {
+        jos.putNextEntry( new JarEntry( "META-INF/NOTICE" ) );
+        
+        OutputStreamWriter writer = new OutputStreamWriter(jos);
+        writer.write(preamble1);
+        writer.write(projectName);
+        writer.write(preamble2);
+        
+        writer.write(copyright);
+        writer.write("\n");
+        
+        writer.write(preamble3);
+        writer.write("\n");
+        
+        for (Iterator itr = entries.iterator(); itr.hasNext();) {
+            String line = (String) itr.next();
+            writer.append(line);
+            writer.append('\n');
+        }
+        
+        writer.flush();
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.codehaus.plexus.util.IOUtil;
+
+public class AppendingTransformer
+    implements ResourceTransformer
+{
+    String resource;
+    ByteArrayOutputStream data = new ByteArrayOutputStream();
+    
+    public boolean canTransformResource( String r )
+    {
+        r = r.toLowerCase();
+
+        if (resource != null && resource.toLowerCase().equals(r))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void processResource( InputStream is )
+        throws IOException
+    {
+        IOUtil.copy(is, data);
+        data.write('\n');
+        
+        is.close();
+    }
+
+    public boolean hasTransformedResource()
+    {
+        return true;
+    }
+
+    public void modifyOutputStream( JarOutputStream jos )
+        throws IOException
+    {
+        jos.putNextEntry( new JarEntry( resource ) );
+        
+        IOUtil.copy(new ByteArrayInputStream(data.toByteArray()), jos);
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
+
+// 1. We want to process all resources that are common in all the JARs that we are processing.
+// 2. At the end of processing we want to hand back the transformation of the resources.
+
+// In my particular case I want to grab all the plexus components.xml files and aggregate them
+// and then stick them in one place in the aggregated JAR.
+
+public class ComponentsXmlResourceTransformer
+    implements ResourceTransformer
+{
+    private Map components = new LinkedHashMap();
+
+    public static final String COMPONENTS_XML_PATH = "META-INF/plexus/components.xml";
+
+    public boolean canTransformResource( String resource )
+    {
+        return COMPONENTS_XML_PATH.equals( resource );
+    }
+
+    public void processResource( InputStream is )
+        throws IOException
+    {
+        // We can't just read the stream because the plexus dom builder closes the stream
+
+        File f = File.createTempFile( "maven-shade-plugin", "tmp" );
+
+        f.deleteOnExit();
+        
+        String n = f.getAbsolutePath();
+
+        OutputStream os = new FileOutputStream( f );
+
+        IOUtil.copy( is, os );
+
+        os.close();
+
+        //
+
+        Reader reader;
+
+        Xpp3Dom newDom;
+
+        try
+        {
+            reader = new FileReader( n );
+
+            newDom = Xpp3DomBuilder.build( reader );
+        }
+        catch ( Exception e )
+        {
+            throw new IOException( "Error parsing components.xml in " + is );
+        }
+
+        Xpp3Dom[] children = newDom.getChild( "components" ).getChildren( "component" );
+
+        for ( int i = 0; i < children.length; i++ )
+        {
+            Xpp3Dom component = children[i];
+
+            String role = component.getChild( "role" ).getValue();
+
+            Xpp3Dom child = component.getChild( "role-hint" );
+
+            String roleHint = child != null ? child.getValue() : "";
+
+            components.put( role + roleHint, component );
+        }
+    }
+
+    public void modifyOutputStream( JarOutputStream jos )
+        throws IOException
+    {
+        Reader reader = new FileReader( getTransformedResource() );
+
+        jos.putNextEntry( new JarEntry( COMPONENTS_XML_PATH ) );
+
+        IOUtil.copy( reader, jos );
+
+        reader.close();
+    }
+
+    public boolean hasTransformedResource()
+    {
+        return components.size() > 0;
+    }
+
+    public File getTransformedResource()
+        throws IOException
+    {
+        File f = File.createTempFile( "shade-maven-plugin-plx", "tmp" );
+
+        f.deleteOnExit();
+
+        FileWriter fileWriter = new FileWriter( f );
+        try
+        {
+            Xpp3Dom dom = new Xpp3Dom( "component-set" );
+
+            Xpp3Dom componentDom = new Xpp3Dom( "components" );
+
+            dom.addChild( componentDom );
+
+            for ( Iterator i = components.values().iterator(); i.hasNext(); )
+            {
+                Xpp3Dom component = (Xpp3Dom) i.next();
+                componentDom.addChild( component );
+            }
+
+            Xpp3DomWriter.write( fileWriter, dom );
+        }
+        finally
+        {
+            IOUtil.close( fileWriter );
+        }
+
+        return f;
+    }
+
+
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarOutputStream;
+
+/** @author Jason van Zyl */
+public interface ResourceTransformer
+{
+    boolean canTransformResource( String resource );
+
+    void processResource( InputStream is )
+        throws IOException;
+    
+    boolean hasTransformedResource();
+
+    void modifyOutputStream( JarOutputStream os )
+        throws IOException;
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.jdom.Attribute;
+import org.jdom.Content;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
+public class XmlAppendingTransformer
+    implements ResourceTransformer
+{
+    public static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
+    
+    String resource;
+    Document doc;
+    
+    public boolean canTransformResource( String r )
+    {
+        r = r.toLowerCase();
+
+        if (resource != null && resource.toLowerCase().equals(r))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void processResource( InputStream is )
+        throws IOException
+    {
+        Document r;
+        try 
+        {
+            r = new SAXBuilder().build(is);
+        } 
+        catch (JDOMException e) 
+        {
+            throw new RuntimeException(e);
+        }
+        
+        if (doc == null) 
+        {
+            doc = r;
+        } 
+        else 
+        {
+            Element root = r.getRootElement();
+            
+            for (Iterator itr = root.getAttributes().iterator(); itr.hasNext();)
+            {
+                Attribute a = (Attribute) itr.next();
+                itr.remove();
+                
+                Element mergedEl = doc.getRootElement();
+                Attribute mergedAtt = mergedEl.getAttribute(a.getName(), a.getNamespace());
+                if (mergedAtt == null) 
+                {
+                    mergedEl.setAttribute(a);
+                }
+            }
+            
+            for (Iterator itr = root.getChildren().iterator(); itr.hasNext();)
+            {
+                Content n = (Content) itr.next();
+                itr.remove();
+                
+                doc.getRootElement().addContent(n);
+            }
+        }
+    }
+
+    public boolean hasTransformedResource()
+    {
+        return true;
+    }
+
+    public void modifyOutputStream( JarOutputStream jos )
+        throws IOException
+    {
+        jos.putNextEntry( new JarEntry( resource ) );
+        
+        new XMLOutputter(Format.getPrettyFormat()).output(doc, jos);
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/plexus-utils-1.4.1.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/plexus-utils-1.4.1.jar?rev=574111&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/plexus-utils-1.4.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/test-project-1.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/test-project-1.0-SNAPSHOT.jar?rev=574111&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/jars/test-project-1.0-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/ShadeMojoTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/ShadeMojoTest.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/ShadeMojoTest.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/ShadeMojoTest.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugins.shade;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.plugins.shade.Shader;
+import org.apache.maven.plugins.shade.relocation.SimpleRelocator;
+import org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer;
+import org.codehaus.plexus.PlexusTestCase;
+
+
+/** @author Jason van Zyl */
+public class ShadeMojoTest
+    extends PlexusTestCase
+{
+    public void testShader()
+        throws Exception
+    {
+        Shader s = (Shader) lookup( Shader.ROLE );
+
+        Set set = new HashSet();
+
+        set.add( new File( getBasedir(), "src/test/jars/test-project-1.0-SNAPSHOT.jar" ) );
+
+        set.add( new File( getBasedir(), "src/test/jars/plexus-utils-1.4.1.jar" ) );
+
+        File jar = new File( "target/foo.jar" );
+
+        List relocators = new ArrayList();
+
+        relocators.add( new SimpleRelocator( "org/codehaus/plexus/util", Arrays.asList(
+            new String[]{"org/codehaus/plexus/util/xml/Xpp3Dom", "org/codehaus/plexus/util/xml/pull.*"} ) ) );
+
+        List resourceTransformers = new ArrayList();
+
+        resourceTransformers.add( new ComponentsXmlResourceTransformer() );
+
+        s.shade( set, jar, relocators, resourceTransformers );
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/default-config-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/default-config-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/default-config-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/default-config-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,55 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>default-config-project</artifactId>
+  <name>default-config-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.shade</groupId>
+      <artifactId>test-project</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/no-relocation-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/no-relocation-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/no-relocation-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/no-relocation-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,66 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>no-relocation-project</artifactId>
+  <name>no-relocation-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.shade</groupId>
+      <artifactId>test-project</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <artifactSet>
+                <excludes>
+                  <exclude>classworlds:classworlds</exclude>
+                  <exclude>junit:junit</exclude>
+                  <exclude>jmock:jmock</exclude>
+                  <exclude>xml-apis:xml-apis</exclude>
+                </excludes>
+              </artifactSet>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/pom.xml Sun Sep  9 18:06:19 2007
@@ -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 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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>projects-parent</artifactId>
+  <name>projects-parent</name>
+  <packaging>pom</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <modules>
+    <module>test-project</module>
+    <module>no-relocation-project</module>
+    <module>shaded-project</module>
+    <module>shaded-renamed-project</module>
+    <module>shaded-attached-project</module>
+  </modules>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-attached-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-attached-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-attached-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-attached-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,78 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>shaded-attached-project</artifactId>
+  <name>shaded-attached-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+   <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.shade</groupId>
+      <artifactId>test-project</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedArtifactId>shaded-artifact</shadedArtifactId>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
+              <shadedClassifierName>jackofall</shadedClassifierName> <!-- Any name that makes sense -->
+              <artifactSet>
+                <excludes>
+                  <exclude>classworlds:classworlds</exclude>
+                  <exclude>junit:junit</exclude>
+                  <exclude>jmock:jmock</exclude>
+                  <exclude>xml-apis:xml-apis</exclude>
+                </excludes>
+              </artifactSet>
+              <relocations>
+                <relocation>
+                  <pattern>org.codehaus.plexus.util</pattern>
+                  <excludes>
+                    <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
+                    <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
+                  </excludes>
+                </relocation>
+              </relocations>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,75 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>shaded-project</artifactId>
+  <name>shaded-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.shade</groupId>
+      <artifactId>test-project</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <artifactSet>
+                <excludes>
+                  <exclude>classworlds:classworlds</exclude>
+                  <exclude>junit:junit</exclude>
+                  <exclude>jmock:jmock</exclude>
+                  <exclude>xml-apis:xml-apis</exclude>
+                </excludes>
+              </artifactSet>
+              <relocations>
+                <relocation>
+                  <pattern>org.codehaus.plexus.util</pattern>
+                  <excludes>
+                    <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
+                    <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
+                  </excludes>
+                </relocation>
+              </relocations>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-renamed-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-renamed-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-renamed-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/shaded-renamed-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,73 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>shaded-renamed-project</artifactId>
+  <name>shaded-renamed-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+   <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.shade</groupId>
+      <artifactId>test-project</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedArtifactId>renamed-artifact</shadedArtifactId>
+              <artifactSet>
+                <excludes>
+                  <exclude>classworlds:classworlds</exclude>
+                  <exclude>junit:junit</exclude>
+                  <exclude>jmock:jmock</exclude>
+                  <exclude>xml-apis:xml-apis</exclude>
+                </excludes>
+              </artifactSet>
+              <relocations>
+                <relocation>
+                  <pattern>org.codehaus.plexus.util</pattern>
+                  <excludes>
+                    <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
+                    <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
+                  </excludes>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/pom.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/pom.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/pom.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,43 @@
+<?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>org.apache.maven.plugins.shade</groupId>
+  <artifactId>test-project</artifactId>
+  <name>test-project</name>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.4.1</version>
+    </dependency>  
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/java/org/apache/maven/plugins/shade/App.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/java/org/apache/maven/plugins/shade/App.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/java/org/apache/maven/plugins/shade/App.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/java/org/apache/maven/plugins/shade/App.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.shade;
+
+import org.codehaus.plexus.util.*;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+
+        StringUtils.isEmpty( "foo" );
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/resources/META-INF/plexus/components.xml?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/main/resources/META-INF/plexus/components.xml Sun Sep  9 18:06:19 2007
@@ -0,0 +1,209 @@
+<!--
+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.
+-->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
+      <role-hint>legacy</role-hint>
+      <implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
+    </component>
+
+    <!--
+     |
+     | ArtifactHandlerManager
+     |
+     -->
+    <component>
+      <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
+      <implementation>org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+          <field-name>artifactHandlers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>ejb</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>ejb</type>
+        <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>jar</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>jar</type>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>test-jar</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <classifier>tests</classifier>
+        <extension>jar</extension>
+        <type>test-jar</type>
+        <packaging>jar</packaging>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>maven-plugin</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>maven-plugin</type>
+        <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>pom</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>pom</type>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>java-source</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <classifier>sources</classifier>
+        <type>java-source</type>
+        <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>javadoc</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <classifier>javadoc</classifier>
+        <type>javadoc</type>
+        <extension>jar</extension>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>war</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>war</type>
+        <includesDependencies>true</includesDependencies>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>ear</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>ear</type>
+        <includesDependencies>true</includesDependencies>
+        <language>java</language>
+        <addedToClasspath>false</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>ejb-client</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>ejb-client</type>
+        <extension>jar</extension>
+        <packaging>ejb</packaging>
+        <classifier>client</classifier>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>par</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>par</type>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+      <role-hint>ejb3</role-hint>
+      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+      <configuration>
+        <type>ejb3</type>
+        <language>java</language>
+        <addedToClasspath>true</addedToClasspath>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+      <implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
+      <implementation>org.apache.maven.artifact.resolver.DefaultArtifactCollector</implementation>
+    </component>
+  </components>
+</component-set>

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/test/java/org/apache/maven/plugins/shade/AppTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/test/java/org/apache/maven/plugins/shade/AppTest.java?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/test/java/org/apache/maven/plugins/shade/AppTest.java (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/src/test/projects/test-project/src/test/java/org/apache/maven/plugins/shade/AppTest.java Sun Sep  9 18:06:19 2007
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.shade;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Added: maven/sandbox/trunk/plugins/maven-shade-plugin/static-remapper.txt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-shade-plugin/static-remapper.txt?rev=574111&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-shade-plugin/static-remapper.txt (added)
+++ maven/sandbox/trunk/plugins/maven-shade-plugin/static-remapper.txt Sun Sep  9 18:06:19 2007
@@ -0,0 +1,62 @@
+    /*
+    ClassVisitor cv = null;
+    Remapper remapper = null;
+
+    RemappingClassAdapter a = new RemappingClassAdapter( cv, remapper )
+    {
+        protected MethodVisitor createRemappingMethodAdapter( int access,
+                                                              String newDesc,
+                                                              MethodVisitor mv )
+        {
+            final MethodVisitor rmv = super.createRemappingMethodAdapter( access, newDesc, mv );
+            return new MethodNode()
+            {
+                public void visitEnd()
+                {
+                    Analyzer an = new Analyzer( new SourceInterpreter() );
+                    try
+                    {
+                        Frame[] frames = an.analyze( className, this );
+                        // Elements of the frames array now contains info for each instruction
+                        // from the analyzed method.
+                        for ( int i = 0; i < frames.length; i++ )
+                        {
+                            Frame frame = frames[i];
+                            AbstractInsnNode insn = instructions.get( i );
+                            if ( insn.getOpcode() == Opcodes.INVOKEVIRTUAL )
+                            {
+                                MethodInsnNode minsn = (MethodInsnNode) insn;
+                                if ( minsn.name.equals( "getResource" ) && minsn.owner.equals( "java/lang/Class" ) )
+                                {
+                                    // now check where params come from (top of the stack)
+                                    SourceValue value = (SourceValue) frames[i].getStack( 0 );
+                                    Set sources = value.insns;  // instructions that produced this value
+                                    for ( Iterator it = sources.iterator(); it.hasNext(); )
+                                    {
+                                        AbstractInsnNode source = (AbstractInsnNode) it.next();
+                                        if ( source.getOpcode() == Opcodes.LDC )
+                                        {
+                                            LdcInsnNode constant = (LdcInsnNode) source;
+                                            // can change constant.cst value here
+                                        }
+                                        else
+                                        {
+                                            // can log something about value that came not from the constant
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        // got your mapping. can remap now. replaying recorded method
+                        accept( rmv );
+                    }
+                    catch ( AnalyzerException ex )
+                    {
+                        // TODO Auto-generated catch block
+                        ex.printStackTrace();
+                    }
+                }
+            };
+        }
+    };
+    */
\ No newline at end of file

Modified: maven/sandbox/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/pom.xml?rev=574111&r1=574110&r2=574111&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/pom.xml (original)
+++ maven/sandbox/trunk/plugins/pom.xml Sun Sep  9 18:06:19 2007
@@ -17,7 +17,7 @@
     <module>maven-plugin-management-plugin</module>
     <module>maven-plug-it-plugin</module>
     <module>maven-swizzle-plugin</module>
-    <module>maven-enforcer-plugin</module>
+    <module>maven-shade-plugin</module>
     <module>maven-committers-plugin</module>
   </modules>
 



Mime
View raw message