You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2007/07/02 18:06:24 UTC
svn commit: r552524 [2/9] - in /maven/plugins/trunk/maven-dependency-plugin:
./ src/changes/ src/it/copy-dependencies/ src/it/copy-dependencies2/
src/it/mdep-27/ src/it/mdep-50/ src/it/mdep-61/ src/it/mdep-66/
src/it/mdep-67/ src/main/java/org/apache/m...
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java Mon Jul 2 09:06:19 2007
@@ -1,435 +1,435 @@
-package org.apache.maven.plugin.dependency;
-
-/*
- * 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.BufferedReader;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
-import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.AndDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.ArtifactDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.StateDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.TreeTokens;
-
-/**
- * Displays the dependency tree for this project.
- *
- * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
- * @since 2.0-alpha-5
- * @goal tree
- * @requiresDependencyResolution test
- */
-public class TreeMojo extends AbstractMojo
-{
- // fields -----------------------------------------------------------------
-
- /**
- * The Maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * The artifact repository to use.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- */
- private ArtifactRepository localRepository;
-
- /**
- * The artifact factory to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactFactory artifactFactory;
-
- /**
- * The artifact metadata source to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactMetadataSource artifactMetadataSource;
-
- /**
- * The artifact collector to use.
- *
- * @component
- * @required
- * @readonly
- */
- private ArtifactCollector artifactCollector;
-
- /**
- * The dependency tree builder to use.
- *
- * @component
- * @required
- * @readonly
- */
- private DependencyTreeBuilder dependencyTreeBuilder;
-
- /**
- * If specified, this parameter will cause the dependency tree to be written to the path specified, instead of
- * writing to the console.
- *
- * @parameter expression="${output}"
- */
- private File output;
-
- /**
- * The computed dependency tree root node of the Maven project.
- */
- private DependencyNode rootNode;
-
- /**
- * The scope to filter by when resolving the dependency tree, or <code>null</code> to include dependencies from
- * all scopes.
- *
- * @parameter expression="${scope}"
- */
- private String scope;
-
- /**
- * Whether to include omitted nodes in the serialized dependency tree.
- *
- * @parameter expression="${verbose}" default-value="false"
- */
- private boolean verbose;
-
- /**
- * The token set name to use when outputting the dependency tree. Possible values are <code>whitespace</code>,
- * <code>standard</code> or <code>extended</code>, which use whitespace, standard or extended ASCII sets
- * respectively.
- *
- * @parameter expression="${tokens}" default-value="standard"
- */
- private String tokens;
-
- /**
- * A comma-separated list of artifacts to filter the serialized dependency tree by, or <code>null</code> not to
- * filter the dependency tree. The artifact syntax is defined by <code>StrictPatternIncludesArtifactFilter</code>.
- *
- * @see StrictPatternIncludesArtifactFilter
- * @parameter expression="${includes}"
- */
- private String includes;
-
- /**
- * A comma-separated list of artifacts to filter from the serialized dependency tree, or <code>null</code> not to
- * filter any artifacts from the dependency tree. The artifact syntax is defined by
- * <code>StrictPatternExcludesArtifactFilter</code>.
- *
- * @see StrictPatternExcludesArtifactFilter
- * @parameter expression="${excludes}"
- */
- private String excludes;
-
- // Mojo methods -----------------------------------------------------------
-
- /*
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException
- {
- ArtifactFilter artifactFilter = createResolvingArtifactFilter();
-
- try
- {
- // TODO: fix DependencyTreeBuilder to apply filter
- rootNode =
- dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
- artifactMetadataSource, artifactFilter, artifactCollector );
-
- String dependencyTreeString = serialiseDependencyTree( rootNode );
-
- if ( output != null )
- {
- write( dependencyTreeString, output );
-
- getLog().info( "Wrote dependency tree to: " + output );
- }
- else
- {
- log( dependencyTreeString );
- }
- }
- catch ( DependencyTreeBuilderException exception )
- {
- throw new MojoExecutionException( "Cannot build project dependency tree", exception );
- }
- catch ( IOException exception )
- {
- throw new MojoExecutionException( "Cannot serialise project dependency tree", exception );
- }
- }
-
- // public methods ---------------------------------------------------------
-
- /**
- * Gets the Maven project used by this mojo.
- *
- * @return the Maven project
- */
- public MavenProject getProject()
- {
- return project;
- }
-
- /**
- * Gets the computed dependency tree root node for the Maven project.
- *
- * @return the dependency tree root node
- */
- public DependencyNode getDependencyTree()
- {
- return rootNode;
- }
-
- // private methods --------------------------------------------------------
-
- /**
- * Gets the artifact filter to use when resolving the dependency tree.
- *
- * @return the artifact filter
- */
- private ArtifactFilter createResolvingArtifactFilter()
- {
- ArtifactFilter filter;
-
- // filter scope
- if ( scope != null )
- {
- getLog().debug( "+ Resolving dependency tree for scope '" + scope + "'" );
-
- filter = new ScopeArtifactFilter( scope );
- }
- else
- {
- filter = null;
- }
-
- return filter;
- }
-
- /**
- * Serialises the specified dependency tree to a string.
- *
- * @param rootNode
- * the dependency tree root node to serialise
- * @return the serialised dependency tree
- */
- private String serialiseDependencyTree( DependencyNode rootNode )
- {
- StringWriter writer = new StringWriter();
- TreeTokens treeTokens = toTreeTokens( tokens );
-
- DependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor( writer, treeTokens );
-
- // TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
- visitor = new BuildingDependencyNodeVisitor( visitor );
-
- DependencyNodeFilter filter = createDependencyNodeFilter();
-
- if ( filter != null )
- {
- CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
- DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor( collectingVisitor, filter );
- rootNode.accept( firstPassVisitor );
-
- DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
- visitor = new FilteringDependencyNodeVisitor( visitor, secondPassFilter );
- }
-
- rootNode.accept( visitor );
-
- return writer.toString();
- }
-
- /**
- * Gets the tree tokens instance for the specified name.
- *
- * @param tokens
- * the tree tokens name
- * @return the <code>TreeTokens</code> instance
- */
- private TreeTokens toTreeTokens( String tokens )
- {
- TreeTokens treeTokens;
-
- if ( "whitespace".equals( tokens ) )
- {
- getLog().debug( "+ Using whitespace tree tokens" );
-
- treeTokens = SerializingDependencyNodeVisitor.WHITESPACE_TOKENS;
- }
- else if ( "extended".equals( tokens ) )
- {
- getLog().debug( "+ Using extended tree tokens" );
-
- treeTokens = SerializingDependencyNodeVisitor.EXTENDED_TOKENS;
- }
- else
- {
- treeTokens = SerializingDependencyNodeVisitor.STANDARD_TOKENS;
- }
-
- return treeTokens;
- }
-
- /**
- * Gets the dependency node filter to use when serializing the dependency tree.
- *
- * @return the dependency node filter, or <code>null</code> if none required
- */
- private DependencyNodeFilter createDependencyNodeFilter()
- {
- List filters = new ArrayList();
-
- // filter node states
- if ( !verbose )
- {
- getLog().debug( "+ Filtering omitted nodes from dependency tree" );
-
- filters.add( StateDependencyNodeFilter.INCLUDED );
- }
-
- // filter includes
- if ( includes != null )
- {
- List patterns = Arrays.asList( includes.split( "," ) );
-
- getLog().debug( "+ Filtering dependency tree by artifact include patterns: " + patterns );
-
- ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter( patterns );
- filters.add( new ArtifactDependencyNodeFilter( artifactFilter ) );
- }
-
- // filter excludes
- if ( excludes != null )
- {
- List patterns = Arrays.asList( excludes.split( "," ) );
-
- getLog().debug( "+ Filtering dependency tree by artifact exclude patterns: " + patterns );
-
- ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter( patterns );
- filters.add( new ArtifactDependencyNodeFilter( artifactFilter ) );
- }
-
- return filters.isEmpty() ? null : new AndDependencyNodeFilter( filters );
- }
-
- /**
- * Writes the specified string to the specified file.
- *
- * @param string
- * the string to write
- * @param file
- * the file to write to
- * @throws IOException
- * if an I/O error occurs
- */
- private void write( String string, File file ) throws IOException
- {
- output.getParentFile().mkdirs();
-
- FileWriter writer = null;
-
- try
- {
- writer = new FileWriter( output );
-
- writer.write( string );
- }
- finally
- {
- if ( writer != null )
- {
- try
- {
- writer.close();
- }
- catch ( IOException exception )
- {
- getLog().error( "Cannot close file", exception );
- }
- }
- }
- }
-
- /**
- * Writes the specified string to the log at info level.
- *
- * @param string
- * the string to write
- * @throws IOException
- * if an I/O error occurs
- */
- private void log( String string ) throws IOException
- {
- BufferedReader reader = new BufferedReader( new StringReader( string ) );
-
- String line;
-
- while ( ( line = reader.readLine() ) != null )
- {
- getLog().info( line );
- }
-
- reader.close();
- }
-}
+package org.apache.maven.plugin.dependency;
+
+/*
+ * 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.BufferedReader;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
+import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
+import org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter;
+import org.apache.maven.shared.dependency.tree.filter.AndDependencyNodeFilter;
+import org.apache.maven.shared.dependency.tree.filter.ArtifactDependencyNodeFilter;
+import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
+import org.apache.maven.shared.dependency.tree.filter.StateDependencyNodeFilter;
+import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
+import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor;
+import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.TreeTokens;
+
+/**
+ * Displays the dependency tree for this project.
+ *
+ * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
+ * @version $Id$
+ * @since 2.0-alpha-5
+ * @goal tree
+ * @requiresDependencyResolution test
+ */
+public class TreeMojo extends AbstractMojo
+{
+ // fields -----------------------------------------------------------------
+
+ /**
+ * The Maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * The artifact repository to use.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * The artifact factory to use.
+ *
+ * @component
+ * @required
+ * @readonly
+ */
+ private ArtifactFactory artifactFactory;
+
+ /**
+ * The artifact metadata source to use.
+ *
+ * @component
+ * @required
+ * @readonly
+ */
+ private ArtifactMetadataSource artifactMetadataSource;
+
+ /**
+ * The artifact collector to use.
+ *
+ * @component
+ * @required
+ * @readonly
+ */
+ private ArtifactCollector artifactCollector;
+
+ /**
+ * The dependency tree builder to use.
+ *
+ * @component
+ * @required
+ * @readonly
+ */
+ private DependencyTreeBuilder dependencyTreeBuilder;
+
+ /**
+ * If specified, this parameter will cause the dependency tree to be written to the path specified, instead of
+ * writing to the console.
+ *
+ * @parameter expression="${output}"
+ */
+ private File output;
+
+ /**
+ * The computed dependency tree root node of the Maven project.
+ */
+ private DependencyNode rootNode;
+
+ /**
+ * The scope to filter by when resolving the dependency tree, or <code>null</code> to include dependencies from
+ * all scopes.
+ *
+ * @parameter expression="${scope}"
+ */
+ private String scope;
+
+ /**
+ * Whether to include omitted nodes in the serialized dependency tree.
+ *
+ * @parameter expression="${verbose}" default-value="false"
+ */
+ private boolean verbose;
+
+ /**
+ * The token set name to use when outputting the dependency tree. Possible values are <code>whitespace</code>,
+ * <code>standard</code> or <code>extended</code>, which use whitespace, standard or extended ASCII sets
+ * respectively.
+ *
+ * @parameter expression="${tokens}" default-value="standard"
+ */
+ private String tokens;
+
+ /**
+ * A comma-separated list of artifacts to filter the serialized dependency tree by, or <code>null</code> not to
+ * filter the dependency tree. The artifact syntax is defined by <code>StrictPatternIncludesArtifactFilter</code>.
+ *
+ * @see StrictPatternIncludesArtifactFilter
+ * @parameter expression="${includes}"
+ */
+ private String includes;
+
+ /**
+ * A comma-separated list of artifacts to filter from the serialized dependency tree, or <code>null</code> not to
+ * filter any artifacts from the dependency tree. The artifact syntax is defined by
+ * <code>StrictPatternExcludesArtifactFilter</code>.
+ *
+ * @see StrictPatternExcludesArtifactFilter
+ * @parameter expression="${excludes}"
+ */
+ private String excludes;
+
+ // Mojo methods -----------------------------------------------------------
+
+ /*
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ ArtifactFilter artifactFilter = createResolvingArtifactFilter();
+
+ try
+ {
+ // TODO: fix DependencyTreeBuilder to apply filter
+ rootNode =
+ dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
+ artifactMetadataSource, artifactFilter, artifactCollector );
+
+ String dependencyTreeString = serialiseDependencyTree( rootNode );
+
+ if ( output != null )
+ {
+ write( dependencyTreeString, output );
+
+ getLog().info( "Wrote dependency tree to: " + output );
+ }
+ else
+ {
+ log( dependencyTreeString );
+ }
+ }
+ catch ( DependencyTreeBuilderException exception )
+ {
+ throw new MojoExecutionException( "Cannot build project dependency tree", exception );
+ }
+ catch ( IOException exception )
+ {
+ throw new MojoExecutionException( "Cannot serialise project dependency tree", exception );
+ }
+ }
+
+ // public methods ---------------------------------------------------------
+
+ /**
+ * Gets the Maven project used by this mojo.
+ *
+ * @return the Maven project
+ */
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * Gets the computed dependency tree root node for the Maven project.
+ *
+ * @return the dependency tree root node
+ */
+ public DependencyNode getDependencyTree()
+ {
+ return rootNode;
+ }
+
+ // private methods --------------------------------------------------------
+
+ /**
+ * Gets the artifact filter to use when resolving the dependency tree.
+ *
+ * @return the artifact filter
+ */
+ private ArtifactFilter createResolvingArtifactFilter()
+ {
+ ArtifactFilter filter;
+
+ // filter scope
+ if ( scope != null )
+ {
+ getLog().debug( "+ Resolving dependency tree for scope '" + scope + "'" );
+
+ filter = new ScopeArtifactFilter( scope );
+ }
+ else
+ {
+ filter = null;
+ }
+
+ return filter;
+ }
+
+ /**
+ * Serialises the specified dependency tree to a string.
+ *
+ * @param rootNode
+ * the dependency tree root node to serialise
+ * @return the serialised dependency tree
+ */
+ private String serialiseDependencyTree( DependencyNode rootNode )
+ {
+ StringWriter writer = new StringWriter();
+ TreeTokens treeTokens = toTreeTokens( tokens );
+
+ DependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor( writer, treeTokens );
+
+ // TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
+ visitor = new BuildingDependencyNodeVisitor( visitor );
+
+ DependencyNodeFilter filter = createDependencyNodeFilter();
+
+ if ( filter != null )
+ {
+ CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
+ DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor( collectingVisitor, filter );
+ rootNode.accept( firstPassVisitor );
+
+ DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
+ visitor = new FilteringDependencyNodeVisitor( visitor, secondPassFilter );
+ }
+
+ rootNode.accept( visitor );
+
+ return writer.toString();
+ }
+
+ /**
+ * Gets the tree tokens instance for the specified name.
+ *
+ * @param tokens
+ * the tree tokens name
+ * @return the <code>TreeTokens</code> instance
+ */
+ private TreeTokens toTreeTokens( String tokens )
+ {
+ TreeTokens treeTokens;
+
+ if ( "whitespace".equals( tokens ) )
+ {
+ getLog().debug( "+ Using whitespace tree tokens" );
+
+ treeTokens = SerializingDependencyNodeVisitor.WHITESPACE_TOKENS;
+ }
+ else if ( "extended".equals( tokens ) )
+ {
+ getLog().debug( "+ Using extended tree tokens" );
+
+ treeTokens = SerializingDependencyNodeVisitor.EXTENDED_TOKENS;
+ }
+ else
+ {
+ treeTokens = SerializingDependencyNodeVisitor.STANDARD_TOKENS;
+ }
+
+ return treeTokens;
+ }
+
+ /**
+ * Gets the dependency node filter to use when serializing the dependency tree.
+ *
+ * @return the dependency node filter, or <code>null</code> if none required
+ */
+ private DependencyNodeFilter createDependencyNodeFilter()
+ {
+ List filters = new ArrayList();
+
+ // filter node states
+ if ( !verbose )
+ {
+ getLog().debug( "+ Filtering omitted nodes from dependency tree" );
+
+ filters.add( StateDependencyNodeFilter.INCLUDED );
+ }
+
+ // filter includes
+ if ( includes != null )
+ {
+ List patterns = Arrays.asList( includes.split( "," ) );
+
+ getLog().debug( "+ Filtering dependency tree by artifact include patterns: " + patterns );
+
+ ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter( patterns );
+ filters.add( new ArtifactDependencyNodeFilter( artifactFilter ) );
+ }
+
+ // filter excludes
+ if ( excludes != null )
+ {
+ List patterns = Arrays.asList( excludes.split( "," ) );
+
+ getLog().debug( "+ Filtering dependency tree by artifact exclude patterns: " + patterns );
+
+ ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter( patterns );
+ filters.add( new ArtifactDependencyNodeFilter( artifactFilter ) );
+ }
+
+ return filters.isEmpty() ? null : new AndDependencyNodeFilter( filters );
+ }
+
+ /**
+ * Writes the specified string to the specified file.
+ *
+ * @param string
+ * the string to write
+ * @param file
+ * the file to write to
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ private void write( String string, File file ) throws IOException
+ {
+ output.getParentFile().mkdirs();
+
+ FileWriter writer = null;
+
+ try
+ {
+ writer = new FileWriter( output );
+
+ writer.write( string );
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException exception )
+ {
+ getLog().error( "Cannot close file", exception );
+ }
+ }
+ }
+ }
+
+ /**
+ * Writes the specified string to the log at info level.
+ *
+ * @param string
+ * the string to write
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ private void log( String string ) throws IOException
+ {
+ BufferedReader reader = new BufferedReader( new StringReader( string ) );
+
+ String line;
+
+ while ( ( line = reader.readLine() ) != null )
+ {
+ getLog().info( line );
+ }
+
+ reader.close();
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencySilentLog.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
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=552524&r1=552523&r2=552524
==============================================================================
--- 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 Mon Jul 2 09:06:19 2007
@@ -1,249 +1,249 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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.Arrays;
-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.plugin.logging.Log;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * This is the common base class of ClassifierFilter and
- * TypeFilter
- *
- * @author <a href="richardv@mxtelecom.com">Richard van der
- * Hoff</a>
- * @version $Id: AbstractArtifactFeatureFilter.java 522374
- * 2007-03-25 22:58:03Z brianf $
- */
-public abstract class AbstractArtifactFeatureFilter
- extends AbstractArtifactsFilter
-{
- /** The list of types or classifiers to include */
- private List includes;
-
- /**
- * The list of types or classifiers to exclude (ignored
- * if includes != null)
- */
- private List excludes;
-
- /**
- * The configuration string for the include list - comma
- * separated
- */
- private String includeString;
-
- /**
- * 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"
- */
- private String featureName;
-
- public AbstractArtifactFeatureFilter( String include, String exclude, String theFeatureName )
- {
- setExcludes( exclude );
- setIncludes( include );
- featureName = theFeatureName;
- }
-
- /**
- * This function determines if filtering needs to be
- * performed. Includes are processed before Excludes.
- *
- * @param dependencies the set of dependencies to
- * filter.
- *
- * @return a Set of filtered dependencies.
- */
- public Set filter( Set artifacts, Log log )
- {
- Set results = artifacts;
-
- if ( this.includes != null && !this.includes.isEmpty() )
- {
- int size = includes.size();
- log.debug( "Including only " + size + " " + featureName + ( ( size > 1 ) ? "s" : "" ) + ": "
- + this.includeString );
-
- results = filterIncludes( results, this.includes );
- }
-
- if ( this.excludes != null && !this.excludes.isEmpty() )
- {
- int size = excludes.size();
- log.debug( "Excluding " + size + " " + featureName + ( ( size > 1 ) ? "s" : "" ) + ": "
- + this.excludeString );
- results = filterExcludes( results, this.excludes );
- }
-
- return results;
- }
-
- /**
- * Processes the dependencies list and includes the
- * dependencies that match a filter in the list.
- *
- * @param depends List of dependencies.
- * @param includes List of types or classifiers to
- * include.
- *
- * @return a set of filtered artifacts.
- */
- private Set filterIncludes( Set artifacts, List theIncludes )
- {
- Set result = new HashSet();
-
- Iterator includeIter = theIncludes.iterator();
- while ( includeIter.hasNext() )
- {
- String include = (String) includeIter.next();
- Iterator iter = artifacts.iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
-
- // if the classifier or type of the artifact
- // matches the feature
- // to include, add to the
- // results
- if ( compareFeatures( getArtifactFeature( artifact ), include ) )
- {
- result.add( artifact );
- }
- }
- }
- return result;
- }
-
- /**
- * Processes the dependencies list and excludes the
- * dependencies that match a filter in the list.
- *
- * @param depends List of dependencies.
- * @param excludes List of types or classifiers to
- * exclude.
- *
- * @return a set of filtered artifacts.
- */
- private Set filterExcludes( Set artifacts, List theExcludes )
- {
- Set result = new HashSet();
-
- Iterator iter = artifacts.iterator();
- while ( iter.hasNext() )
- {
- boolean exclude = false;
- Artifact artifact = (Artifact) iter.next();
- String artifactFeature = getArtifactFeature( artifact );
-
- // look through all types or classifiers. If no
- // matches are found
- // then it can be added to the results.
- Iterator excludeIter = theExcludes.iterator();
- while ( excludeIter.hasNext() )
- {
- String excludeFeature = (String) excludeIter.next();
- if ( compareFeatures( artifactFeature, excludeFeature ) )
- {
- exclude = true;
- break;
- }
- }
-
- if ( !exclude )
- {
- result.add( artifact );
- }
- }
-
- return result;
- }
-
- /**
- * 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
- * @return type or classifier
- */
- protected abstract String getArtifactFeature( Artifact artifact );
-
- public void setExcludes( String excludeString )
- {
- this.excludeString = excludeString;
-
- if ( StringUtils.isNotEmpty( excludeString ) )
- {
- this.excludes = Arrays.asList( StringUtils.split( excludeString, "," ) );
- }
- }
-
- public void setIncludes( String includeString )
- {
- this.includeString = includeString;
-
- if ( StringUtils.isNotEmpty( includeString ) )
- {
- this.includes = Arrays.asList( StringUtils.split( includeString, "," ) );
- }
- }
-
- /**
- * @return Returns the excludes.
- */
- public List getExcludes()
- {
- return this.excludes;
- }
-
- /**
- * @return Returns the includes.
- */
- public List getIncludes()
- {
- return this.includes;
- }
-
- /**
- * Allows Feature comparison to be customized
- *
- * @param lhs String artifact's feature
- * @param rhs String feature from exclude or include
- * list
- * @return boolean true if features match
- */
- protected boolean compareFeatures( String lhs, String rhs )
- {
- return ( lhs.equals( rhs ) );
- }
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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.Arrays;
+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.plugin.logging.Log;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This is the common base class of ClassifierFilter and
+ * TypeFilter
+ *
+ * @author <a href="richardv@mxtelecom.com">Richard van der
+ * Hoff</a>
+ * @version $Id: AbstractArtifactFeatureFilter.java 522374
+ * 2007-03-25 22:58:03Z brianf $
+ */
+public abstract class AbstractArtifactFeatureFilter
+ extends AbstractArtifactsFilter
+{
+ /** The list of types or classifiers to include */
+ private List includes;
+
+ /**
+ * The list of types or classifiers to exclude (ignored
+ * if includes != null)
+ */
+ private List excludes;
+
+ /**
+ * The configuration string for the include list - comma
+ * separated
+ */
+ private String includeString;
+
+ /**
+ * 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"
+ */
+ private String featureName;
+
+ public AbstractArtifactFeatureFilter( String include, String exclude, String theFeatureName )
+ {
+ setExcludes( exclude );
+ setIncludes( include );
+ featureName = theFeatureName;
+ }
+
+ /**
+ * This function determines if filtering needs to be
+ * performed. Includes are processed before Excludes.
+ *
+ * @param dependencies the set of dependencies to
+ * filter.
+ *
+ * @return a Set of filtered dependencies.
+ */
+ public Set filter( Set artifacts, Log log )
+ {
+ Set results = artifacts;
+
+ if ( this.includes != null && !this.includes.isEmpty() )
+ {
+ int size = includes.size();
+ log.debug( "Including only " + size + " " + featureName + ( ( size > 1 ) ? "s" : "" ) + ": "
+ + this.includeString );
+
+ results = filterIncludes( results, this.includes );
+ }
+
+ if ( this.excludes != null && !this.excludes.isEmpty() )
+ {
+ int size = excludes.size();
+ log.debug( "Excluding " + size + " " + featureName + ( ( size > 1 ) ? "s" : "" ) + ": "
+ + this.excludeString );
+ results = filterExcludes( results, this.excludes );
+ }
+
+ return results;
+ }
+
+ /**
+ * Processes the dependencies list and includes the
+ * dependencies that match a filter in the list.
+ *
+ * @param depends List of dependencies.
+ * @param includes List of types or classifiers to
+ * include.
+ *
+ * @return a set of filtered artifacts.
+ */
+ private Set filterIncludes( Set artifacts, List theIncludes )
+ {
+ Set result = new HashSet();
+
+ Iterator includeIter = theIncludes.iterator();
+ while ( includeIter.hasNext() )
+ {
+ String include = (String) includeIter.next();
+ Iterator iter = artifacts.iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+
+ // if the classifier or type of the artifact
+ // matches the feature
+ // to include, add to the
+ // results
+ if ( compareFeatures( getArtifactFeature( artifact ), include ) )
+ {
+ result.add( artifact );
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Processes the dependencies list and excludes the
+ * dependencies that match a filter in the list.
+ *
+ * @param depends List of dependencies.
+ * @param excludes List of types or classifiers to
+ * exclude.
+ *
+ * @return a set of filtered artifacts.
+ */
+ private Set filterExcludes( Set artifacts, List theExcludes )
+ {
+ Set result = new HashSet();
+
+ Iterator iter = artifacts.iterator();
+ while ( iter.hasNext() )
+ {
+ boolean exclude = false;
+ Artifact artifact = (Artifact) iter.next();
+ String artifactFeature = getArtifactFeature( artifact );
+
+ // look through all types or classifiers. If no
+ // matches are found
+ // then it can be added to the results.
+ Iterator excludeIter = theExcludes.iterator();
+ while ( excludeIter.hasNext() )
+ {
+ String excludeFeature = (String) excludeIter.next();
+ if ( compareFeatures( artifactFeature, excludeFeature ) )
+ {
+ exclude = true;
+ break;
+ }
+ }
+
+ if ( !exclude )
+ {
+ result.add( artifact );
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 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
+ * @return type or classifier
+ */
+ protected abstract String getArtifactFeature( Artifact artifact );
+
+ public void setExcludes( String excludeString )
+ {
+ this.excludeString = excludeString;
+
+ if ( StringUtils.isNotEmpty( excludeString ) )
+ {
+ this.excludes = Arrays.asList( StringUtils.split( excludeString, "," ) );
+ }
+ }
+
+ public void setIncludes( String includeString )
+ {
+ this.includeString = includeString;
+
+ if ( StringUtils.isNotEmpty( includeString ) )
+ {
+ this.includes = Arrays.asList( StringUtils.split( includeString, "," ) );
+ }
+ }
+
+ /**
+ * @return Returns the excludes.
+ */
+ public List getExcludes()
+ {
+ return this.excludes;
+ }
+
+ /**
+ * @return Returns the includes.
+ */
+ public List getIncludes()
+ {
+ return this.includes;
+ }
+
+ /**
+ * Allows Feature comparison to be customized
+ *
+ * @param lhs String artifact's feature
+ * @param rhs String feature from exclude or include
+ * list
+ * @return boolean true if features match
+ */
+ protected boolean compareFeatures( String lhs, String rhs )
+ {
+ return ( lhs.equals( rhs ) );
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java Mon Jul 2 09:06:19 2007
@@ -1,45 +1,45 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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.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
-{
- /**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
- public boolean okToProcess( Artifact artifact, Log log )
- throws MojoExecutionException
- {
- Set set = new HashSet();
- set.add( artifact );
-
- set = filter( set, log );
- return set.contains( artifact );
- }
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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.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
+{
+ /**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+ public boolean okToProcess( Artifact artifact, Log log )
+ throws MojoExecutionException
+ {
+ Set set = new HashSet();
+ set.add( artifact );
+
+ set = filter( set, log );
+ return set.contains( artifact );
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactsFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java Mon Jul 2 09:06:19 2007
@@ -1,56 +1,56 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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 org.apache.maven.artifact.Artifact;
-
-/**
- * Filter on ArtifactId name
- *
- * @author clove
- * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter
- * @since 2.0-alpha-2
- * @version $Id$
- */
-public class ArtifactIdFilter
- extends AbstractArtifactFeatureFilter
-{
- /**
- * Will setup super with 'ArtifactId' as the filterType
- *
- * @param include
- * @param exclude
- */
- public ArtifactIdFilter( String include, String exclude )
- {
- super( include, exclude, "ArtifactId" );
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
- */
- protected String getArtifactFeature( Artifact artifact )
- {
- return artifact.getArtifactId();
- }
-
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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 org.apache.maven.artifact.Artifact;
+
+/**
+ * Filter on ArtifactId name
+ *
+ * @author clove
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter
+ * @since 2.0-alpha-2
+ * @version $Id$
+ */
+public class ArtifactIdFilter
+ extends AbstractArtifactFeatureFilter
+{
+ /**
+ * Will setup super with 'ArtifactId' as the filterType
+ *
+ * @param include
+ * @param exclude
+ */
+ public ArtifactIdFilter( String include, String exclude )
+ {
+ super( include, exclude, "ArtifactId" );
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
+ */
+ protected String getArtifactFeature( Artifact artifact )
+ {
+ return artifact.getArtifactId();
+ }
+
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java Mon Jul 2 09:06:19 2007
@@ -1,38 +1,38 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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 org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public interface ArtifactItemFilter
-{
-
- boolean okToProcess( ArtifactItem item )
- throws MojoExecutionException;
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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 org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public interface ArtifactItemFilter
+{
+
+ boolean okToProcess( ArtifactItem item )
+ throws MojoExecutionException;
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactsFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java?view=diff&rev=552524&r1=552523&r2=552524
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java Mon Jul 2 09:06:19 2007
@@ -1,46 +1,46 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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 org.apache.maven.artifact.Artifact;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- *
- */
-public class ClassifierFilter
- extends AbstractArtifactFeatureFilter
-{
- public ClassifierFilter( String include, String exclude )
- {
- super( include, exclude, "Classifiers" );
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
- */
- protected String getArtifactFeature( Artifact artifact )
- {
- return artifact.getClassifier();
- }
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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 org.apache.maven.artifact.Artifact;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ *
+ */
+public class ClassifierFilter
+ extends AbstractArtifactFeatureFilter
+{
+ public ClassifierFilter( String include, String exclude )
+ {
+ super( include, exclude, "Classifiers" );
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
+ */
+ protected String getArtifactFeature( Artifact artifact )
+ {
+ return artifact.getClassifier();
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
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=552524&r1=552523&r2=552524
==============================================================================
--- 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 Mon Jul 2 09:06:19 2007
@@ -1,289 +1,289 @@
-package org.apache.maven.plugin.dependency.utils.filters;
-
-/*
- * 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.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-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 <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
-public class DestFileFilter
- extends AbstractArtifactsFilter
- implements ArtifactItemFilter
-{
-
- boolean overWriteReleases;
-
- boolean overWriteSnapshots;
-
- boolean overWriteIfNewer;
-
- boolean useSubDirectoryPerArtifact;
-
- boolean useSubDirectoryPerType;
-
- boolean useRepositoryLayout;
-
- boolean removeVersion;
-
- File outputFileDirectory;
-
- public DestFileFilter( File outputFileDirectory )
- {
- this.outputFileDirectory = outputFileDirectory;
- overWriteReleases = false;
- overWriteIfNewer = false;
- overWriteSnapshots = false;
- useSubDirectoryPerArtifact = false;
- useSubDirectoryPerType = false;
- removeVersion = false;
- }
-
- public DestFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer,
- boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType,
- boolean useRepositoryLayout, boolean removeVersion, File outputFileDirectory )
- {
- this.overWriteReleases = overWriteReleases;
- this.overWriteSnapshots = overWriteSnapshots;
- this.overWriteIfNewer = overWriteIfNewer;
- this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact;
- this.useSubDirectoryPerType = useSubDirectoryPerType;
- this.useRepositoryLayout = useRepositoryLayout;
- this.removeVersion = removeVersion;
- this.outputFileDirectory = outputFileDirectory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.mojo.dependency.utils.filters.ArtifactsFilter#filter(java.util.Set,
- * org.apache.maven.plugin.logging.Log)
- */
- public Set filter( Set artifacts, Log log )
- throws MojoExecutionException
- {
- Set result = new HashSet();
-
- Iterator iter = artifacts.iterator();
- // log.debug("Artifacts:"+ artifacts.size());
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
- if ( okToProcess( new ArtifactItem( artifact ) ) )
- {
- result.add( artifact );
- }
- }
- return result;
- }
-
- /**
- * @return Returns the overWriteReleases.
- */
- public boolean isOverWriteReleases()
- {
- return this.overWriteReleases;
- }
-
- /**
- * @param overWriteReleases
- * The overWriteReleases to set.
- */
- public void setOverWriteReleases( boolean overWriteReleases )
- {
- this.overWriteReleases = overWriteReleases;
- }
-
- /**
- * @return Returns the overWriteSnapshots.
- */
- public boolean isOverWriteSnapshots()
- {
- return this.overWriteSnapshots;
- }
-
- /**
- * @param overWriteSnapshots
- * The overWriteSnapshots to set.
- */
- public void setOverWriteSnapshots( boolean overWriteSnapshots )
- {
- this.overWriteSnapshots = overWriteSnapshots;
- }
-
- /**
- * @return Returns the overWriteIfNewer.
- */
- public boolean isOverWriteIfNewer()
- {
- return this.overWriteIfNewer;
- }
-
- /**
- * @param overWriteIfNewer
- * The overWriteIfNewer to set.
- */
- public void setOverWriteIfNewer( boolean overWriteIfNewer )
- {
- this.overWriteIfNewer = overWriteIfNewer;
- }
-
- /**
- * @return Returns the outputFileDirectory.
- */
- public File getOutputFileDirectory()
- {
- return this.outputFileDirectory;
- }
-
- /**
- * @param outputFileDirectory
- * The outputFileDirectory to set.
- */
- public void setOutputFileDirectory( File outputFileDirectory )
- {
- this.outputFileDirectory = outputFileDirectory;
- }
-
- /**
- * @return Returns the removeVersion.
- */
- public boolean isRemoveVersion()
- {
- return this.removeVersion;
- }
-
- /**
- * @param removeVersion
- * The removeVersion to set.
- */
- public void setRemoveVersion( boolean removeVersion )
- {
- this.removeVersion = removeVersion;
- }
-
- /**
- * @return Returns the useSubDirectoryPerArtifact.
- */
- public boolean isUseSubDirectoryPerArtifact()
- {
- return this.useSubDirectoryPerArtifact;
- }
-
- /**
- * @param useSubDirectoryPerArtifact
- * The useSubDirectoryPerArtifact to set.
- */
- public void setUseSubDirectoryPerArtifact( boolean useSubDirectoryPerArtifact )
- {
- this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact;
- }
-
- /**
- * @return Returns the useSubDirectoryPerType.
- */
- public boolean isUseSubDirectoryPerType()
- {
- return this.useSubDirectoryPerType;
- }
-
- /**
- * @param useSubDirectoryPerType
- * The useSubDirectoryPerType to set.
- */
- public void setUseSubDirectoryPerType( boolean useSubDirectoryPerType )
- {
- this.useSubDirectoryPerType = useSubDirectoryPerType;
- }
-
- /**
- *
- * @return Returns the useRepositoryLayout
- */
- public boolean isUseRepositoryLayout()
- {
- return useRepositoryLayout;
- }
-
- /**
- *
- * @param useRepositoryLayout
- * the useRepositoryLayout to set
- */
- public void setUseRepositoryLayout( boolean useRepositoryLayout )
- {
- this.useRepositoryLayout = useRepositoryLayout;
- }
-
- public boolean okToProcess( ArtifactItem item )
- throws MojoExecutionException
- {
- 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( useSubDirectoryPerType,
- useSubDirectoryPerArtifact, useRepositoryLayout,
- removeVersion, 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;
- }
-}
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/*
+ * 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.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+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 <a href="mailto:brianf@apache.org">Brian Fox</a>
+ * @version $Id$
+ */
+public class DestFileFilter
+ extends AbstractArtifactsFilter
+ implements ArtifactItemFilter
+{
+
+ boolean overWriteReleases;
+
+ boolean overWriteSnapshots;
+
+ boolean overWriteIfNewer;
+
+ boolean useSubDirectoryPerArtifact;
+
+ boolean useSubDirectoryPerType;
+
+ boolean useRepositoryLayout;
+
+ boolean removeVersion;
+
+ File outputFileDirectory;
+
+ public DestFileFilter( File outputFileDirectory )
+ {
+ this.outputFileDirectory = outputFileDirectory;
+ overWriteReleases = false;
+ overWriteIfNewer = false;
+ overWriteSnapshots = false;
+ useSubDirectoryPerArtifact = false;
+ useSubDirectoryPerType = false;
+ removeVersion = false;
+ }
+
+ public DestFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer,
+ boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType,
+ boolean useRepositoryLayout, boolean removeVersion, File outputFileDirectory )
+ {
+ this.overWriteReleases = overWriteReleases;
+ this.overWriteSnapshots = overWriteSnapshots;
+ this.overWriteIfNewer = overWriteIfNewer;
+ this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact;
+ this.useSubDirectoryPerType = useSubDirectoryPerType;
+ this.useRepositoryLayout = useRepositoryLayout;
+ this.removeVersion = removeVersion;
+ this.outputFileDirectory = outputFileDirectory;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.mojo.dependency.utils.filters.ArtifactsFilter#filter(java.util.Set,
+ * org.apache.maven.plugin.logging.Log)
+ */
+ public Set filter( Set artifacts, Log log )
+ throws MojoExecutionException
+ {
+ Set result = new HashSet();
+
+ Iterator iter = artifacts.iterator();
+ // log.debug("Artifacts:"+ artifacts.size());
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ if ( okToProcess( new ArtifactItem( artifact ) ) )
+ {
+ result.add( artifact );
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @return Returns the overWriteReleases.
+ */
+ public boolean isOverWriteReleases()
+ {
+ return this.overWriteReleases;
+ }
+
+ /**
+ * @param overWriteReleases
+ * The overWriteReleases to set.
+ */
+ public void setOverWriteReleases( boolean overWriteReleases )
+ {
+ this.overWriteReleases = overWriteReleases;
+ }
+
+ /**
+ * @return Returns the overWriteSnapshots.
+ */
+ public boolean isOverWriteSnapshots()
+ {
+ return this.overWriteSnapshots;
+ }
+
+ /**
+ * @param overWriteSnapshots
+ * The overWriteSnapshots to set.
+ */
+ public void setOverWriteSnapshots( boolean overWriteSnapshots )
+ {
+ this.overWriteSnapshots = overWriteSnapshots;
+ }
+
+ /**
+ * @return Returns the overWriteIfNewer.
+ */
+ public boolean isOverWriteIfNewer()
+ {
+ return this.overWriteIfNewer;
+ }
+
+ /**
+ * @param overWriteIfNewer
+ * The overWriteIfNewer to set.
+ */
+ public void setOverWriteIfNewer( boolean overWriteIfNewer )
+ {
+ this.overWriteIfNewer = overWriteIfNewer;
+ }
+
+ /**
+ * @return Returns the outputFileDirectory.
+ */
+ public File getOutputFileDirectory()
+ {
+ return this.outputFileDirectory;
+ }
+
+ /**
+ * @param outputFileDirectory
+ * The outputFileDirectory to set.
+ */
+ public void setOutputFileDirectory( File outputFileDirectory )
+ {
+ this.outputFileDirectory = outputFileDirectory;
+ }
+
+ /**
+ * @return Returns the removeVersion.
+ */
+ public boolean isRemoveVersion()
+ {
+ return this.removeVersion;
+ }
+
+ /**
+ * @param removeVersion
+ * The removeVersion to set.
+ */
+ public void setRemoveVersion( boolean removeVersion )
+ {
+ this.removeVersion = removeVersion;
+ }
+
+ /**
+ * @return Returns the useSubDirectoryPerArtifact.
+ */
+ public boolean isUseSubDirectoryPerArtifact()
+ {
+ return this.useSubDirectoryPerArtifact;
+ }
+
+ /**
+ * @param useSubDirectoryPerArtifact
+ * The useSubDirectoryPerArtifact to set.
+ */
+ public void setUseSubDirectoryPerArtifact( boolean useSubDirectoryPerArtifact )
+ {
+ this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact;
+ }
+
+ /**
+ * @return Returns the useSubDirectoryPerType.
+ */
+ public boolean isUseSubDirectoryPerType()
+ {
+ return this.useSubDirectoryPerType;
+ }
+
+ /**
+ * @param useSubDirectoryPerType
+ * The useSubDirectoryPerType to set.
+ */
+ public void setUseSubDirectoryPerType( boolean useSubDirectoryPerType )
+ {
+ this.useSubDirectoryPerType = useSubDirectoryPerType;
+ }
+
+ /**
+ *
+ * @return Returns the useRepositoryLayout
+ */
+ public boolean isUseRepositoryLayout()
+ {
+ return useRepositoryLayout;
+ }
+
+ /**
+ *
+ * @param useRepositoryLayout
+ * the useRepositoryLayout to set
+ */
+ public void setUseRepositoryLayout( boolean useRepositoryLayout )
+ {
+ this.useRepositoryLayout = useRepositoryLayout;
+ }
+
+ public boolean okToProcess( ArtifactItem item )
+ throws MojoExecutionException
+ {
+ 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( useSubDirectoryPerType,
+ useSubDirectoryPerArtifact, useRepositoryLayout,
+ removeVersion, 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;
+ }
+}
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision
Propchange: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jul 2 09:06:19 2007
@@ -1 +1 @@
-Author Date Id HeadURL Revision
+Author Date Id Revision