You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/03/24 14:18:01 UTC

svn commit: r640405 [1/4] - in /maven/plugins/trunk/maven-shade-plugin: ./ src/main/java/org/apache/maven/plugins/shade/ src/main/java/org/apache/maven/plugins/shade/filter/ src/main/java/org/apache/maven/plugins/shade/mojo/ src/main/java/org/apache/ma...

Author: bentmann
Date: Mon Mar 24 06:17:58 2008
New Revision: 640405

URL: http://svn.apache.org/viewvc?rev=640405&view=rev
Log:
o Added svn:eol-style=native

Modified:
    maven/plugins/trunk/maven-shade-plugin/pom.xml   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/Filter.java   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ArtifactSet.java   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/MavenJDOMWriter.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/pom/PomWriter.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/Relocator.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheLicenseResourceTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ApacheNoticeResourceTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/AppendingTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/ResourceTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/resource/XmlAppendingTransformer.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/site/apt/examples.apt   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/site/apt/index.apt   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/site/apt/usage.apt   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/site/site.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/DefaultShaderTest.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/mojo/ShadeMojoTest.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/default-config-project/pom.xml   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/no-relocation-project/pom.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/pom.xml   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/shaded-attached-project/pom.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/shaded-project/pom.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/shaded-renamed-project/pom.xml   (props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/test-project/pom.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/test-project/src/main/java/org/apache/maven/plugins/shade/App.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/test-project/src/main/resources/META-INF/plexus/components.xml   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/src/test/projects/test-project/src/test/java/org/apache/maven/plugins/shade/AppTest.java   (contents, props changed)
    maven/plugins/trunk/maven-shade-plugin/static-remapper.txt   (contents, props changed)

Propchange: maven/plugins/trunk/maven-shade-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java Mon Mar 24 06:17:58 2008
@@ -1,320 +1,320 @@
-package org.apache.maven.plugins.shade;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.ArrayList;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.zip.ZipException;
-
-import org.apache.maven.plugins.shade.relocation.Relocator;
-import org.apache.maven.plugins.shade.resource.ResourceTransformer;
-import org.apache.maven.plugins.shade.filter.Filter;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.IOUtil;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.commons.Remapper;
-import org.objectweb.asm.commons.RemappingClassAdapter;
-
-/**
- * @author Jason van Zyl
- * @plexus.component
- */
-public class DefaultShader
-    extends AbstractLogEnabled
-    implements Shader
-{
-    public void shade( Set jars, File uberJar, List filters, List relocators, List resourceTransformers )
-    throws IOException
-    {
-        Set resources = new HashSet();
-
-        RelocatorRemapper remapper = new RelocatorRemapper( relocators );
-
-        JarOutputStream jos = new JarOutputStream( new FileOutputStream( uberJar ) );
-
-        for ( Iterator i = jars.iterator(); i.hasNext(); )
-        {
-            File jar = (File) i.next();
-
-            List jarFilters = getFilters( jar, filters );
-
-            JarFile jarFile = new JarFile( jar );
-
-            for ( Enumeration j = jarFile.entries(); j.hasMoreElements(); )
-            {
-                JarEntry entry = (JarEntry) j.nextElement();
-
-                String name = entry.getName();
-                if ( "META-INF/INDEX.LIST".equals( name ) ) 
-                {
-                    //we cannot allow the jar indexes to be copied over or the 
-                    //jar is useless.   Ideally, we could create a new one
-                    //later
-                    continue;
-                }
-
-                String mappedName = remapper.map( name );
-
-                InputStream is = jarFile.getInputStream( entry );
-                if ( !entry.isDirectory() && !isFiltered( jarFilters, name ) )
-                {
-                    int idx = mappedName.lastIndexOf('/');
-                    if ( idx != -1 )
-                    {
-                        //make sure dirs are created
-                        String dir = mappedName.substring(0, idx);
-                        if ( !resources.contains( dir ) )
-                        {
-                            addDirectory( resources, jos, dir );
-                        }
-                    }
-
-                    if ( name.endsWith( ".class" ) )
-                    {
-                        addRemappedClass( remapper, jos, jar, name, is );
-                    }
-                    else
-                    {
-                        if ( !resourceTransformed( resourceTransformers, mappedName, is ) )
-                        {
-                            // Avoid duplicates that aren't accounted for by the resource transformers
-                            if ( resources.contains( mappedName ) )
-                            {
-                                continue;
-                            }
-
-                            addResource( resources, jos, mappedName, is );
-                        }
-                    }
-                }
-
-                IOUtil.close( is );
-            }
-
-            jarFile.close();
-        }
-
-        for ( Iterator i = resourceTransformers.iterator(); i.hasNext(); )
-        {
-            ResourceTransformer transformer = (ResourceTransformer) i.next();
-
-            if ( transformer.hasTransformedResource() )
-            {
-                transformer.modifyOutputStream( jos );
-            }
-        }
-
-        IOUtil.close( jos );
-    }
-
-    private List getFilters(File jar, List filters)
-    {
-        List list = new ArrayList();
-
-        for ( int i = 0; i < filters.size(); i++ )
-        {
-            Filter filter = (Filter) filters.get( i );
-
-            if ( filter.canFilter( jar ) )
-            {
-                list.add( filter );
-            }
-
-        }
-
-        return list;
-    }
-
-    private void addDirectory( Set resources, JarOutputStream jos, String name )
-        throws IOException
-    {
-        if ( name.lastIndexOf( '/' ) > 0 )
-        {
-            String parent = name.substring( 0, name.lastIndexOf( '/' ) );
-            if ( !resources.contains( parent ) )
-            {
-                addDirectory( resources, jos, parent );
-            }
-        }
-
-        //directory entries must end in "/"
-        JarEntry entry = new JarEntry( name + "/" );
-        jos.putNextEntry( entry );
-
-        resources.add( name );
-    }
-
-    private void addRemappedClass( RelocatorRemapper remapper, JarOutputStream jos, File jar, String name, InputStream is )
-        throws IOException
-    {
-        if ( !remapper.hasRelocators() )
-        {
-            jos.putNextEntry( new JarEntry( name ) );
-
-            IOUtil.copy( is, jos );
-            return;
-        }
-
-        ClassReader cr = new ClassReader( is );
-
-        ClassWriter cw = new ClassWriter( cr, 0 );
-
-        ClassVisitor cv = new RemappingClassAdapter( cw, remapper );
-
-        cr.accept( cv, ClassReader.EXPAND_FRAMES );
-
-        byte[] renamedClass = cw.toByteArray();
-
-        // Need to take the .class off for remapping evaluation
-        String mappedName = remapper.map( name.substring( 0, name.indexOf( '.' ) ) );
-
-        try
-        {
-            // Now we put it back on so the class file is written out with the right extension.
-            jos.putNextEntry( new JarEntry( mappedName + ".class" ) );
-
-            IOUtil.copy( renamedClass, jos );
-        }
-        catch ( ZipException e )
-        {
-            getLogger().warn( "We have a duplicate " + mappedName + " in " + jar );
-        }
-    }
-
-    private boolean isFiltered( List filters, String name )
-    {
-        for ( int i = 0; i < filters.size(); i++ )
-        {
-            Filter filter = (Filter) filters.get( i );
-
-            if ( filter.isFiltered( name ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    private boolean resourceTransformed( List resourceTransformers, String name, InputStream is )
-        throws IOException
-    {
-        boolean resourceTransformed = false;
-
-        for ( Iterator k = resourceTransformers.iterator(); k.hasNext(); )
-        {
-            ResourceTransformer transformer = (ResourceTransformer) k.next();
-
-            if ( transformer.canTransformResource( name ) )
-            {
-                transformer.processResource( is );
-
-                resourceTransformed = true;
-
-                break;
-            }
-        }
-        return resourceTransformed;
-    }
-
-    private void addResource( Set resources, JarOutputStream jos, String name, InputStream is )
-        throws IOException
-    {
-        jos.putNextEntry( new JarEntry( name ) );
-
-        IOUtil.copy( is, jos );
-
-        resources.add( name );
-    }
-
-    class RelocatorRemapper
-        extends Remapper
-    {
-        List relocators;
-
-        public RelocatorRemapper( List relocators )
-        {
-            this.relocators = relocators;
-        }
-
-        public boolean hasRelocators()
-        {
-            return !relocators.isEmpty();
-        }
-
-        public Object mapValue( Object object )
-        {
-            if ( object instanceof String )
-            {
-                String name = (String) object;
-                String value = name;
-                for ( Iterator i = relocators.iterator(); i.hasNext(); )
-                {
-                    Relocator r = (Relocator) i.next();
-
-                    if ( r.canRelocatePath( name ) )
-                    {
-                        value = r.relocatePath( name );
-                        break;
-                    }
-
-                    if ( r.canRelocateClass( name ) )
-                    {
-                        value = r.relocateClass( name );
-                        break;
-                    }
-                }
-
-                return value;
-            }
-            return object;
-        }
-
-        public String map( String name )
-        {
-            String value = name;
-            for ( Iterator i = relocators.iterator(); i.hasNext(); )
-            {
-                Relocator r = (Relocator) i.next();
-
-                if ( r.canRelocatePath( name ) )
-                {
-                    value = r.relocatePath( name );
-                    break;
-                }
-            }
-
-            return value;
-        }
-    }
-}
+package org.apache.maven.plugins.shade;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.ArrayList;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipException;
+
+import org.apache.maven.plugins.shade.relocation.Relocator;
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+import org.apache.maven.plugins.shade.filter.Filter;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.commons.Remapper;
+import org.objectweb.asm.commons.RemappingClassAdapter;
+
+/**
+ * @author Jason van Zyl
+ * @plexus.component
+ */
+public class DefaultShader
+    extends AbstractLogEnabled
+    implements Shader
+{
+    public void shade( Set jars, File uberJar, List filters, List relocators, List resourceTransformers )
+    throws IOException
+    {
+        Set resources = new HashSet();
+
+        RelocatorRemapper remapper = new RelocatorRemapper( relocators );
+
+        JarOutputStream jos = new JarOutputStream( new FileOutputStream( uberJar ) );
+
+        for ( Iterator i = jars.iterator(); i.hasNext(); )
+        {
+            File jar = (File) i.next();
+
+            List jarFilters = getFilters( jar, filters );
+
+            JarFile jarFile = new JarFile( jar );
+
+            for ( Enumeration j = jarFile.entries(); j.hasMoreElements(); )
+            {
+                JarEntry entry = (JarEntry) j.nextElement();
+
+                String name = entry.getName();
+                if ( "META-INF/INDEX.LIST".equals( name ) ) 
+                {
+                    //we cannot allow the jar indexes to be copied over or the 
+                    //jar is useless.   Ideally, we could create a new one
+                    //later
+                    continue;
+                }
+
+                String mappedName = remapper.map( name );
+
+                InputStream is = jarFile.getInputStream( entry );
+                if ( !entry.isDirectory() && !isFiltered( jarFilters, name ) )
+                {
+                    int idx = mappedName.lastIndexOf('/');
+                    if ( idx != -1 )
+                    {
+                        //make sure dirs are created
+                        String dir = mappedName.substring(0, idx);
+                        if ( !resources.contains( dir ) )
+                        {
+                            addDirectory( resources, jos, dir );
+                        }
+                    }
+
+                    if ( name.endsWith( ".class" ) )
+                    {
+                        addRemappedClass( remapper, jos, jar, name, is );
+                    }
+                    else
+                    {
+                        if ( !resourceTransformed( resourceTransformers, mappedName, is ) )
+                        {
+                            // Avoid duplicates that aren't accounted for by the resource transformers
+                            if ( resources.contains( mappedName ) )
+                            {
+                                continue;
+                            }
+
+                            addResource( resources, jos, mappedName, is );
+                        }
+                    }
+                }
+
+                IOUtil.close( is );
+            }
+
+            jarFile.close();
+        }
+
+        for ( Iterator i = resourceTransformers.iterator(); i.hasNext(); )
+        {
+            ResourceTransformer transformer = (ResourceTransformer) i.next();
+
+            if ( transformer.hasTransformedResource() )
+            {
+                transformer.modifyOutputStream( jos );
+            }
+        }
+
+        IOUtil.close( jos );
+    }
+
+    private List getFilters(File jar, List filters)
+    {
+        List list = new ArrayList();
+
+        for ( int i = 0; i < filters.size(); i++ )
+        {
+            Filter filter = (Filter) filters.get( i );
+
+            if ( filter.canFilter( jar ) )
+            {
+                list.add( filter );
+            }
+
+        }
+
+        return list;
+    }
+
+    private void addDirectory( Set resources, JarOutputStream jos, String name )
+        throws IOException
+    {
+        if ( name.lastIndexOf( '/' ) > 0 )
+        {
+            String parent = name.substring( 0, name.lastIndexOf( '/' ) );
+            if ( !resources.contains( parent ) )
+            {
+                addDirectory( resources, jos, parent );
+            }
+        }
+
+        //directory entries must end in "/"
+        JarEntry entry = new JarEntry( name + "/" );
+        jos.putNextEntry( entry );
+
+        resources.add( name );
+    }
+
+    private void addRemappedClass( RelocatorRemapper remapper, JarOutputStream jos, File jar, String name, InputStream is )
+        throws IOException
+    {
+        if ( !remapper.hasRelocators() )
+        {
+            jos.putNextEntry( new JarEntry( name ) );
+
+            IOUtil.copy( is, jos );
+            return;
+        }
+
+        ClassReader cr = new ClassReader( is );
+
+        ClassWriter cw = new ClassWriter( cr, 0 );
+
+        ClassVisitor cv = new RemappingClassAdapter( cw, remapper );
+
+        cr.accept( cv, ClassReader.EXPAND_FRAMES );
+
+        byte[] renamedClass = cw.toByteArray();
+
+        // Need to take the .class off for remapping evaluation
+        String mappedName = remapper.map( name.substring( 0, name.indexOf( '.' ) ) );
+
+        try
+        {
+            // Now we put it back on so the class file is written out with the right extension.
+            jos.putNextEntry( new JarEntry( mappedName + ".class" ) );
+
+            IOUtil.copy( renamedClass, jos );
+        }
+        catch ( ZipException e )
+        {
+            getLogger().warn( "We have a duplicate " + mappedName + " in " + jar );
+        }
+    }
+
+    private boolean isFiltered( List filters, String name )
+    {
+        for ( int i = 0; i < filters.size(); i++ )
+        {
+            Filter filter = (Filter) filters.get( i );
+
+            if ( filter.isFiltered( name ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private boolean resourceTransformed( List resourceTransformers, String name, InputStream is )
+        throws IOException
+    {
+        boolean resourceTransformed = false;
+
+        for ( Iterator k = resourceTransformers.iterator(); k.hasNext(); )
+        {
+            ResourceTransformer transformer = (ResourceTransformer) k.next();
+
+            if ( transformer.canTransformResource( name ) )
+            {
+                transformer.processResource( is );
+
+                resourceTransformed = true;
+
+                break;
+            }
+        }
+        return resourceTransformed;
+    }
+
+    private void addResource( Set resources, JarOutputStream jos, String name, InputStream is )
+        throws IOException
+    {
+        jos.putNextEntry( new JarEntry( name ) );
+
+        IOUtil.copy( is, jos );
+
+        resources.add( name );
+    }
+
+    class RelocatorRemapper
+        extends Remapper
+    {
+        List relocators;
+
+        public RelocatorRemapper( List relocators )
+        {
+            this.relocators = relocators;
+        }
+
+        public boolean hasRelocators()
+        {
+            return !relocators.isEmpty();
+        }
+
+        public Object mapValue( Object object )
+        {
+            if ( object instanceof String )
+            {
+                String name = (String) object;
+                String value = name;
+                for ( Iterator i = relocators.iterator(); i.hasNext(); )
+                {
+                    Relocator r = (Relocator) i.next();
+
+                    if ( r.canRelocatePath( name ) )
+                    {
+                        value = r.relocatePath( name );
+                        break;
+                    }
+
+                    if ( r.canRelocateClass( name ) )
+                    {
+                        value = r.relocateClass( name );
+                        break;
+                    }
+                }
+
+                return value;
+            }
+            return object;
+        }
+
+        public String map( String name )
+        {
+            String value = name;
+            for ( Iterator i = relocators.iterator(); i.hasNext(); )
+            {
+                Relocator r = (Relocator) i.next();
+
+                if ( r.canRelocatePath( name ) )
+                {
+                    value = r.relocatePath( name );
+                    break;
+                }
+            }
+
+            return value;
+        }
+    }
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java Mon Mar 24 06:17:58 2008
@@ -1,25 +1,25 @@
-package org.apache.maven.plugins.shade;
-
-/*
- * 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.
- */
-
-/** @author Jason van Zyl */
-public interface ShadeConfiguration
-{
-}
+package org.apache.maven.plugins.shade;
+
+/*
+ * 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.
+ */
+
+/** @author Jason van Zyl */
+public interface ShadeConfiguration
+{
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadeConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java Mon Mar 24 06:17:58 2008
@@ -1,38 +1,38 @@
-package org.apache.maven.plugins.shade;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-/** @author Jason van Zyl */
-public interface Shader
-{
-    String ROLE = Shader.class.getName();
-
-    public void shade(Set jars,
-                      File uberJar,
-                      List filters,
-                      List relocators,
-                      List resourceTransformers)
-        throws IOException;
-}
+package org.apache.maven.plugins.shade;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+/** @author Jason van Zyl */
+public interface Shader
+{
+    String ROLE = Shader.class.getName();
+
+    public void shade(Set jars,
+                      File uberJar,
+                      List filters,
+                      List relocators,
+                      List resourceTransformers)
+        throws IOException;
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/Shader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java Mon Mar 24 06:17:58 2008
@@ -1,25 +1,25 @@
-package org.apache.maven.plugins.shade;
-
-/*
- * 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.
- */
-
-/** @author Jason van Zyl */
-public class ShadingResult
-{
-}
+package org.apache.maven.plugins.shade;
+
+/*
+ * 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.
+ */
+
+/** @author Jason van Zyl */
+public class ShadingResult
+{
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/ShadingResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/Filter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/SimpleFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ArchiveFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ArtifactSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java Mon Mar 24 06:17:58 2008
@@ -1,50 +1,50 @@
-package org.apache.maven.plugins.shade.mojo;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-/**
- * @author Jason van Zyl
- * @author Mauro Talevi
- */
-public class PackageRelocation
-{
-    private String pattern;
-
-    private String shadedPattern;
-
-    private List excludes;
-
-    public String getPattern()
-    {
-        return pattern;
-    }
-
-    public String getShadedPattern()
-    {
-        return shadedPattern;
-    }
-
-    public List getExcludes()
-    {
-        return excludes;
-    }
-}
+package org.apache.maven.plugins.shade.mojo;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+/**
+ * @author Jason van Zyl
+ * @author Mauro Talevi
+ */
+public class PackageRelocation
+{
+    private String pattern;
+
+    private String shadedPattern;
+
+    private List excludes;
+
+    public String getPattern()
+    {
+        return pattern;
+    }
+
+    public String getShadedPattern()
+    {
+        return shadedPattern;
+    }
+
+    public List getExcludes()
+    {
+        return excludes;
+    }
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/PackageRelocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java?rev=640405&r1=640404&r2=640405&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Mon Mar 24 06:17:58 2008
@@ -1,687 +1,687 @@
-package org.apache.maven.plugins.shade.mojo;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.shade.Shader;
-import org.apache.maven.plugins.shade.filter.SimpleFilter;
-import org.apache.maven.plugins.shade.pom.PomWriter;
-import org.apache.maven.plugins.shade.relocation.SimpleRelocator;
-import org.apache.maven.plugins.shade.resource.ResourceTransformer;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- * Mojo that performs shading delegating to the Shader component.
- *
- * @author Jason van Zyl
- * @author Mauro Talevi
- * @author David Blevins
- * @goal shade
- * @phase package
- * @requiresDependencyResolution runtime
- */
-public class ShadeMojo
-    extends AbstractMojo
-{
-    /**
-     * @parameter expression="${project}"
-     * @readonly
-     */
-    private MavenProject project;
-
-    /** @component */
-    private MavenProjectHelper projectHelper;
-
-    /** @component */
-    private Shader shader;
-
-    /**
-     * Remote repositories which will be searched for source attachments.
-     *
-     * @parameter expression="${project.remoteArtifactRepositories}"
-     * @required
-     * @readonly
-     */
-    protected List remoteArtifactRepositories;
-
-    /**
-     * Local maven repository.
-     *
-     * @parameter expression="${localRepository}"
-     * @required
-     * @readonly
-     */
-    protected ArtifactRepository localRepository;
-
-    /**
-     * Artifact factory, needed to download source jars for inclusion in classpath.
-     *
-     * @component role="org.apache.maven.artifact.factory.ArtifactFactory"
-     * @required
-     * @readonly
-     */
-    protected ArtifactFactory artifactFactory;
-
-    /**
-     * Artifact resolver, needed to download source jars for inclusion in classpath.
-     *
-     * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
-     * @required
-     * @readonly
-     */
-    protected ArtifactResolver artifactResolver;
-
-    /**
-     * Artifacts to include/exclude from the final artifact.
-     *
-     * @parameter
-     */
-    private ArtifactSet artifactSet;
-
-    /**
-     * Packages to be relocated.
-     *
-     * @parameter
-     */
-    private PackageRelocation[] relocations;
-
-    /**
-     * Resource transformers to be used.
-     *
-     * @parameter
-     */
-    private ResourceTransformer[] transformers;
-
-    /**
-     * Archive Filters to be used.  Allows you to specify an artifact in the form of
-     * groupId:artifactId and a set of include/exclude file patterns for filtering which
-     * contents of the archive are added to the shaded jar.  From a logical perspective,
-     * includes are processed before excludes, thus it's possible to use an include to
-     * collect a set of files from the archive then use excludes to further reduce the set.
-     * By default, all files are included and no files are excluded.
-     *
-     * @parameter
-     */
-    private ArchiveFilter[] filters;
-
-    /** @parameter expression="${project.build.directory}" */
-    private File outputDirectory;
-
-    /**
-     * The name of the shaded artifactId
-     *
-     * @parameter expression="${finalName}"
-     */
-    private String finalName;
-
-    /**
-     * The name of the shaded artifactId. So you may want to use a different artifactId and keep
-     * the standard version. If the original artifactId was "foo" then the final artifact would
-     * be something like foo-1.0.jar. So if you change the artifactId you might have something
-     * like foo-special-1.0.jar.
-     *
-     * @parameter expression="${shadedArtifactId}" default-value="${project.artifactId}"
-     */
-    private String shadedArtifactId;
-
-    /**
-     * If specified, this will include only artifacts which have groupIds which
-     * start with this.
-     *
-     * @parameter expression="${shadedGroupFilter}"
-     */
-    private String shadedGroupFilter;
-
-    /**
-     * Defines whether the shaded artifact should be attached as classifier to
-     * the original artifact.  If false, the shaded jar will be the main artifact
-     * of the project
-     *
-     * @parameter expression="${shadedArtifactAttached}" default-value="false"
-     */
-    private boolean shadedArtifactAttached;
-
-    /**
-     * @parameter expression="${createDependencyReducedPom}" default-value="true"
-     */
-    private boolean createDependencyReducedPom;
-
-    /**
-     * When true, dependencies are kept in the pom but with scope 'provided'; when false,
-     * the dependency is removed.
-     *
-     * @parameter expression="${keepDependenciesWithProvidedScope}" default-value="false"
-     */
-    private boolean keepDependenciesWithProvidedScope;
-
-    /**
-     * When true, transitive deps of removed dependencies are promoted to direct dependencies.
-     * This should allow the drop in replacement of the removed deps with the new shaded
-     * jar and everything should still work.
-     *
-     * @parameter expression="${promoteTransitiveDependencies}" default-value="false"
-     */
-    private boolean promoteTransitiveDependencies;
-
-
-    /**
-     * The name of the classifier used in case the shaded artifact is attached.
-     *
-     * @parameter expression="${shadedClassifierName}" default-value="shaded"
-     */
-    private String shadedClassifierName;
-
-    /**
-     * When true, it will attempt to create a sources jar as well
-     *
-     * @parameter expression="${createSourcesJar}" default-value="false"
-     */
-    private boolean createSourcesJar;
-
-
-    /** @throws MojoExecutionException  */
-    public void execute()
-        throws MojoExecutionException
-    {
-        Set artifacts = new LinkedHashSet();
-        Set artifactIds = new LinkedHashSet();
-        Set sourceArtifacts = new LinkedHashSet();
-
-        artifacts.add( project.getArtifact().getFile() );
-
-        if ( createSourcesJar )
-        {
-            File file = shadedSourcesArtifactFile();
-            if ( file.exists() )
-            {
-                sourceArtifacts.add( file );
-            }
-        }
-        
-        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
-        {
-            Artifact artifact = (Artifact) it.next();
-
-            if ( excludeArtifact( artifact ) )
-            {
-                getLog().info( "Excluding " + artifact.getId() + " from the shaded jar." );
-
-                continue;
-            }
-
-            getLog().info( "Including " + artifact.getId() + " in the shaded jar." );
-
-            artifacts.add( artifact.getFile() );
-
-            artifactIds.add( getId( artifact ) );
-
-            if ( createSourcesJar )
-            {
-                File file = resolveArtifactSources( artifact );
-                if ( file != null )
-                {
-                    sourceArtifacts.add( file );
-                }
-            }
-        }
-
-
-        File outputJar = shadedArtifactFileWithClassifier();
-        File sourcesJar = shadedSourceArtifactFileWithClassifier();
-
-        // Now add our extra resources
-        try
-        {
-            List filters = getFilters();
-
-            List relocators = getRelocators();
-
-            List resourceTransformers = getResourceTrasformers();
-
-            shader.shade( artifacts, outputJar, filters, relocators, resourceTransformers );
-
-            if (createSourcesJar)
-            {
-                shader.shade( sourceArtifacts, sourcesJar, filters, relocators, resourceTransformers );
-            }
-
-            if ( shadedArtifactAttached )
-            {
-                getLog().info( "Attaching shaded artifact." );
-                projectHelper.attachArtifact( getProject(), "jar", shadedClassifierName, outputJar );
-                if ( createSourcesJar )
-                {
-                    projectHelper.attachArtifact( getProject(), "jar",
-                                                  shadedClassifierName + "-sources", sourcesJar );
-                }
-            }
-
-            else
-            {
-                getLog().info( "Replacing original artifact with shaded artifact." );
-                File file = shadedArtifactFile();
-                replaceFile( file, outputJar );
-
-                if ( createSourcesJar )
-                {
-                    file = shadedSourcesArtifactFile();
-
-                    replaceFile( file, sourcesJar );
-
-                    projectHelper.attachArtifact( project, "jar",
-                                                  "sources", file );
-                }
-
-                if ( createDependencyReducedPom )
-                {
-                    createDependencyReducedPom( artifactIds );
-                }
-            }
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "Error creating shaded jar.", e );
-        }
-    }
-
-    private void replaceFile(File oldFile, File newFile) throws MojoExecutionException
-    {
-        getLog().info("Replacing " + oldFile + " with " + newFile);
-
-        File origFile = new File( outputDirectory, "original-" + oldFile.getName() );
-        if ( oldFile.exists() && !oldFile.renameTo( origFile ) )
-        {
-            //try a gc to see if an unclosed stream needs garbage collecting
-            System.gc();
-            System.gc();
-
-            if ( !oldFile.renameTo( origFile ) )
-            {
-                // Still didn't work.   We'll do a copy
-                try
-                {
-                    FileOutputStream fout = new FileOutputStream( origFile );
-                    FileInputStream fin = new FileInputStream( oldFile );
-                    try
-                    {
-                        IOUtil.copy(fin, fout);
-                    }
-                    finally
-                    {
-                        IOUtil.close( fin );
-                        IOUtil.close( fout );
-                    }
-                }
-                catch (IOException ex)
-                {
-                    //kind of ignorable here.   We're just trying to save the original
-                    getLog().warn(ex);
-                }
-            }
-        }
-        if ( !newFile.renameTo( oldFile ) )
-        {
-            //try a gc to see if an unclosed stream needs garbage collecting
-            System.gc();
-            System.gc();
-            if ( !newFile.renameTo( oldFile ) )
-            {
-                // Still didn't work.   We'll do a copy
-                try
-                {
-                    FileOutputStream fout = new FileOutputStream( oldFile );
-                    FileInputStream fin = new FileInputStream( newFile );
-                    try
-                    {
-                        IOUtil.copy(fin, fout);
-                    }
-                    finally
-                    {
-                        IOUtil.close( fin );
-                        IOUtil.close( fout );
-                    }
-                }
-                catch (IOException ex)
-                {
-                    throw new MojoExecutionException( "Could not replace original artifact with shaded artifact!", ex);
-                }
-            }
-        }
-    }
-
-    private File resolveArtifactSources(Artifact artifact) {
-
-        Artifact resolvedArtifact =
-            artifactFactory.createArtifactWithClassifier( artifact.getGroupId(),
-                                                          artifact.getArtifactId(),
-                                                          artifact.getVersion(),
-                                                          "java-source",
-                                                          "sources");
-
-        try
-        {
-            artifactResolver.resolve( resolvedArtifact, remoteArtifactRepositories, localRepository );
-        }
-        catch ( ArtifactNotFoundException e )
-        {
-            // ignore, the jar has not been found
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            getLog().warn( "Could not get sources for " + artifact );
-        }
-
-        if ( resolvedArtifact.isResolved() )
-        {
-            return resolvedArtifact.getFile();
-        }
-        return null;
-    }
-
-    private boolean excludeArtifact( Artifact artifact )
-    {
-        String id = getId( artifact );
-
-        // This is the case where we have only stated artifacts to include and no exclusions
-        // have been listed. We just want what we have asked to include.
-        if ( artifactSet != null && ( artifactSet.getExcludes() == null && artifactSet.getIncludes() != null ) && !includedArtifacts().contains( id ) )
-        {
-            return true;
-        }
-
-        if ( excludedArtifacts().contains( id ) )
-        {
-            return true;
-        }
-
-        if ( shadedGroupFilter != null && !artifact.getGroupId().startsWith( shadedGroupFilter ) )
-        {
-            return true;
-        }
-
-        return false;
-    }
-
-    private Set excludedArtifacts()
-    {
-        if ( artifactSet != null && artifactSet.getExcludes() != null )
-        {
-            return artifactSet.getExcludes();
-        }
-
-        return Collections.EMPTY_SET;
-    }
-
-    private Set includedArtifacts()
-    {
-        if ( artifactSet != null && artifactSet.getIncludes() != null )
-        {
-            return artifactSet.getIncludes();
-        }
-
-        return Collections.EMPTY_SET;
-    }
-
-    private List getRelocators()
-    {
-        List relocators = new ArrayList();
-
-        if ( relocations == null )
-        {
-            return relocators;
-        }
-
-        for ( int i = 0; i < relocations.length; i++ )
-        {
-            PackageRelocation r = relocations[i];
-
-            relocators.add( new SimpleRelocator( r.getPattern(), r.getShadedPattern(), r.getExcludes() ) );
-
-        }
-        return relocators;
-    }
-
-    private List getResourceTrasformers()
-    {
-        if ( transformers == null )
-        {
-            return Collections.EMPTY_LIST;
-        }
-
-        return Arrays.asList( transformers );
-    }
-
-    private List getFilters()
-    {
-        List filters = new ArrayList();
-
-        if ( this.filters == null )
-        {
-            return filters;
-        }
-
-        Map artifacts = new HashMap();
-
-        artifacts.put( getId( project.getArtifact() ), project.getArtifact().getFile() );
-
-        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
-        {
-            Artifact artifact = (Artifact) it.next();
-
-            artifacts.put( getId( artifact ), artifact.getFile() );
-        }
-
-        for ( int i = 0; i < this.filters.length; i++ )
-        {
-            ArchiveFilter f = this.filters[i];
-
-            File jar = (File) artifacts.get( f.getArtifact() );
-
-            if ( jar == null )
-            {
-                getLog().info( "No artifact matching filter " + f.getArtifact() );
-
-                continue;
-            }
-
-            filters.add( new SimpleFilter( jar, f.getIncludes(), f.getExcludes() ) );
-
-        }
-
-        return filters;
-    }
-
-    private File shadedArtifactFileWithClassifier()
-    {
-        Artifact artifact = project.getArtifact();
-        final String shadedName =
-            shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "." + artifact.getArtifactHandler().getExtension();
-        return new File( outputDirectory, shadedName );
-    }
-    private File shadedSourceArtifactFileWithClassifier()
-    {
-        Artifact artifact = project.getArtifact();
-        final String shadedName =
-            shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "-sources." + artifact.getArtifactHandler().getExtension();
-        return new File( outputDirectory, shadedName );
-    }
-
-    private File shadedArtifactFile()
-    {
-        Artifact artifact = project.getArtifact();
-
-        String shadedName;
-
-        if ( finalName != null )
-        {
-            shadedName = finalName + "." + artifact.getArtifactHandler().getExtension();
-        }
-        else
-        {
-            shadedName = shadedArtifactId + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension();
-        }
-
-        return new File( outputDirectory, shadedName );
-    }
-    private File shadedSourcesArtifactFile()
-    {
-        Artifact artifact = project.getArtifact();
-
-        String shadedName;
-
-        if ( finalName != null )
-        {
-            shadedName = finalName + "-sources." + artifact.getArtifactHandler().getExtension();
-        }
-        else
-        {
-            shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-sources." + artifact.getArtifactHandler().getExtension();
-        }
-
-        return new File( outputDirectory, shadedName );
-    }
-
-    protected MavenProject getProject()
-    {
-        if ( project.getExecutionProject() != null )
-        {
-            return project.getExecutionProject();
-        }
-        else
-        {
-            return project;
-        }
-    }
-
-    // We need to find the direct dependencies that have been included in the uber JAR so that we can modify the
-    // POM accordingly.
-    private void createDependencyReducedPom( Set artifactsToRemove )
-        throws IOException
-    {
-        Model model = getProject().getOriginalModel();
-
-        List dependencies = new ArrayList();
-
-        boolean modified = false;
-
-        List origDeps = getProject().getDependencies();
-        if ( promoteTransitiveDependencies )
-        {
-            origDeps = new ArrayList();
-            for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
-            {
-                Artifact artifact = (Artifact) it.next();
-
-                //promote
-                Dependency dep = new Dependency();
-                dep.setArtifactId( artifact.getArtifactId() );
-                if (artifact.hasClassifier())
-                {
-                    dep.setClassifier( artifact.getClassifier() );
-                }
-                dep.setGroupId( artifact.getGroupId() );
-                dep.setOptional( artifact.isOptional() );
-                dep.setScope( artifact.getScope() );
-                dep.setType( artifact.getType() );
-                dep.setVersion( artifact.getVersion() );
-
-                // How to do these?
-                //dep.setSystemPath( .... );
-                //dep.setExclusions( exclusions );
-                origDeps.add( dep );
-            }
-        }
-
-        for ( Iterator i = origDeps.iterator(); i.hasNext(); )
-        {
-            Dependency d = (Dependency) i.next();
-
-            dependencies.add( d );
-
-            String id = d.getGroupId() + ":" + d.getArtifactId();
-
-            if ( artifactsToRemove.contains( id ) )
-            {
-                modified = true;
-
-                if ( keepDependenciesWithProvidedScope )
-                {
-                    d.setScope( "provided" );
-                }
-                else
-                {
-                    dependencies.remove( d );
-                }
-            }
-        }
-
-        // Check to see if we have a reduction and if so rewrite the POM.
-        if ( modified )
-        {
-            model.setDependencies( dependencies );
-
-            File f = new File( outputDirectory, "dependency-reduced-pom.xml" );
-            if (f.exists())
-            {
-                f.delete();
-            }
-
-            Writer w = new FileWriter( f );
-
-            PomWriter.write( w, model, true );
-
-            w.close();
-
-            project.setFile( f );
-        }
-    }
-
-    private String getId( Artifact artifact )
-    {
-        return artifact.getGroupId() + ":" + artifact.getArtifactId();
-    }
-}
+package org.apache.maven.plugins.shade.mojo;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.shade.Shader;
+import org.apache.maven.plugins.shade.filter.SimpleFilter;
+import org.apache.maven.plugins.shade.pom.PomWriter;
+import org.apache.maven.plugins.shade.relocation.SimpleRelocator;
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Mojo that performs shading delegating to the Shader component.
+ *
+ * @author Jason van Zyl
+ * @author Mauro Talevi
+ * @author David Blevins
+ * @goal shade
+ * @phase package
+ * @requiresDependencyResolution runtime
+ */
+public class ShadeMojo
+    extends AbstractMojo
+{
+    /**
+     * @parameter expression="${project}"
+     * @readonly
+     */
+    private MavenProject project;
+
+    /** @component */
+    private MavenProjectHelper projectHelper;
+
+    /** @component */
+    private Shader shader;
+
+    /**
+     * Remote repositories which will be searched for source attachments.
+     *
+     * @parameter expression="${project.remoteArtifactRepositories}"
+     * @required
+     * @readonly
+     */
+    protected List remoteArtifactRepositories;
+
+    /**
+     * Local maven repository.
+     *
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    protected ArtifactRepository localRepository;
+
+    /**
+     * Artifact factory, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.factory.ArtifactFactory"
+     * @required
+     * @readonly
+     */
+    protected ArtifactFactory artifactFactory;
+
+    /**
+     * Artifact resolver, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
+     * @required
+     * @readonly
+     */
+    protected ArtifactResolver artifactResolver;
+
+    /**
+     * Artifacts to include/exclude from the final artifact.
+     *
+     * @parameter
+     */
+    private ArtifactSet artifactSet;
+
+    /**
+     * Packages to be relocated.
+     *
+     * @parameter
+     */
+    private PackageRelocation[] relocations;
+
+    /**
+     * Resource transformers to be used.
+     *
+     * @parameter
+     */
+    private ResourceTransformer[] transformers;
+
+    /**
+     * Archive Filters to be used.  Allows you to specify an artifact in the form of
+     * groupId:artifactId and a set of include/exclude file patterns for filtering which
+     * contents of the archive are added to the shaded jar.  From a logical perspective,
+     * includes are processed before excludes, thus it's possible to use an include to
+     * collect a set of files from the archive then use excludes to further reduce the set.
+     * By default, all files are included and no files are excluded.
+     *
+     * @parameter
+     */
+    private ArchiveFilter[] filters;
+
+    /** @parameter expression="${project.build.directory}" */
+    private File outputDirectory;
+
+    /**
+     * The name of the shaded artifactId
+     *
+     * @parameter expression="${finalName}"
+     */
+    private String finalName;
+
+    /**
+     * The name of the shaded artifactId. So you may want to use a different artifactId and keep
+     * the standard version. If the original artifactId was "foo" then the final artifact would
+     * be something like foo-1.0.jar. So if you change the artifactId you might have something
+     * like foo-special-1.0.jar.
+     *
+     * @parameter expression="${shadedArtifactId}" default-value="${project.artifactId}"
+     */
+    private String shadedArtifactId;
+
+    /**
+     * If specified, this will include only artifacts which have groupIds which
+     * start with this.
+     *
+     * @parameter expression="${shadedGroupFilter}"
+     */
+    private String shadedGroupFilter;
+
+    /**
+     * Defines whether the shaded artifact should be attached as classifier to
+     * the original artifact.  If false, the shaded jar will be the main artifact
+     * of the project
+     *
+     * @parameter expression="${shadedArtifactAttached}" default-value="false"
+     */
+    private boolean shadedArtifactAttached;
+
+    /**
+     * @parameter expression="${createDependencyReducedPom}" default-value="true"
+     */
+    private boolean createDependencyReducedPom;
+
+    /**
+     * When true, dependencies are kept in the pom but with scope 'provided'; when false,
+     * the dependency is removed.
+     *
+     * @parameter expression="${keepDependenciesWithProvidedScope}" default-value="false"
+     */
+    private boolean keepDependenciesWithProvidedScope;
+
+    /**
+     * When true, transitive deps of removed dependencies are promoted to direct dependencies.
+     * This should allow the drop in replacement of the removed deps with the new shaded
+     * jar and everything should still work.
+     *
+     * @parameter expression="${promoteTransitiveDependencies}" default-value="false"
+     */
+    private boolean promoteTransitiveDependencies;
+
+
+    /**
+     * The name of the classifier used in case the shaded artifact is attached.
+     *
+     * @parameter expression="${shadedClassifierName}" default-value="shaded"
+     */
+    private String shadedClassifierName;
+
+    /**
+     * When true, it will attempt to create a sources jar as well
+     *
+     * @parameter expression="${createSourcesJar}" default-value="false"
+     */
+    private boolean createSourcesJar;
+
+
+    /** @throws MojoExecutionException  */
+    public void execute()
+        throws MojoExecutionException
+    {
+        Set artifacts = new LinkedHashSet();
+        Set artifactIds = new LinkedHashSet();
+        Set sourceArtifacts = new LinkedHashSet();
+
+        artifacts.add( project.getArtifact().getFile() );
+
+        if ( createSourcesJar )
+        {
+            File file = shadedSourcesArtifactFile();
+            if ( file.exists() )
+            {
+                sourceArtifacts.add( file );
+            }
+        }
+        
+        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
+        {
+            Artifact artifact = (Artifact) it.next();
+
+            if ( excludeArtifact( artifact ) )
+            {
+                getLog().info( "Excluding " + artifact.getId() + " from the shaded jar." );
+
+                continue;
+            }
+
+            getLog().info( "Including " + artifact.getId() + " in the shaded jar." );
+
+            artifacts.add( artifact.getFile() );
+
+            artifactIds.add( getId( artifact ) );
+
+            if ( createSourcesJar )
+            {
+                File file = resolveArtifactSources( artifact );
+                if ( file != null )
+                {
+                    sourceArtifacts.add( file );
+                }
+            }
+        }
+
+
+        File outputJar = shadedArtifactFileWithClassifier();
+        File sourcesJar = shadedSourceArtifactFileWithClassifier();
+
+        // Now add our extra resources
+        try
+        {
+            List filters = getFilters();
+
+            List relocators = getRelocators();
+
+            List resourceTransformers = getResourceTrasformers();
+
+            shader.shade( artifacts, outputJar, filters, relocators, resourceTransformers );
+
+            if (createSourcesJar)
+            {
+                shader.shade( sourceArtifacts, sourcesJar, filters, relocators, resourceTransformers );
+            }
+
+            if ( shadedArtifactAttached )
+            {
+                getLog().info( "Attaching shaded artifact." );
+                projectHelper.attachArtifact( getProject(), "jar", shadedClassifierName, outputJar );
+                if ( createSourcesJar )
+                {
+                    projectHelper.attachArtifact( getProject(), "jar",
+                                                  shadedClassifierName + "-sources", sourcesJar );
+                }
+            }
+
+            else
+            {
+                getLog().info( "Replacing original artifact with shaded artifact." );
+                File file = shadedArtifactFile();
+                replaceFile( file, outputJar );
+
+                if ( createSourcesJar )
+                {
+                    file = shadedSourcesArtifactFile();
+
+                    replaceFile( file, sourcesJar );
+
+                    projectHelper.attachArtifact( project, "jar",
+                                                  "sources", file );
+                }
+
+                if ( createDependencyReducedPom )
+                {
+                    createDependencyReducedPom( artifactIds );
+                }
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating shaded jar.", e );
+        }
+    }
+
+    private void replaceFile(File oldFile, File newFile) throws MojoExecutionException
+    {
+        getLog().info("Replacing " + oldFile + " with " + newFile);
+
+        File origFile = new File( outputDirectory, "original-" + oldFile.getName() );
+        if ( oldFile.exists() && !oldFile.renameTo( origFile ) )
+        {
+            //try a gc to see if an unclosed stream needs garbage collecting
+            System.gc();
+            System.gc();
+
+            if ( !oldFile.renameTo( origFile ) )
+            {
+                // Still didn't work.   We'll do a copy
+                try
+                {
+                    FileOutputStream fout = new FileOutputStream( origFile );
+                    FileInputStream fin = new FileInputStream( oldFile );
+                    try
+                    {
+                        IOUtil.copy(fin, fout);
+                    }
+                    finally
+                    {
+                        IOUtil.close( fin );
+                        IOUtil.close( fout );
+                    }
+                }
+                catch (IOException ex)
+                {
+                    //kind of ignorable here.   We're just trying to save the original
+                    getLog().warn(ex);
+                }
+            }
+        }
+        if ( !newFile.renameTo( oldFile ) )
+        {
+            //try a gc to see if an unclosed stream needs garbage collecting
+            System.gc();
+            System.gc();
+            if ( !newFile.renameTo( oldFile ) )
+            {
+                // Still didn't work.   We'll do a copy
+                try
+                {
+                    FileOutputStream fout = new FileOutputStream( oldFile );
+                    FileInputStream fin = new FileInputStream( newFile );
+                    try
+                    {
+                        IOUtil.copy(fin, fout);
+                    }
+                    finally
+                    {
+                        IOUtil.close( fin );
+                        IOUtil.close( fout );
+                    }
+                }
+                catch (IOException ex)
+                {
+                    throw new MojoExecutionException( "Could not replace original artifact with shaded artifact!", ex);
+                }
+            }
+        }
+    }
+
+    private File resolveArtifactSources(Artifact artifact) {
+
+        Artifact resolvedArtifact =
+            artifactFactory.createArtifactWithClassifier( artifact.getGroupId(),
+                                                          artifact.getArtifactId(),
+                                                          artifact.getVersion(),
+                                                          "java-source",
+                                                          "sources");
+
+        try
+        {
+            artifactResolver.resolve( resolvedArtifact, remoteArtifactRepositories, localRepository );
+        }
+        catch ( ArtifactNotFoundException e )
+        {
+            // ignore, the jar has not been found
+        }
+        catch ( ArtifactResolutionException e )
+        {
+            getLog().warn( "Could not get sources for " + artifact );
+        }
+
+        if ( resolvedArtifact.isResolved() )
+        {
+            return resolvedArtifact.getFile();
+        }
+        return null;
+    }
+
+    private boolean excludeArtifact( Artifact artifact )
+    {
+        String id = getId( artifact );
+
+        // This is the case where we have only stated artifacts to include and no exclusions
+        // have been listed. We just want what we have asked to include.
+        if ( artifactSet != null && ( artifactSet.getExcludes() == null && artifactSet.getIncludes() != null ) && !includedArtifacts().contains( id ) )
+        {
+            return true;
+        }
+
+        if ( excludedArtifacts().contains( id ) )
+        {
+            return true;
+        }
+
+        if ( shadedGroupFilter != null && !artifact.getGroupId().startsWith( shadedGroupFilter ) )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    private Set excludedArtifacts()
+    {
+        if ( artifactSet != null && artifactSet.getExcludes() != null )
+        {
+            return artifactSet.getExcludes();
+        }
+
+        return Collections.EMPTY_SET;
+    }
+
+    private Set includedArtifacts()
+    {
+        if ( artifactSet != null && artifactSet.getIncludes() != null )
+        {
+            return artifactSet.getIncludes();
+        }
+
+        return Collections.EMPTY_SET;
+    }
+
+    private List getRelocators()
+    {
+        List relocators = new ArrayList();
+
+        if ( relocations == null )
+        {
+            return relocators;
+        }
+
+        for ( int i = 0; i < relocations.length; i++ )
+        {
+            PackageRelocation r = relocations[i];
+
+            relocators.add( new SimpleRelocator( r.getPattern(), r.getShadedPattern(), r.getExcludes() ) );
+
+        }
+        return relocators;
+    }
+
+    private List getResourceTrasformers()
+    {
+        if ( transformers == null )
+        {
+            return Collections.EMPTY_LIST;
+        }
+
+        return Arrays.asList( transformers );
+    }
+
+    private List getFilters()
+    {
+        List filters = new ArrayList();
+
+        if ( this.filters == null )
+        {
+            return filters;
+        }
+
+        Map artifacts = new HashMap();
+
+        artifacts.put( getId( project.getArtifact() ), project.getArtifact().getFile() );
+
+        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
+        {
+            Artifact artifact = (Artifact) it.next();
+
+            artifacts.put( getId( artifact ), artifact.getFile() );
+        }
+
+        for ( int i = 0; i < this.filters.length; i++ )
+        {
+            ArchiveFilter f = this.filters[i];
+
+            File jar = (File) artifacts.get( f.getArtifact() );
+
+            if ( jar == null )
+            {
+                getLog().info( "No artifact matching filter " + f.getArtifact() );
+
+                continue;
+            }
+
+            filters.add( new SimpleFilter( jar, f.getIncludes(), f.getExcludes() ) );
+
+        }
+
+        return filters;
+    }
+
+    private File shadedArtifactFileWithClassifier()
+    {
+        Artifact artifact = project.getArtifact();
+        final String shadedName =
+            shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "." + artifact.getArtifactHandler().getExtension();
+        return new File( outputDirectory, shadedName );
+    }
+    private File shadedSourceArtifactFileWithClassifier()
+    {
+        Artifact artifact = project.getArtifact();
+        final String shadedName =
+            shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "-sources." + artifact.getArtifactHandler().getExtension();
+        return new File( outputDirectory, shadedName );
+    }
+
+    private File shadedArtifactFile()
+    {
+        Artifact artifact = project.getArtifact();
+
+        String shadedName;
+
+        if ( finalName != null )
+        {
+            shadedName = finalName + "." + artifact.getArtifactHandler().getExtension();
+        }
+        else
+        {
+            shadedName = shadedArtifactId + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension();
+        }
+
+        return new File( outputDirectory, shadedName );
+    }
+    private File shadedSourcesArtifactFile()
+    {
+        Artifact artifact = project.getArtifact();
+
+        String shadedName;
+
+        if ( finalName != null )
+        {
+            shadedName = finalName + "-sources." + artifact.getArtifactHandler().getExtension();
+        }
+        else
+        {
+            shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-sources." + artifact.getArtifactHandler().getExtension();
+        }
+
+        return new File( outputDirectory, shadedName );
+    }
+
+    protected MavenProject getProject()
+    {
+        if ( project.getExecutionProject() != null )
+        {
+            return project.getExecutionProject();
+        }
+        else
+        {
+            return project;
+        }
+    }
+
+    // We need to find the direct dependencies that have been included in the uber JAR so that we can modify the
+    // POM accordingly.
+    private void createDependencyReducedPom( Set artifactsToRemove )
+        throws IOException
+    {
+        Model model = getProject().getOriginalModel();
+
+        List dependencies = new ArrayList();
+
+        boolean modified = false;
+
+        List origDeps = getProject().getDependencies();
+        if ( promoteTransitiveDependencies )
+        {
+            origDeps = new ArrayList();
+            for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
+            {
+                Artifact artifact = (Artifact) it.next();
+
+                //promote
+                Dependency dep = new Dependency();
+                dep.setArtifactId( artifact.getArtifactId() );
+                if (artifact.hasClassifier())
+                {
+                    dep.setClassifier( artifact.getClassifier() );
+                }
+                dep.setGroupId( artifact.getGroupId() );
+                dep.setOptional( artifact.isOptional() );
+                dep.setScope( artifact.getScope() );
+                dep.setType( artifact.getType() );
+                dep.setVersion( artifact.getVersion() );
+
+                // How to do these?
+                //dep.setSystemPath( .... );
+                //dep.setExclusions( exclusions );
+                origDeps.add( dep );
+            }
+        }
+
+        for ( Iterator i = origDeps.iterator(); i.hasNext(); )
+        {
+            Dependency d = (Dependency) i.next();
+
+            dependencies.add( d );
+
+            String id = d.getGroupId() + ":" + d.getArtifactId();
+
+            if ( artifactsToRemove.contains( id ) )
+            {
+                modified = true;
+
+                if ( keepDependenciesWithProvidedScope )
+                {
+                    d.setScope( "provided" );
+                }
+                else
+                {
+                    dependencies.remove( d );
+                }
+            }
+        }
+
+        // Check to see if we have a reduction and if so rewrite the POM.
+        if ( modified )
+        {
+            model.setDependencies( dependencies );
+
+            File f = new File( outputDirectory, "dependency-reduced-pom.xml" );
+            if (f.exists())
+            {
+                f.delete();
+            }
+
+            Writer w = new FileWriter( f );
+
+            PomWriter.write( w, model, true );
+
+            w.close();
+
+            project.setFile( f );
+        }
+    }
+
+    private String getId( Artifact artifact )
+    {
+        return artifact.getGroupId() + ":" + artifact.getArtifactId();
+    }
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native