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:07:07 UTC
svn commit: r480814 - in
/maven/plugins/branches/maven-dependency-plugin-copy-refactor: ./
src/main/java/org/apache/maven/plugin/dependency/
src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/
src/main/java/org/apache/maven/plugin/depen...
Author: brianf
Date: Wed Nov 29 19:07:05 2006
New Revision: 480814
URL: http://svn.apache.org/viewvc?view=rev&rev=480814
Log:
made a copy
Added:
maven/plugins/branches/maven-dependency-plugin-copy-refactor/
- copied from r477461, maven/plugins/trunk/maven-dependency-plugin/
maven/plugins/branches/maven-dependency-plugin-copy-refactor/NOTICE
- copied unchanged from r477462, maven/plugins/trunk/maven-dependency-plugin/NOTICE
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
- copied unchanged from r477502, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
- copied, changed from r478674, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
- copied, changed from r478674, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
- copied, changed from r477502, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
- copied, changed from r477502, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
- copied unchanged from r478674, maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/
- copied from r480813, maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/resources/unit/copy-dependencies-test/plugin-config.xml
- copied unchanged from r477462, maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/resources/unit/copy-test/plugin-config.xml
- copied unchanged from r477462, maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-test/plugin-config.xml
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/resources/unit/resolve-test/plugin-config.xml
- copied unchanged from r477462, maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/resolve-test/plugin-config.xml
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml
- copied unchanged from r477462, maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml
Modified:
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TransitivityFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java
maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java
Copied: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java (from r478674, 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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?view=diff&rev=480814&p1=maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java&r1=478674&p2=maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java&r2=480814
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java Wed Nov 29 19:07:05 2006
@@ -31,6 +31,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;
/**
@@ -93,6 +94,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
@@ -110,11 +113,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() )
{
@@ -127,35 +130,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
@@ -214,13 +226,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." );
}
}
Copied: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java (from r478674, 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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java?view=diff&rev=480814&p1=maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java&r1=478674&p2=maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java&r2=480814
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java Wed Nov 29 19:07:05 2006
@@ -22,7 +22,6 @@
import java.io.File;
import org.apache.maven.artifact.Artifact;
-import org.codehaus.plexus.archiver.util.FilterSupport;
import org.codehaus.plexus.util.StringUtils;
/**
@@ -94,7 +93,7 @@
/**
* Force Overwrite
*/
- private boolean doOverWrite;
+ private boolean needsProcessing;
/**
* Artifact Item
@@ -118,7 +117,7 @@
private final String filterEmptyString(String in)
{
- if (in.equals(""))
+ if (in == null || in.equals(""))
{
return null;
}
@@ -259,20 +258,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;
}
/**
Copied: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java (from r477502, 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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java?view=diff&rev=480814&p1=maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java&r1=477502&p2=maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java&r2=480814
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java Wed Nov 29 19:07:05 2006
@@ -26,6 +26,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;
/**
@@ -68,7 +70,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());
+ }
}
}
@@ -87,35 +96,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.
*/
Copied: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java (from r477502, 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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java?view=diff&rev=480814&p1=maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java&r1=477502&p2=maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java&r2=480814
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java Wed Nov 29 19:07:05 2006
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.maven.plugin.dependency.fromConfiguration;
import java.io.File;
@@ -27,6 +26,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;
@@ -67,12 +68,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." );
+ }
}
}
@@ -95,17 +103,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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java Wed Nov 29 19:07:05 2006
@@ -20,6 +20,7 @@
package org.apache.maven.plugin.dependency.utils.filters;
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;
@@ -34,7 +35,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;
@@ -46,17 +49,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.
@@ -72,14 +78,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 );
}
}
@@ -110,9 +116,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 );
}
@@ -141,7 +148,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.
@@ -165,15 +172,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 )
{
@@ -184,7 +191,6 @@
this.excludes = Arrays.asList( StringUtils.split( excludeString, "," ) );
}
}
-
public void setIncludes( String includeString )
{
Added: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java?view=auto&rev=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java (added)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java Wed Nov 29 19:07:05 2006
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.dependency.utils.filters;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+
+public abstract class AbstractArtifactsFilter
+ implements ArtifactsFilter
+{
+
+ public boolean okToProcess( Artifact artifact, Log log )
+ throws MojoExecutionException
+ {
+ Set set = new HashSet();
+ set.add( artifact );
+
+ set = filter( set, log );
+ return set.contains( artifact );
+ }
+}
Added: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java?view=auto&rev=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java (added)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java Wed Nov 29 19:07:05 2006
@@ -0,0 +1,34 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ *
+ */
+package org.apache.maven.plugin.dependency.utils.filters;
+
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
+
+/**
+ * @author brianf
+ *
+ */
+public interface ArtifactItemFilter
+{
+
+ public boolean okToProcess ( ArtifactItem item);
+}
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java Wed Nov 29 19:07:05 2006
@@ -24,6 +24,7 @@
import java.util.Set;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
@@ -36,4 +37,6 @@
public Set filter( Set artifacts, Log log )
throws MojoExecutionException;
+ public boolean okToProcess( Artifact artifact, Log log )
+ throws MojoExecutionException;
}
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java Wed Nov 29 19:07:05 2006
@@ -29,15 +29,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;
@@ -54,7 +57,7 @@
File outputFileDirectory;
- public DestFileFilter (File outputFileDirectory)
+ public DestFileFilter( File outputFileDirectory )
{
this.outputFileDirectory = outputFileDirectory;
overWriteReleases = false;
@@ -64,6 +67,7 @@
useSubDirectoryPerType = false;
removeVersion = false;
}
+
public DestFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer,
boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType, boolean removeVersion,
File outputFileDirectory )
@@ -93,7 +97,7 @@
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
- if ( okToProcess( artifact ) )
+ if (okToProcess( new ArtifactItem(artifact) ) )
{
result.add( artifact );
}
@@ -101,32 +105,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.
*/
@@ -177,6 +155,7 @@
{
this.overWriteIfNewer = overWriteIfNewer;
}
+
/**
* @return Returns the outputFileDirectory.
*/
@@ -184,13 +163,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.
*/
@@ -198,13 +180,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.
*/
@@ -212,13 +197,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.
*/
@@ -226,11 +214,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/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java Wed Nov 29 19:07:05 2006
@@ -36,7 +36,7 @@
*
*/
public class MarkerFileFilter
- implements ArtifactsFilter
+ extends AbstractArtifactsFilter
{
boolean overWriteReleases;
@@ -72,7 +72,7 @@
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
- if ( okToProcess( artifact ) )
+ if ( doOverwrite( artifact ) )
{
result.add( artifact );
}
@@ -80,7 +80,7 @@
return result;
}
- public boolean okToProcess( Artifact artifact )
+ protected boolean doOverwrite( Artifact artifact )
throws MojoExecutionException
{
boolean overWrite = false;
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java Wed Nov 29 19:07:05 2006
@@ -39,11 +39,10 @@
super( true, true, true, handler );
}
- public boolean okToProcess( Artifact artifact )
+ protected boolean doOverwrite( Artifact artifact )
throws MojoExecutionException
- {
+ {
handler.setArtifact( artifact );
-
return ( !handler.isMarkerSet() );
}
}
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java Wed Nov 29 19:07:05 2006
@@ -30,7 +30,7 @@
import org.codehaus.plexus.util.StringUtils;
public class ScopeFilter
- implements ArtifactsFilter
+ extends AbstractArtifactsFilter
{
private String includeScope;
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TransitivityFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TransitivityFilter.java?view=diff&rev=480814&r1=477461&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TransitivityFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TransitivityFilter.java Wed Nov 29 19:07:05 2006
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.maven.plugin.dependency.utils.filters;
import java.util.HashSet;
@@ -28,7 +27,7 @@
import org.apache.maven.plugin.logging.Log;
public class TransitivityFilter
- implements ArtifactsFilter
+ extends AbstractArtifactsFilter
{
private boolean excludeTransitive;
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java?view=diff&rev=480814&r1=480813&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java Wed Nov 29 19:07:05 2006
@@ -104,10 +104,7 @@
File destFile = new File( folder, stubFactory.getUnpackableFileName( artifact ) );
- /*
- * System.out.println( "Checking file: " + destFile.getPath() ); if (
- * val != destFile.exists() ) { System.out.println( "FAIL!" ); }
- */
+
assertEquals( val, destFile.exists() );
assertMarkerFile( val, artifact );
}
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java?view=diff&rev=480814&r1=480813&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java Wed Nov 29 19:07:05 2006
@@ -22,9 +22,12 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Dependency;
@@ -33,6 +36,7 @@
import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
import org.apache.maven.plugin.dependency.testUtils.stubs.StubArtifactRepository;
import org.apache.maven.plugin.dependency.testUtils.stubs.StubArtifactResolver;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
import org.apache.maven.project.MavenProject;
public class TestCopyMojo
@@ -88,26 +92,11 @@
mojo.artifactItems = list;
ArtifactItem result = getSingleArtifactItem( false );
- assertFalse( result.isDoOverWrite() );
-
- item.setOverWrite( "true" );
- result = getSingleArtifactItem( false );
- assertTrue( result.isDoOverWrite() );
assertEquals( mojo.outputDirectory, result.getOutputDirectory() );
- item.setOverWrite( "false" );
- result = getSingleArtifactItem( false );
- assertFalse( result.isDoOverWrite() );
-
- item.setOverWrite( "" );
- result = getSingleArtifactItem( false );
- assertFalse( result.isDoOverWrite() );
-
- item.setOverWrite( "blah" );
File output = new File( mojo.outputDirectory, "override" );
item.setOutputDirectory( output );
result = getSingleArtifactItem( false );
- assertFalse( result.isDoOverWrite() );
assertEquals( output, result.getOutputDirectory() );
}
@@ -290,28 +279,29 @@
assertEquals( "2.1", item.getVersion() );
}
- public List getDependencyMgtList(ArtifactItem item)
+ public List getDependencyMgtList( ArtifactItem item )
{
Dependency dep = new Dependency();
- dep.setArtifactId(item.getArtifactId());
- dep.setClassifier(item.getClassifier());
- dep.setGroupId(item.getGroupId());
- dep.setType(item.getType());
- dep.setVersion("3.0-SNAPSHOT");
-
+ dep.setArtifactId( item.getArtifactId() );
+ dep.setClassifier( item.getClassifier() );
+ dep.setGroupId( item.getGroupId() );
+ dep.setType( item.getType() );
+ dep.setVersion( "3.0-SNAPSHOT" );
+
Dependency dep2 = new Dependency();
- dep2.setArtifactId(item.getArtifactId());
- dep2.setClassifier("classifier");
- dep2.setGroupId(item.getGroupId());
- dep2.setType(item.getType());
- dep2.setVersion("3.1");
-
- List list = new ArrayList(2);
- list.add(dep2);
- list.add(dep);
-
+ dep2.setArtifactId( item.getArtifactId() );
+ dep2.setClassifier( "classifier" );
+ dep2.setGroupId( item.getGroupId() );
+ dep2.setType( item.getType() );
+ dep2.setVersion( "3.1" );
+
+ List list = new ArrayList( 2 );
+ list.add( dep2 );
+ list.add( dep );
+
return list;
}
+
public void testMissingVersionFromDependencyMgt()
throws MojoExecutionException
{
@@ -321,8 +311,7 @@
item.setClassifier( "" );
item.setGroupId( "groupId" );
item.setType( "type" );
-
-
+
MavenProject project = mojo.getProject();
project.setDependencies( getDependencyList( item ) );
@@ -335,114 +324,260 @@
ArrayList list = new ArrayList();
list.add( item );
-
+
mojo.artifactItems = list;
project.getDependencyManagement().setDependencies( getDependencyMgtList( item ) );
mojo.execute();
- System.out.println("resolved:"+item.toString());
+
this.assertFileExists( item, true );
assertEquals( "3.0-SNAPSHOT", item.getVersion() );
}
+
public void testMissingVersionFromDependencyMgtWithClassifier()
- throws MojoExecutionException
-{
- ArtifactItem item = new ArtifactItem();
+ throws MojoExecutionException
+ {
+ ArtifactItem item = new ArtifactItem();
- item.setArtifactId( "artifactId" );
- item.setClassifier( "classifier" );
- item.setGroupId( "groupId" );
- item.setType( "type" );
-
-
- MavenProject project = mojo.getProject();
- project.setDependencies( getDependencyList( item ) );
+ item.setArtifactId( "artifactId" );
+ item.setClassifier( "classifier" );
+ item.setGroupId( "groupId" );
+ item.setType( "type" );
- item = new ArtifactItem();
+ MavenProject project = mojo.getProject();
+ project.setDependencies( getDependencyList( item ) );
- item.setArtifactId( "artifactId-2" );
- item.setClassifier( "classifier" );
- item.setGroupId( "groupId" );
- item.setType( "type" );
+ item = new ArtifactItem();
- ArrayList list = new ArrayList();
- list.add( item );
-
- mojo.artifactItems = list;
+ item.setArtifactId( "artifactId-2" );
+ item.setClassifier( "classifier" );
+ item.setGroupId( "groupId" );
+ item.setType( "type" );
- project.getDependencyManagement().setDependencies( getDependencyMgtList( item ) );
+ ArrayList list = new ArrayList();
+ list.add( item );
- mojo.execute();
- System.out.println("resolved:"+item.toString());
- this.assertFileExists( item, true );
- assertEquals( "3.1", item.getVersion() );
-}
-
- public void testArtifactNotFound()
- throws Exception
-{
- dotestArtifactExceptions( false, true );
-}
+ mojo.artifactItems = list;
-public void testArtifactResolutionException()
- throws Exception
-{
- dotestArtifactExceptions( true, false );
-}
+ project.getDependencyManagement().setDependencies( getDependencyMgtList( item ) );
-public void dotestArtifactExceptions( boolean are, boolean anfe )
- throws Exception
-{
- ArtifactItem item = new ArtifactItem();
+ mojo.execute();
- item.setArtifactId( "artifactId" );
- item.setClassifier( "" );
- item.setGroupId( "groupId" );
- item.setType( "type" );
- item.setVersion("1.0");
+ this.assertFileExists( item, true );
+ assertEquals( "3.1", item.getVersion() );
+ }
- ArrayList list = new ArrayList();
- list.add( item );
- mojo.artifactItems = list;
-
- // init classifier things
- mojo.setFactory(DependencyTestUtils.getArtifactFactory());
- mojo.setResolver(new StubArtifactResolver( null, are, anfe ));
- mojo.setLocal(new StubArtifactRepository( this.testDir.getAbsolutePath() ));
+ public void testArtifactNotFound()
+ throws Exception
+ {
+ dotestArtifactExceptions( false, true );
+ }
- try
+ public void testArtifactResolutionException()
+ throws Exception
{
- mojo.execute();
- fail( "ExpectedException" );
+ dotestArtifactExceptions( true, false );
+ }
+
+ public void dotestArtifactExceptions( boolean are, boolean anfe )
+ throws Exception
+ {
+ ArtifactItem item = new ArtifactItem();
+
+ item.setArtifactId( "artifactId" );
+ item.setClassifier( "" );
+ item.setGroupId( "groupId" );
+ item.setType( "type" );
+ item.setVersion( "1.0" );
+
+ ArrayList list = new ArrayList();
+ list.add( item );
+ mojo.artifactItems = list;
+
+ // init classifier things
+ mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
+ mojo.setResolver( new StubArtifactResolver( null, are, anfe ) );
+ mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
+
+ try
+ {
+ mojo.execute();
+ fail( "ExpectedException" );
+ }
+ catch ( MojoExecutionException e )
+ {
+ if ( are )
+ {
+ assertEquals( "Unable to resolve artifact.", e.getMessage() );
+ }
+ else
+ {
+ assertEquals( "Unable to find artifact.", e.getMessage() );
+ }
+ }
}
- catch ( MojoExecutionException e )
+
+ public void testNoArtifactItems()
{
- if (are)
+ try
{
- assertEquals("Unable to resolve artifact.",e.getMessage());
+ mojo.getArtifactItems( false );
+ fail( "Expected Exception" );
}
- else
+ catch ( MojoExecutionException e )
{
- assertEquals("Unable to find artifact.",e.getMessage());
+ assertEquals( "There are no artifactItems configured.", e.getMessage() );
}
+
}
-}
-public void testNoArtifactItems()
-{
- try
+ public void testCopyDontOverWriteReleases()
+ throws IOException, MojoExecutionException, InterruptedException
+ {
+ stubFactory.setCreateFiles( true );
+ Artifact release = stubFactory.getReleaseArtifact();
+ release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ ArtifactItem item = new ArtifactItem( release );
+
+ ArrayList list = new ArrayList( 1 );
+ list.add( item );
+ mojo.artifactItems = list;
+
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
+
+ Thread.sleep( 100 );
+ // round up to the next second
+ long time = System.currentTimeMillis() + 1000;
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ Thread.sleep( 100 );
+
+ mojo.execute();
+
+ assertEquals( time, copiedFile.lastModified() );
+ }
+
+ public void testCopyDontOverWriteSnapshots()
+ throws IOException, MojoExecutionException, InterruptedException
+ {
+ stubFactory.setCreateFiles( true );
+ Artifact artifact = stubFactory.getSnapshotArtifact();
+ artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ ArtifactItem item = new ArtifactItem( artifact );
+
+ ArrayList list = new ArrayList( 1 );
+ list.add( item );
+ mojo.artifactItems = list;
+
+ mojo.overWriteIfNewer = false;
+
+ mojo.execute();
+
+ File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
+
+ Thread.sleep( 100 );
+ // round up to the next second
+ long time = System.currentTimeMillis() + 1000;
+ time = time - ( time % 1000 );
+ copiedFile.setLastModified( time );
+ Thread.sleep( 100 );
+
+ mojo.execute();
+
+ assertEquals( time, copiedFile.lastModified() );
+ }
+
+ public void testCopyOverWriteReleases()
+ throws IOException, MojoExecutionException, InterruptedException
{
- mojo.getArtifactItems(false);
- fail("Expected Exception");
+ stubFactory.setCreateFiles( true );
+ Artifact release = stubFactory.getReleaseArtifact();
+ release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ ArtifactItem item = new ArtifactItem( release );
+
+ ArrayList list = new ArrayList( 1 );
+ list.add( item );
+ mojo.artifactItems = list;
+
+ mojo.overWriteIfNewer = false;
+ mojo.overWriteReleases = true;
+ mojo.execute();
+
+ File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
+
+ // round up to the next second
+ long time = System.currentTimeMillis() - 2000;
+ copiedFile.setLastModified( time );
+
+ mojo.execute();
+
+ assertTrue( time < copiedFile.lastModified() );
}
- catch ( MojoExecutionException e )
+
+ public void testCopyOverWriteSnapshot()
+ throws IOException, MojoExecutionException, InterruptedException
{
- assertEquals("There are no artifactItems configured.",e.getMessage());
+ stubFactory.setCreateFiles( true );
+ Artifact artifact = stubFactory.getSnapshotArtifact();
+ artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ ArtifactItem item = new ArtifactItem( artifact );
+
+ ArrayList list = new ArrayList( 1 );
+ list.add( item );
+ mojo.artifactItems = list;
+
+ mojo.overWriteIfNewer = false;
+ mojo.overWriteReleases = false;
+ mojo.overWriteSnapshots = true;
+ mojo.execute();
+
+ File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
+
+ // round up to the next second
+ long time = System.currentTimeMillis() - 2000;
+ copiedFile.setLastModified( time );
+
+ mojo.execute();
+
+ assertTrue( time < copiedFile.lastModified() );
}
-}
+ public void testCopyOverWriteIfNewer()
+ throws IOException, MojoExecutionException, InterruptedException
+{
+ stubFactory.setCreateFiles( true );
+ Artifact artifact = stubFactory.getSnapshotArtifact();
+ artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 );
+
+ ArtifactItem item = new ArtifactItem( artifact );
+
+ ArrayList list = new ArrayList( 1 );
+ list.add( item );
+ mojo.artifactItems = list;
+ mojo.overWriteIfNewer = true;
+ mojo.execute();
+
+ File copiedFile = new File( item.getOutputDirectory(), item.getDestFileName() );
+
+ // set dest to be old
+ long time = System.currentTimeMillis() - 10000;
+ copiedFile.setLastModified( time );
+ //set source to be newer
+ artifact.getFile().setLastModified(time + 4000);
+ mojo.execute();
+
+ assertTrue( time < copiedFile.lastModified() );
+}
// TODO: test overwrite / overwrite if newer / overwrite release / overwrite
// snapshot
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java?view=diff&rev=480814&r1=480813&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java Wed Nov 29 19:07:05 2006
@@ -115,12 +115,12 @@
DestFileFilter filter = new DestFileFilter( outputFolder );
Artifact artifact = fact.getReleaseArtifact();
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
createFile( artifact );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
filter.overWriteReleases = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log));
}
public void testDestFileSnapshot()
@@ -129,12 +129,12 @@
DestFileFilter filter = new DestFileFilter( outputFolder );
Artifact artifact = fact.getSnapshotArtifact();
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
createFile( artifact );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
filter.overWriteSnapshots = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
}
public void testDestFileStripVersion()
@@ -144,12 +144,12 @@
Artifact artifact = fact.getSnapshotArtifact();
filter.removeVersion = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
createFile( artifact, false, false, true );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
filter.overWriteSnapshots = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
}
public void testDestFileSubPerArtifact()
@@ -159,12 +159,12 @@
Artifact artifact = fact.getSnapshotArtifact();
filter.useSubDirectoryPerArtifact = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
createFile( artifact, true, false, false );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
filter.overWriteSnapshots = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
}
public void testDestFileSubPerType()
@@ -174,12 +174,12 @@
Artifact artifact = fact.getSnapshotArtifact();
filter.useSubDirectoryPerType = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
createFile( artifact, false, true, false );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
filter.overWriteSnapshots = true;
- assertTrue( filter.okToProcess( artifact ) );
+ assertTrue( filter.okToProcess( artifact ,log) );
}
public void testDestFileOverwriteIfNewer()
@@ -190,17 +190,23 @@
fact.setCreateFiles( true );
Artifact artifact = fact.getSnapshotArtifact();
File artifactFile = artifact.getFile();
- artifactFile.setLastModified( artifactFile.lastModified() - 1000 );
+ artifactFile.setLastModified( artifactFile.lastModified() );
filter.overWriteIfNewer = true;
- assertTrue( filter.okToProcess( artifact ) );
+ //should pass because the file doesn't exist yet.
+ assertTrue( filter.okToProcess( artifact ,log) );
+ //create the file in the destination
File destFile = createFile( artifact, false, false, false );
- assertTrue( filter.okToProcess( artifact ) );
+
+ //set the last modified timestamp to be older than the source
+ destFile.setLastModified( artifactFile.lastModified()-1000 );
+ assertTrue( filter.okToProcess( artifact ,log) );
- destFile.setLastModified( destFile.lastModified() - 2000 );
+ //now set the last modified timestamp to be newer than the source
+ destFile.setLastModified( artifactFile.lastModified() + 1000 );
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact ,log) );
}
public void testGettersSetters()
Modified: maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java?view=diff&rev=480814&r1=480813&r2=480814
==============================================================================
--- maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java (original)
+++ maven/plugins/branches/maven-dependency-plugin-copy-refactor/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java Wed Nov 29 19:07:05 2006
@@ -83,7 +83,8 @@
artifacts = fact.getReleaseAndSnapshotArtifacts();
}
- protected void tearDown() throws IOException
+ protected void tearDown()
+ throws IOException
{
DependencyTestUtils.removeDirectory( outputFolder );
}
@@ -92,16 +93,15 @@
throws MojoExecutionException, IOException
{
SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler( outputFolder );
- ResolveFileFilter filter = new ResolveFileFilter( handler );
-
- handler = new SourcesFileMarkerHandler( outputFolder );
-
+
Artifact artifact = fact.getReleaseArtifact();
handler.setArtifact( artifact );
-
- assertTrue( filter.okToProcess( artifact ) );
+
+ ResolveFileFilter filter = new ResolveFileFilter( handler );
+
+ assertTrue( filter.okToProcess( artifact , log));
handler.setMarker();
- assertFalse( filter.okToProcess( artifact ) );
+ assertFalse( filter.okToProcess( artifact, log ));
}
}