You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/11/30 04:17:28 UTC

svn commit: r480816 - in /maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency: fromConfiguration/ utils/filters/

Author: brianf
Date: Wed Nov 29 19:17:27 2006
New Revision: 480816

URL: http://svn.apache.org/viewvc?view=rev&rev=480816
Log: (empty)

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java Wed Nov 29 19:17:27 2006
@@ -50,6 +50,7 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.AbstractDependencyMojo;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -112,6 +113,8 @@
      */
     protected ArrayList artifactItems;
 
+    abstract ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item );
+
     /**
      * Preprocesses the list of ArtifactItems. This method defaults the
      * outputDirectory if not set and creates the output Directory if it doesn't
@@ -129,11 +132,11 @@
     protected ArrayList getArtifactItems( boolean removeVersion )
         throws MojoExecutionException
     {
-        if (artifactItems == null || artifactItems.size() < 1)
+        if ( artifactItems == null || artifactItems.size() < 1 )
         {
-            throw new MojoExecutionException("There are no artifactItems configured.");
+            throw new MojoExecutionException( "There are no artifactItems configured." );
         }
-        
+
         Iterator iter = artifactItems.iterator();
         while ( iter.hasNext() )
         {
@@ -146,35 +149,44 @@
             }
             artifactItem.getOutputDirectory().mkdirs();
 
-            //make sure we have a version.
+            // make sure we have a version.
             if ( StringUtils.isEmpty( artifactItem.getVersion() ) )
             {
                 fillMissingArtifactVersion( artifactItem );
             }
-            
-            artifactItem.setArtifact( this.getArtifact( artifactItem ) );
 
-            // TODO:refactor this
-            String overWrite = artifactItem.getOverWrite();
-            if ( StringUtils.isEmpty( overWrite ) )
-            {
-                artifactItem.setDoOverWrite( false );
-            }
-            else
-            {
-                artifactItem.setDoOverWrite( overWrite.equalsIgnoreCase( "true" ) );
-            }
+            artifactItem.setArtifact( this.getArtifact( artifactItem ) );
 
-            if ( artifactItem.getDestFileName() == null )
+            if ( StringUtils.isEmpty( artifactItem.getDestFileName() ) )
             {
                 artifactItem.setDestFileName( DependencyUtil.getFormattedFileName( artifactItem.getArtifact(),
                                                                                    removeVersion ) );
-            }
+            }   
             
+            artifactItem.setNeedsProcessing(checkIfProcessingNeeded(artifactItem));
         }
         return artifactItems;
     }
 
+    private boolean checkIfProcessingNeeded(ArtifactItem item) throws MojoExecutionException
+    {
+        boolean result = false;
+        if ( StringUtils.equalsIgnoreCase( item.getOverWrite(), "true" ) )
+        {
+            result = true;
+        }
+        else if (StringUtils.equalsIgnoreCase( item.getOverWrite(), "false" ))
+        {
+            result = false;
+        }
+        else
+        {
+            ArtifactItemFilter filter = getMarkedArtifactFilter( item );
+            result = filter.okToProcess( item );
+        }
+        return result;
+    }
+    
     /**
      * Resolves the Artifact from the remote repository if nessessary. If no
      * version is specified, it will be retrieved from the dependency list or
@@ -233,13 +245,11 @@
     private void fillMissingArtifactVersion( ArtifactItem artifact )
         throws MojoExecutionException
     {
-        if ( !findDependencyVersion( artifact, project.getDependencies() ) )
+        if ( !findDependencyVersion( artifact, project.getDependencies() )
+            && !findDependencyVersion( artifact, project.getDependencyManagement().getDependencies() ) )
         {
-            if ( !findDependencyVersion( artifact, project.getDependencyManagement().getDependencies() ) )
-            {
-                throw new MojoExecutionException( "Unable to find artifact version of " + artifact.getGroupId() + ":"
-                    + artifact.getArtifactId() + " in either dependency list or in project's dependency management." );
-            }
+            throw new MojoExecutionException( "Unable to find artifact version of " + artifact.getGroupId() + ":"
+                + artifact.getArtifactId() + " in either dependency list or in project's dependency management." );
         }
     }
 

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java Wed Nov 29 19:17:27 2006
@@ -41,7 +41,6 @@
 import java.io.File;
 
 import org.apache.maven.artifact.Artifact;
-import org.codehaus.plexus.archiver.util.FilterSupport;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -113,7 +112,7 @@
     /**
      * Force Overwrite
      */
-    private boolean doOverWrite;
+    private boolean needsProcessing;
 
     /**
      * Artifact Item
@@ -137,7 +136,7 @@
 
     private final String filterEmptyString(String in)
     {
-        if (in.equals(""))
+        if (in == null || in.equals(""))
         {
             return null;
         }
@@ -278,20 +277,20 @@
     }
 
     /**
-     * @return Returns the doOverWrite.
+     * @return Returns the needsProcessing.
      */
-    public boolean isDoOverWrite()
+    public boolean isNeedsProcessing()
     {
-        return this.doOverWrite;
+        return this.needsProcessing;
     }
 
     /**
-     * @param doOverWrite
-     *            The doOverWrite to set.
+     * @param needsProcessing
+     *            The needsProcessing to set.
      */
-    public void setDoOverWrite( boolean doOverWrite )
+    public void setNeedsProcessing( boolean needsProcessing )
     {
-        this.doOverWrite = doOverWrite;
+        this.needsProcessing = needsProcessing;
     }
 
     /**

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java Wed Nov 29 19:17:27 2006
@@ -45,6 +45,8 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter;
+import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter;
 import org.apache.maven.plugin.logging.Log;
 
 /**
@@ -87,7 +89,14 @@
         while ( iter.hasNext() )
         {
             ArtifactItem artifactItem = (ArtifactItem) iter.next();
-            copyArtifact( artifactItem);
+            if (artifactItem.isNeedsProcessing())
+            {
+                copyArtifact( artifactItem);
+            }
+            else
+            {
+                this.getLog().info(artifactItem+" already exists in "+ artifactItem.getOutputDirectory());
+            }
         }
     }
 
@@ -106,35 +115,19 @@
     protected void copyArtifact( ArtifactItem artifactItem )
         throws MojoExecutionException
     {
-        Artifact artifact = artifactItem.getArtifact();
-
         File destFile = new File( artifactItem.getOutputDirectory(), artifactItem.getDestFileName() );
 
-        // TODO: refactor this to use the filters.
-        if ( !artifactItem.isDoOverWrite() )
-        {
-            if ( artifactItem.getArtifact().isSnapshot() )
-            {
-                artifactItem.setDoOverWrite( this.overWriteSnapshots );
-            }
-            else
-            {
-                artifactItem.setDoOverWrite( this.overWriteReleases );
-            }
-        }
-
-        File artifactFile = artifact.getFile();
-        if ( artifactItem.isDoOverWrite()
-            || ( !destFile.exists() || ( overWriteIfNewer && artifactFile.lastModified() < destFile.lastModified() ) ) )
-        {
-            copyFile( artifactFile, destFile );
-        }
-        else
-        {
-            this.getLog().info( artifactFile + " already exists." );
-        }
+        copyFile( artifactItem.getArtifact().getFile(), destFile );
     }
 
+    protected ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item)
+    {
+        ArtifactItemFilter destinationNameOverrideFilter = new DestFileFilter( this.overWriteReleases, this.overWriteSnapshots, this.overWriteIfNewer,
+                                   false, false, this.stripVersion,
+                                   item.getOutputDirectory() );
+        return destinationNameOverrideFilter;
+    }
+    
     /**
      * @return Returns the stripVersion.
      */

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java Wed Nov 29 19:17:27 2006
@@ -17,7 +17,6 @@
  * under the License.    
  */
 
-
 package org.apache.maven.plugin.dependency.fromConfiguration;
 
 /*
@@ -46,6 +45,8 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.filters.ArtifactsFilter;
+import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter;
 import org.apache.maven.plugin.dependency.utils.filters.MarkerFileFilter;
 import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
 import org.apache.maven.plugin.dependency.utils.markers.MarkerHandler;
@@ -86,12 +87,19 @@
     public void execute()
         throws MojoExecutionException
     {
-        ArrayList artifactItems = getArtifactItems(false);
+        ArrayList artifactItems = getArtifactItems( false );
         Iterator iter = artifactItems.iterator();
         while ( iter.hasNext() )
         {
             ArtifactItem artifactItem = (ArtifactItem) iter.next();
+            if (artifactItem.isNeedsProcessing())
+            {
             unpackArtifact( artifactItem );
+            }
+            else
+            {
+                this.getLog().info( artifactItem.getArtifact().getFile().getName() + " already unpacked." );
+            }
         }
     }
 
@@ -114,17 +122,15 @@
         Artifact artifact = artifactItem.getArtifact();
 
         MarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory );
-        MarkerFileFilter filter = new MarkerFileFilter( this.overWriteReleases, this.overWriteSnapshots,
-                                                        this.overWriteIfNewer, handler );
 
-        if (artifactItem.isDoOverWrite() || filter.okToProcess(artifact))
-        {
-            unpack(artifact.getFile(),artifactItem.getOutputDirectory());
-            handler.setMarker();
-        }
-        else
-        {
-            this.getLog().info( artifact.getFile().getName() + " already unpacked." );
-        }
+        unpack( artifact.getFile(), artifactItem.getOutputDirectory() );
+        handler.setMarker();
+
+    }
+
+    ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item )
+    {
+        // TODO Auto-generated method stub
+        return null;
     }
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java Wed Nov 29 19:17:27 2006
@@ -39,6 +39,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -53,7 +54,9 @@
  * 
  * @author <a href="richardv@mxtelecom.com">Richard van der Hoff</a>
  */
-public abstract class AbstractArtifactFeatureFilter implements ArtifactsFilter {
+public abstract class AbstractArtifactFeatureFilter
+    extends AbstractArtifactsFilter
+{
     /** The list of types or classifiers to include */
     private List includes;
 
@@ -65,17 +68,20 @@
 
     /** The configuration string for the exclude list - comma separated */
     private String excludeString;
-    
-    /** The name of the feature we are filtering on - for logging - "Classifiers" or "Types" */
+
+    /**
+     * The name of the feature we are filtering on - for logging - "Classifiers"
+     * or "Types"
+     */
     private String featureName;
-    
+
     public AbstractArtifactFeatureFilter( String include, String exclude, String featureName )
     {
         setExcludes( exclude );
         setIncludes( include );
         this.featureName = featureName;
     }
-    
+
     /**
      * This function determines if filtering needs to be performed. Excludes are
      * ignored if Includes are used.
@@ -91,14 +97,14 @@
 
         if ( this.includes != null && !this.includes.isEmpty() )
         {
-            log.debug( "Including only "+featureName+": " + this.includeString );
+            log.debug( "Including only " + featureName + ": " + this.includeString );
             results = filterIncludes( artifacts, this.includes );
         }
         else
         {
             if ( this.excludes != null && !this.excludes.isEmpty() )
             {
-                log.debug( "Excluding "+featureName+": " + this.excludeString );
+                log.debug( "Excluding " + featureName + ": " + this.excludeString );
                 results = filterExcludes( artifacts, this.excludes );
             }
         }
@@ -129,9 +135,10 @@
             {
                 Artifact artifact = (Artifact) iter.next();
 
-                // if the classifier or type of the artifact matches the feature to include, add to the
+                // if the classifier or type of the artifact matches the feature
+                // to include, add to the
                 // results
-                if ( getArtifactFeature(artifact).equals( include ) )
+                if ( getArtifactFeature( artifact ).equals( include ) )
                 {
                     result.add( artifact );
                 }
@@ -160,7 +167,7 @@
         {
             boolean exclude = false;
             Artifact artifact = (Artifact) iter.next();
-            String artifactFeature = getArtifactFeature(artifact);
+            String artifactFeature = getArtifactFeature( artifact );
 
             // look through all types or classifiers. If no matches are found
             // then it can be added to the results.
@@ -184,15 +191,15 @@
         return result;
     }
 
-
-    
     /**
-     * Should return the type or classifier of the given artifact, so that we can filter it
+     * Should return the type or classifier of the given artifact, so that we
+     * can filter it
      * 
-     * @param artifact  artifact to return type or classifier of
+     * @param artifact
+     *            artifact to return type or classifier of
      * @return type or classifier
      */
-    protected abstract String getArtifactFeature(Artifact artifact);
+    protected abstract String getArtifactFeature( Artifact artifact );
 
     public void setExcludes( String excludeString )
     {
@@ -203,7 +210,6 @@
             this.excludes = Arrays.asList( StringUtils.split( excludeString, "," ) );
         }
     }
-
 
     public void setIncludes( String includeString )
     {

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java Wed Nov 29 19:17:27 2006
@@ -43,6 +43,7 @@
 
 import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
 
@@ -55,4 +56,6 @@
     public Set filter( Set artifacts, Log log )
         throws MojoExecutionException;
 
+    public boolean okToProcess( Artifact artifact, Log log )
+        throws MojoExecutionException;
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java Wed Nov 29 19:17:27 2006
@@ -48,15 +48,18 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * @author brianf
  * 
  */
 public class DestFileFilter
-    implements ArtifactsFilter
+    extends AbstractArtifactsFilter
+    implements ArtifactItemFilter
 {
 
     boolean overWriteReleases;
@@ -73,7 +76,7 @@
 
     File outputFileDirectory;
 
-    public DestFileFilter (File outputFileDirectory)
+    public DestFileFilter( File outputFileDirectory )
     {
         this.outputFileDirectory = outputFileDirectory;
         overWriteReleases = false;
@@ -83,6 +86,7 @@
         useSubDirectoryPerType = false;
         removeVersion = false;
     }
+
     public DestFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer,
                           boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType, boolean removeVersion,
                           File outputFileDirectory )
@@ -112,7 +116,7 @@
         while ( iter.hasNext() )
         {
             Artifact artifact = (Artifact) iter.next();
-            if ( okToProcess( artifact ) )
+            if (okToProcess( new ArtifactItem(artifact) ) )
             {
                 result.add( artifact );
             }
@@ -120,32 +124,6 @@
         return result;
     }
 
-    public boolean okToProcess( Artifact artifact )
-        throws MojoExecutionException
-    {
-        boolean overWrite = false;
-        boolean result = false;
-        if ( ( artifact.isSnapshot() && this.overWriteSnapshots )
-            || ( !artifact.isSnapshot() && this.overWriteReleases ) )
-        {
-            overWrite = true;
-        }
-
-        File destFolder = DependencyUtil.getFormattedOutputDirectory( this.useSubDirectoryPerType,
-                                                                      this.useSubDirectoryPerArtifact,
-                                                                      this.outputFileDirectory, artifact );
-        File destFile = new File( destFolder, DependencyUtil.getFormattedFileName( artifact, this.removeVersion ) );
-
-        if ( overWrite
-            || ( !destFile.exists() || ( overWriteIfNewer && artifact.getFile().lastModified() < destFile
-                .lastModified() ) ) )
-        {
-            result = true;
-        }
-
-        return result;
-    }
-
     /**
      * @return Returns the overWriteReleases.
      */
@@ -196,6 +174,7 @@
     {
         this.overWriteIfNewer = overWriteIfNewer;
     }
+
     /**
      * @return Returns the outputFileDirectory.
      */
@@ -203,13 +182,16 @@
     {
         return this.outputFileDirectory;
     }
+
     /**
-     * @param outputFileDirectory The outputFileDirectory to set.
+     * @param outputFileDirectory
+     *            The outputFileDirectory to set.
      */
     public void setOutputFileDirectory( File outputFileDirectory )
     {
         this.outputFileDirectory = outputFileDirectory;
     }
+
     /**
      * @return Returns the removeVersion.
      */
@@ -217,13 +199,16 @@
     {
         return this.removeVersion;
     }
+
     /**
-     * @param removeVersion The removeVersion to set.
+     * @param removeVersion
+     *            The removeVersion to set.
      */
     public void setRemoveVersion( boolean removeVersion )
     {
         this.removeVersion = removeVersion;
     }
+
     /**
      * @return Returns the useSubDirectoryPerArtifact.
      */
@@ -231,13 +216,16 @@
     {
         return this.useSubDirectoryPerArtifact;
     }
+
     /**
-     * @param useSubDirectoryPerArtifact The useSubDirectoryPerArtifact to set.
+     * @param useSubDirectoryPerArtifact
+     *            The useSubDirectoryPerArtifact to set.
      */
     public void setUseSubDirectoryPerArtifact( boolean useSubDirectoryPerArtifact )
     {
         this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact;
     }
+
     /**
      * @return Returns the useSubDirectoryPerType.
      */
@@ -245,11 +233,51 @@
     {
         return this.useSubDirectoryPerType;
     }
+
     /**
-     * @param useSubDirectoryPerType The useSubDirectoryPerType to set.
+     * @param useSubDirectoryPerType
+     *            The useSubDirectoryPerType to set.
      */
     public void setUseSubDirectoryPerType( boolean useSubDirectoryPerType )
     {
         this.useSubDirectoryPerType = useSubDirectoryPerType;
+    }
+
+    public boolean okToProcess( ArtifactItem item )
+    {
+        boolean overWrite = false;
+        boolean result = false;
+        Artifact artifact = item.getArtifact();
+        
+        if ( ( artifact.isSnapshot() && this.overWriteSnapshots )
+            || ( !artifact.isSnapshot() && this.overWriteReleases ) )
+        {
+            overWrite = true;
+        }
+
+        File destFolder = item.getOutputDirectory();
+        if ( destFolder == null )
+        {
+            destFolder = DependencyUtil.getFormattedOutputDirectory( this.useSubDirectoryPerType, this.useSubDirectoryPerArtifact,
+                                                        this.outputFileDirectory, artifact );
+        }
+        
+        File destFile = null;
+        if (StringUtils.isEmpty(item.getDestFileName()))
+        {
+            destFile = new File( destFolder, DependencyUtil.getFormattedFileName( artifact, this.removeVersion ) );
+        }
+        else
+        {
+            destFile = new File (destFolder,item.getDestFileName());
+        }   
+     
+        if ( overWrite
+            || ( !destFile.exists() || ( overWriteIfNewer && artifact.getFile().lastModified() > destFile
+                .lastModified() ) ) )
+        {
+            result = true;
+        }
+        return result;
     }
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java Wed Nov 29 19:17:27 2006
@@ -55,7 +55,7 @@
  * 
  */
 public class MarkerFileFilter
-    implements ArtifactsFilter
+    extends AbstractArtifactsFilter
 {
 
     boolean overWriteReleases;
@@ -91,7 +91,7 @@
         while ( iter.hasNext() )
         {
             Artifact artifact = (Artifact) iter.next();
-            if ( okToProcess( artifact ) )
+            if ( doOverwrite( artifact ) )
             {
                 result.add( artifact );
             }
@@ -99,7 +99,7 @@
         return result;
     }
 
-    public boolean okToProcess( Artifact artifact )
+    protected boolean doOverwrite( Artifact artifact )
         throws MojoExecutionException
     {
         boolean overWrite = false;

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java?view=diff&rev=480816&r1=480815&r2=480816
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java Wed Nov 29 19:17:27 2006
@@ -58,11 +58,10 @@
         super( true, true, true, handler );
     }
 
-    public boolean okToProcess( Artifact artifact )
+    protected boolean doOverwrite( Artifact artifact )
         throws MojoExecutionException
-    {
+    {        
         handler.setArtifact( artifact );
-
         return ( !handler.isMarkerSet() );
     }
 }