You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/07/04 15:28:34 UTC
svn commit: r1357251 [2/2] - in
/maven/plugins/trunk/maven-dependency-plugin: ./
src/main/java/org/apache/maven/plugin/dependency/
src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/
src/main/java/org/apache/maven/plugin/dependency/reso...
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java Wed Jul 4 13:28:33 2012
@@ -19,16 +19,6 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -42,138 +32,146 @@ import org.apache.maven.artifact.resolve
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* Downloads a single artifact transitively from the specified remote repositories. Caveat: will always check the
* central repository defined in the super pom. You could use a mirror entry in your settings.xml
- *
- * @goal get
- * @requiresProject false
*/
+@Mojo( name = "get", requiresProject = false )
public class GetMojo
extends AbstractMojo
{
private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" );
/**
- * @component
- * @readonly
+ *
*/
+ @Component
private ArtifactFactory artifactFactory;
/**
- * @component
- * @readonly
+ *
*/
+ @Component
private ArtifactResolver artifactResolver;
/**
- * @component
- * @readonly
+ *
*/
+ @Component
private ArtifactRepositoryFactory artifactRepositoryFactory;
/**
* Map that contains the layouts.
- *
- * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
+ @Component( role = ArtifactRepositoryLayout.class )
private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
/**
- * @component
- * @readonly
+ *
*/
+ @Component
private ArtifactMetadataSource source;
/**
*
- * @parameter default-value="${localRepository}"
- * @readonly
*/
+ @Parameter( defaultValue = "${localRepository}", readonly = true )
private ArtifactRepository localRepository;
/**
* The groupId of the artifact to download. Ignored if {@link #artifact} is used.
- * @parameter expression="${groupId}"
*/
+ @Parameter( property = "groupId" )
private String groupId;
/**
* The artifactId of the artifact to download. Ignored if {@link #artifact} is used.
- * @parameter expression="${artifactId}"
*/
+ @Parameter( property = "artifactId" )
private String artifactId;
/**
* The version of the artifact to download. Ignored if {@link #artifact} is used.
- * @parameter expression="${version}"
*/
+ @Parameter( property = "version" )
private String version;
/**
* The classifier of the artifact to download. Ignored if {@link #artifact} is used.
- * @parameter expression="${classifier}"
+ *
* @since 2.3
*/
+ @Parameter( property = "classifier" )
private String classifier;
/**
* The packaging of the artifact to download. Ignored if {@link #artifact} is used.
- * @parameter expression="${packaging}" default-value="jar"
*/
+ @Parameter( property = "packaging", defaultValue = "jar" )
private String packaging = "jar";
/**
* The id of the repository from which we'll download the artifact
- * @parameter expression="${repoId}" default-value="temp"
+ *
* @deprecated Use remoteRepositories
*/
+ @Parameter( property = "repoId", defaultValue = "temp" )
private String repositoryId = "temp";
/**
* The url of the repository from which we'll download the artifact. DEPRECATED Use remoteRepositories
- *
+ *
* @deprecated Use remoteRepositories
- * @parameter expression="${repoUrl}"
*/
+ @Parameter( property = "repoUrl" )
private String repositoryUrl;
/**
* Repositories in the format id::[layout]::url or just url, separated by comma.
* ie. central::default::http://repo1.maven.apache.org/maven2,myrepo::::http://repo.acme.com,http://repo.acme2.com
- *
- * @parameter expression="${remoteRepositories}"
*/
+ @Parameter( property = "remoteRepositories" )
private String remoteRepositories;
/**
* A string of the form groupId:artifactId:version[:packaging][:classifier].
- *
- * @parameter expression="${artifact}"
*/
+ @Parameter( property = "artifact" )
private String artifact;
/**
* The destination file to copy the artifact to, if other than the local repository
- * @parameter expression="${dest}"
+ *
* @since 2.4
*/
+ @Parameter( property = "dest" )
private String destination;
/**
*
- * @parameter default-value="${project.remoteArtifactRepositories}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
private List<ArtifactRepository> pomRemoteRepositories;
/**
* Download transitively, retrieving the specified artifact and all of its dependencies.
- * @parameter expression="${transitive}" default-value=true
*/
+ @Parameter( property = "transitive", defaultValue = "true" )
private boolean transitive = true;
public void execute()
@@ -183,7 +181,7 @@ public class GetMojo
if ( artifactId == null && artifact == null )
{
throw new MojoFailureException( "You must specify an artifact, "
- + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0" );
+ + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0" );
}
if ( artifact != null )
{
@@ -242,8 +240,8 @@ public class GetMojo
{
getLog().warn( "repositoryUrl parameter is deprecated. Use remoteRepositories instead" );
ArtifactRepository remoteRepo =
- artifactRepositoryFactory.createArtifactRepository( repositoryId, repositoryUrl,
- getLayout( "default" ), always, always );
+ artifactRepositoryFactory.createArtifactRepository( repositoryId, repositoryUrl, getLayout( "default" ),
+ always, always );
repoList.add( remoteRepo );
}
@@ -278,8 +276,9 @@ public class GetMojo
}
catch ( IOException e )
{
- throw new MojoExecutionException( "Couldn't copy downloaded artifact from " + src.getAbsolutePath()
- + " to " + dest.getAbsolutePath() + " : " + e.getMessage(), e );
+ throw new MojoExecutionException(
+ "Couldn't copy downloaded artifact from " + src.getAbsolutePath() + " to " + dest.getAbsolutePath()
+ + " : " + e.getMessage(), e );
}
}
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java Wed Jul 4 13:28:33 2012
@@ -20,16 +20,17 @@ package org.apache.maven.plugin.dependen
*/
import org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
/**
* Displays the list of dependencies for this project.
- *
+ *
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @version $Id$
* @since 2.0-alpha-5
- * @goal list
- * @requiresDependencyResolution test
*/
+@Mojo( name = "list", requiresDependencyResolution = ResolutionScope.TEST )
public class ListMojo
extends ResolveDependenciesMojo
{
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java Wed Jul 4 13:28:33 2012
@@ -19,55 +19,55 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
+import java.util.Set;
+
/**
* Goal that sets a property pointing to the artifact file for each project dependency.
* For each dependency (direct and transitive) a project property will be set which follows the
* form groupId:artifactId:type:[classifier] and contains the path to the resolved artifact.
- *
- * @goal properties
- * @requiresDependencyResolution test
- * @phase initialize
+ *
* @author Paul Gier
* @version $Id$
* @since 2.2
*/
+@Mojo( name = "properties", requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.INITIALIZE )
public class PropertiesMojo
extends AbstractMojo
{
/**
* The current Maven project
- *
- * @parameter default-value="${project}"
- * @readonly
*/
+ @Component
protected MavenProject project;
/**
* Main entry into mojo. Gets the list of dependencies and iterates through setting a property for each artifact.
- *
+ *
* @throws MojoExecutionException with a message if an error occurs.
*/
public void execute()
throws MojoExecutionException
{
- @SuppressWarnings( "unchecked" )
- Set<Artifact> artifacts = getProject().getArtifacts();
-
+ @SuppressWarnings( "unchecked" ) Set<Artifact> artifacts = getProject().getArtifacts();
+
for ( Artifact artifact : artifacts )
{
project.getProperties().setProperty( artifact.getDependencyConflictId(),
artifact.getFile().getAbsolutePath() );
}
}
-
+
public MavenProject getProject()
{
return project;
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java Wed Jul 4 13:28:33 2012
@@ -34,6 +34,9 @@ import org.apache.maven.model.Dependency
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
@@ -55,10 +58,9 @@ import java.util.Set;
*
* @author jdcasey
* @version $Id$
- * @goal purge-local-repository
- * @aggregator
* @since 2.0
*/
+@Mojo( name = "purge-local-repository", aggregator = true )
public class PurgeLocalRepositoryMojo
extends AbstractMojo
{
@@ -74,19 +76,15 @@ public class PurgeLocalRepositoryMojo
/**
* The projects in the current build. Each of these is subject to
* refreshing.
- *
- * @parameter default-value="${reactorProjects}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true )
private List<MavenProject> projects;
/**
* The list of dependencies in the form of groupId:artifactId which should
* NOT be deleted/refreshed. This is useful for third-party artifacts.
- *
- * @parameter
*/
+ @Parameter
private List<String> excludes;
/**
@@ -94,42 +92,35 @@ public class PurgeLocalRepositoryMojo
* to exclude artifacts from deletion/refresh. This is a command-line
* alternative to the <code>excludes</code> parameter, since List
* parameters are not currently compatible with CLI specification.
- *
- * @parameter expression="${exclude}"
*/
+ @Parameter( property = "exclude" )
private String exclude;
/**
* Whether to re-resolve the artifacts once they have been deleted from the
* local repository. If you are running this mojo from the command-line, you
* may want to disable this. By default, artifacts will be re-resolved.
- *
- * @parameter expression="${reResolve}" default-value="true"
*/
+ @Parameter( property = "reResolve", defaultValue = "true" )
private boolean reResolve;
/**
* The local repository, from which to delete artifacts.
- *
- * @parameter default-value="${localRepository}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
private ArtifactRepository localRepository;
/**
* The artifact resolver used to re-resolve dependencies, if that option is
* enabled.
- *
- * @component
*/
+ @Component
private ArtifactResolver resolver;
/**
* The artifact metadata source used to resolve dependencies
- *
- * @component
*/
+ @Component
private ArtifactMetadataSource source;
/**
@@ -144,39 +135,35 @@ public class PurgeLocalRepositoryMojo
* <li><b>groupId</b> - Eliminate all files associated with the artifact's
* groupId.</li>
* </ul>
- *
- * @parameter expression="${resolutionFuzziness}" default-value="file"
*/
+ @Parameter( property = "resolutionFuzziness", defaultValue = "file" )
private String resolutionFuzziness;
/**
* Whether this mojo should act on all transitive dependencies. Default
* value is true.
- *
- * @parameter expression="${actTransitively}" default-value="true"
*/
+ @Parameter( property = "actTransitively", defaultValue = "true" )
private boolean actTransitively;
/**
* Used to construct artifacts for deletion/resolution...
- *
- * @component
*/
+ @Component
private ArtifactFactory factory;
/**
* Whether this plugin should output verbose messages. Default is false.
- *
- * @parameter expression="${verbose}" default-value="false"
*/
+ @Parameter( property = "verbose", defaultValue = "false" )
private boolean verbose;
/**
* Whether to purge only snapshot artifacts.
*
- * @parameter expression="${snapshotsOnly}" default-value="false"
* @since 2.4
*/
+ @Parameter( property = "snapshotsOnly", defaultValue = "false" )
private boolean snapshotsOnly;
@@ -225,8 +212,7 @@ public class PurgeLocalRepositoryMojo
{
Map<String, Artifact> artifactMap = Collections.emptyMap();
- @SuppressWarnings( "unchecked" )
- List<Dependency> dependencies = project.getDependencies();
+ @SuppressWarnings( "unchecked" ) List<Dependency> dependencies = project.getDependencies();
List<ArtifactRepository> remoteRepositories = Collections.emptyList();
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?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- 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 Wed Jul 4 13:28:33 2012
@@ -19,14 +19,6 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-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;
@@ -41,10 +33,14 @@ import org.apache.maven.execution.Runtim
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.treeSerializers.DOTDependencyNodeVisitor;
import org.apache.maven.plugin.dependency.treeSerializers.GraphmlDependencyNodeVisitor;
import org.apache.maven.plugin.dependency.treeSerializers.TGFDependencyNodeVisitor;
-import org.apache.maven.plugin.dependency.treeSerializers.DOTDependencyNodeVisitor;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
@@ -63,15 +59,22 @@ import org.apache.maven.shared.dependenc
import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor;
import org.apache.maven.shared.dependency.tree.traversal.SerializingDependencyNodeVisitor.TreeTokens;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
/**
* 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
*/
+@Mojo( name = "tree", requiresDependencyResolution = ResolutionScope.TEST )
public class TreeMojo
extends AbstractMojo
{
@@ -79,104 +82,86 @@ public class TreeMojo
/**
* The Maven project.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
*/
+ @Component
private MavenProject project;
/**
* The artifact repository to use.
- *
- * @parameter default-value="${localRepository}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
private ArtifactRepository localRepository;
/**
* The artifact factory to use.
- *
- * @component
- * @required
- * @readonly
*/
+ @Component
private ArtifactFactory artifactFactory;
/**
* The artifact metadata source to use.
- *
- * @component
- * @required
- * @readonly
*/
+ @Component
private ArtifactMetadataSource artifactMetadataSource;
/**
* The artifact collector to use.
- *
- * @component
- * @required
- * @readonly
*/
+ @Component
private ArtifactCollector artifactCollector;
/**
* The dependency tree builder to use.
- *
- * @component
- * @required
- * @readonly
*/
+ @Component
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.
+ *
* @deprecated use outputFile instead.
- * @parameter expression="${output}"
*/
+ @Parameter( property = "output" )
private File output;
/**
* If specified, this parameter will cause the dependency tree to be written to the path specified, instead of
* writing to the console.
- * @parameter expression="${outputFile}"
+ *
* @since 2.0-alpha-5
*/
+ @Parameter( property = "outputFile" )
private File outputFile;
/**
* If specified, this parameter will cause the dependency tree to be written using the specified format. Currently
* supported format are text, dot, graphml and tgf.
- *
+ * <p/>
* These formats can be plotted to image files. An example of how to plot a dot file using
* pygraphviz can be found <a href="http://networkx.lanl.gov/pygraphviz/tutorial.html#layout-and-drawing">here</a>
*
- * @parameter expression="${outputType}" default-value="text"
* @since 2.2
*/
+ @Parameter( property = "outputType", defaultValue = "text" )
private String outputType;
/**
* The scope to filter by when resolving the dependency tree, or <code>null</code> to include dependencies from
* all scopes. Note that this feature does not currently work due to MNG-3236.
*
- * @since 2.0-alpha-5
* @see <a href="http://jira.codehaus.org/browse/MNG-3236">MNG-3236</a>
- *
- * @parameter expression="${scope}"
+ * @since 2.0-alpha-5
*/
+ @Parameter( property = "scope" )
private String scope;
/**
* Whether to include omitted nodes in the serialized dependency tree.
*
* @since 2.0-alpha-6
- *
- * @parameter expression="${verbose}" default-value="false"
*/
+ @Parameter( property = "verbose", defaultValue = "false" )
private boolean verbose;
/**
@@ -185,19 +170,17 @@ public class TreeMojo
* respectively.
*
* @since 2.0-alpha-6
- *
- * @parameter expression="${tokens}" default-value="standard"
*/
+ @Parameter( property = "tokens", defaultValue = "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>.
*
+ * @parameter expression="${includes}"
* @see StrictPatternIncludesArtifactFilter
* @since 2.0-alpha-6
- *
- * @parameter expression="${includes}"
*/
private String includes;
@@ -208,31 +191,31 @@ public class TreeMojo
*
* @see StrictPatternExcludesArtifactFilter
* @since 2.0-alpha-6
- *
- * @parameter expression="${excludes}"
*/
+ @Parameter( property = "excludes" )
private String excludes;
/**
* Runtime Information used to check the Maven version
+ *
* @since 2.0
- * @component role="org.apache.maven.execution.RuntimeInformation"
*/
+ @Component
private RuntimeInformation rti;
/**
* The computed dependency tree root node of the Maven project.
*/
private DependencyNode rootNode;
-
+
/**
* Whether to append outputs into the output file or overwrite it.
- *
- * @parameter expression="${appendOutput}" default-value="false"
+ *
* @since 2.2
*/
+ @Parameter( property = "appendOutput", defaultValue = "false" )
private boolean appendOutput;
-
+
// Mojo methods -----------------------------------------------------------
/*
@@ -250,7 +233,7 @@ public class TreeMojo
if ( !containsVersion( vr, detectedMavenVersion ) )
{
getLog().warn(
- "The tree mojo requires at least Maven 2.0.8 to function properly. You may get erroneous results on earlier versions" );
+ "The tree mojo requires at least Maven 2.0.8 to function properly. You may get erroneous results on earlier versions" );
}
}
catch ( InvalidVersionSpecificationException e )
@@ -258,7 +241,6 @@ public class TreeMojo
throw new MojoExecutionException( e.getLocalizedMessage(), e );
}
-
if ( output != null )
{
getLog().warn( "The parameter output is deprecated. Use outputFile instead." );
@@ -271,15 +253,15 @@ public class TreeMojo
{
// TODO: note that filter does not get applied due to MNG-3236
- rootNode =
- dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
- artifactMetadataSource, artifactFilter, artifactCollector );
+ rootNode = dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory,
+ artifactMetadataSource, artifactFilter,
+ artifactCollector );
String dependencyTreeString = serializeDependencyTree( rootNode );
if ( outputFile != null )
{
- DependencyUtil.write( dependencyTreeString, outputFile, this.appendOutput ,getLog() );
+ DependencyUtil.write( dependencyTreeString, outputFile, this.appendOutput, getLog() );
getLog().info( "Wrote dependency tree to: " + outputFile );
}
@@ -349,8 +331,7 @@ public class TreeMojo
/**
* Serializes the specified dependency tree to a string.
*
- * @param rootNode
- * the dependency tree root node to serialize
+ * @param rootNode the dependency tree root node to serialize
* @return the serialized dependency tree
*/
private String serializeDependencyTree( DependencyNode rootNode )
@@ -370,7 +351,8 @@ public class TreeMojo
DependencyNodeVisitor firstPassVisitor = new FilteringDependencyNodeVisitor( collectingVisitor, filter );
rootNode.accept( firstPassVisitor );
- DependencyNodeFilter secondPassFilter = new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
+ DependencyNodeFilter secondPassFilter =
+ new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
visitor = new FilteringDependencyNodeVisitor( visitor, secondPassFilter );
}
@@ -391,7 +373,7 @@ public class TreeMojo
}
else if ( "dot".equals( outputType ) )
{
- return new DOTDependencyNodeVisitor( writer ) ;
+ return new DOTDependencyNodeVisitor( writer );
}
else
{
@@ -402,8 +384,7 @@ public class TreeMojo
/**
* Gets the tree tokens instance for the specified name.
*
- * @param tokens
- * the tree tokens name
+ * @param tokens the tree tokens name
* @return the <code>TreeTokens</code> instance
*/
private TreeTokens toTreeTokens( String tokens )
@@ -476,14 +457,13 @@ public class TreeMojo
//doesn't work properly. I ripped it out of the enforcer rules.
-
/**
* Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default
* containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" ==
* "[2.0.4,)"
*
* @param allowedRange range of allowed versions.
- * @param theVersion the version to be checked.
+ * @param theVersion the version to be checked.
* @return true if the version is contained by the range.
*/
public static boolean containsVersion( VersionRange allowedRange, ArtifactVersion theVersion )
@@ -491,8 +471,7 @@ public class TreeMojo
ArtifactVersion recommendedVersion = allowedRange.getRecommendedVersion();
if ( recommendedVersion == null )
{
- @SuppressWarnings( "unchecked" )
- List<Restriction> restrictions = allowedRange.getRestrictions();
+ @SuppressWarnings( "unchecked" ) List<Restriction> restrictions = allowedRange.getRestrictions();
for ( Restriction restriction : restrictions )
{
if ( restriction.containsVersion( theVersion ) )
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java Wed Jul 4 13:28:33 2012
@@ -19,27 +19,29 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
import org.apache.maven.plugin.dependency.utils.DependencyUtil;
import org.apache.maven.plugin.dependency.utils.filters.MarkerFileFilter;
import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import java.io.File;
+
/**
* Goal that unpacks the project dependencies from the repository to a defined
* location.
*
- * @goal unpack-dependencies
- * @requiresDependencyResolution test
- * @phase process-sources
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
* @since 1.0
*/
+@Mojo( name = "unpack-dependencies", requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.PROCESS_SOURCES )
public class UnpackDependenciesMojo
extends AbstractFromDependenciesMojo
{
@@ -48,8 +50,9 @@ public class UnpackDependenciesMojo
* artifact. i.e. <code>**\/*.xml,**\/*.properties</code>
* NOTE: Excludes patterns override the includes.
* (component code = <code>return isIncluded( name ) AND !isExcluded( name );</code>)
- * @since 2.0
+ *
* @parameter expression="${mdep.unpack.includes}"
+ * @since 2.0
*/
private String includes;
@@ -58,8 +61,9 @@ public class UnpackDependenciesMojo
* artifact. i.e. <code>**\/*.xml,**\/*.properties</code>
* NOTE: Excludes patterns override the includes.
* (component code = <code>return isIncluded( name ) AND !isExcluded( name );</code>)
- * @since 2.0
+ *
* @parameter expression="${mdep.unpack.excludes}"
+ * @since 2.0
*/
private String excludes;
@@ -67,9 +71,7 @@ public class UnpackDependenciesMojo
* Main entry into mojo. This method gets the dependencies and iterates
* through each one passing it to DependencyUtil.unpackFile().
*
- * @throws MojoExecutionException
- * with a message if an error occurs.
- *
+ * @throws MojoExecutionException with a message if an error occurs.
* @see #getDependencies
* @see DependencyUtil#unpackFile(Artifact, File, File, ArchiverManager,
* Log)
@@ -82,9 +84,9 @@ public class UnpackDependenciesMojo
for ( Artifact artifact : dss.getResolvedDependencies() )
{
File destDir;
- destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact,
- useRepositoryLayout, stripVersion, outputDirectory,
- artifact );
+ destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType,
+ useSubDirectoryPerArtifact, useRepositoryLayout,
+ stripVersion, outputDirectory, artifact );
unpack( artifact.getFile(), destDir, getIncludes(), getExcludes() );
DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory );
handler.setMarker();
@@ -111,9 +113,8 @@ public class UnpackDependenciesMojo
}
/**
- * @param excludes
- * A comma separated list of items to exclude
- * i.e. <code>**\/*.xml, **\/*.properties</code>
+ * @param excludes A comma separated list of items to exclude
+ * i.e. <code>**\/*.xml, **\/*.properties</code>
*/
public void setExcludes( String excludes )
{
@@ -129,9 +130,8 @@ public class UnpackDependenciesMojo
}
/**
- * @param includes
- * A comma separated list of items to include
- * i.e. <code>**\/*.xml, **\/*.properties</code>
+ * @param includes A comma separated list of items to include
+ * i.e. <code>**\/*.xml, **\/*.properties</code>
*/
public void setIncludes( String includes )
{
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java Wed Jul 4 13:28:33 2012
@@ -19,11 +19,6 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
@@ -36,100 +31,96 @@ import org.apache.maven.plugin.MojoExecu
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.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
/**
* Abstract Parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of
* ArtifactItems
- *
- * @see ArtifactItem
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
+ * @see ArtifactItem
*/
public abstract class AbstractFromConfigurationMojo
extends AbstractDependencyMojo
{
/**
* Skip the execution
- *
- * @optional
+ *
* @since 2.2
- * @parameter expression="${mdep.skip}" default-value="false"
*/
+ @Parameter( property = "mdep.skip", defaultValue = "false" )
private boolean skip;
/**
* Default location used for mojo unless overridden in ArtifactItem
- *
- * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/dependency"
- * @optional
+ *
* @since 1.0
*/
+ @Parameter( property = "outputDirectory", defaultValue = "${project.build.directory}/dependency" )
private File outputDirectory;
/**
* Overwrite release artifacts
- *
- * @optional
+ *
* @since 1.0
- * @parameter expression="${mdep.overWriteReleases}" default-value="false"
*/
+ @Parameter( property = "mdep.overWriteReleases", defaultValue = "false" )
private boolean overWriteReleases;
/**
* Overwrite snapshot artifacts
- *
- * @optional
+ *
* @since 1.0
- * @parameter expression="${mdep.overWriteSnapshots}" default-value="false"
*/
+ @Parameter( property = "mdep.overWriteSnapshots", defaultValue = "false" )
private boolean overWriteSnapshots;
/**
* Overwrite if newer
- *
- * @optional
+ *
* @since 2.0
- * @parameter expression="${mdep.overIfNewer}" default-value="true"
*/
+ @Parameter( property = "mdep.overIfNewer", defaultValue = "true" )
private boolean overWriteIfNewer;
/**
* To search for artifacts within the reactor and ensure consistent behaviour between Maven 2 and Maven 3.
- *
- * @parameter default-value="${reactorProjects}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true )
protected List<MavenProject> reactorProjects;
/**
* Collection of ArtifactItems to work on. (ArtifactItem contains groupId, artifactId, version, type, classifier,
* location, destFileName, markerFile and overwrite.) See <a href="./usage.html">Usage</a> for details.
- *
- * @parameter
- * @required
+ *
* @since 1.0
*/
+ @Parameter( required = true )
private List<ArtifactItem> artifactItems;
/**
* To look up ArtifactRepository implementation
- *
- * @component
- * @readonly
*/
+ @Component
private ArtifactRepositoryFactory artifactRepositoryManager;
/**
* Path to override default local repository during plugin's execution. To remove all downloaded artifacts as part
* of the build, set this value to a location under your project's target directory
- *
- * @parameter
+ *
* @since 2.2
*/
+ @Parameter
private File localRepositoryDirectory;
/**
@@ -142,7 +133,7 @@ public abstract class AbstractFromConfig
/**
* Preprocesses the list of ArtifactItems. This method defaults the outputDirectory if not set and creates the
* output Directory if it doesn't exist.
- *
+ *
* @param removeVersion remove the version from the filename.
* @return An ArrayList of preprocessed ArtifactItems
* @throws MojoExecutionException with a message if an error occurs.
@@ -176,8 +167,8 @@ public abstract class AbstractFromConfig
if ( StringUtils.isEmpty( artifactItem.getDestFileName() ) )
{
- artifactItem.setDestFileName( DependencyUtil.getFormattedFileName( artifactItem.getArtifact(),
- removeVersion ) );
+ artifactItem.setDestFileName(
+ DependencyUtil.getFormattedFileName( artifactItem.getArtifact(), removeVersion ) );
}
try
@@ -211,7 +202,7 @@ public abstract class AbstractFromConfig
/**
* Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved
* from the dependency list or from the DependencyManagement section of the pom.
- *
+ *
* @param artifactItem containing information about artifact from plugin configuration.
* @return Artifact object representing the specified file.
* @throws MojoExecutionException with a message if the version can't be found in DependencyManagement.
@@ -237,16 +228,14 @@ public abstract class AbstractFromConfig
if ( StringUtils.isEmpty( artifactItem.getClassifier() ) )
{
- artifact =
- factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
- artifactItem.getType(), null, Artifact.SCOPE_COMPILE );
+ artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
+ artifactItem.getType(), null, Artifact.SCOPE_COMPILE );
}
else
{
- artifact =
- factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
- artifactItem.getType(), artifactItem.getClassifier(),
- Artifact.SCOPE_COMPILE );
+ artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
+ artifactItem.getType(), artifactItem.getClassifier(),
+ Artifact.SCOPE_COMPILE );
}
// Maven 3 will search the reactor for the artifact but Maven 2 does not
@@ -284,9 +273,10 @@ public abstract class AbstractFromConfig
/**
* Checks to see if the specified artifact is available from the reactor.
+ *
* @param artifact The artifact we are looking for.
* @return The resolved artifact that is the same as the one we were looking for or <code>null</code> if one could
- * not be found.
+ * not be found.
*/
private Artifact getArtifactFomReactor( Artifact artifact )
{
@@ -321,6 +311,7 @@ public abstract class AbstractFromConfig
/**
* Returns <code>true</code> if the artifact has a file.
+ *
* @param artifact the artifact (may be null)
* @return <code>true</code> if and only if the artifact is non-null and has a file.
*/
@@ -331,67 +322,64 @@ public abstract class AbstractFromConfig
/**
* Null-safe compare of two artifacts based on groupId, artifactId, version, type and classifier.
+ *
* @param a the first artifact.
* @param b the second artifact.
* @return <code>true</code> if and only if the two artifacts have the same groupId, artifactId, version,
- * type and classifier.
+ * type and classifier.
*/
private static boolean equals( Artifact a, Artifact b )
{
- return a == b
- || !( a == null || b == null )
- && StringUtils.equals( a.getGroupId(), b.getGroupId() )
- && StringUtils.equals( a.getArtifactId(), b.getArtifactId() )
- && StringUtils.equals( a.getVersion(), b.getVersion() )
- && StringUtils.equals( a.getType(), b.getType() )
- && StringUtils.equals( a.getClassifier(), b.getClassifier() );
+ return a == b || !( a == null || b == null ) && StringUtils.equals( a.getGroupId(), b.getGroupId() )
+ && StringUtils.equals( a.getArtifactId(), b.getArtifactId() ) && StringUtils.equals( a.getVersion(),
+ b.getVersion() )
+ && StringUtils.equals( a.getType(), b.getType() ) && StringUtils.equals( a.getClassifier(),
+ b.getClassifier() );
}
/**
* Tries to find missing version from dependency list and dependency management. If found, the artifact is updated
* with the correct version. It will first look for an exact match on artifactId/groupId/classifier/type and if it
* doesn't find a match, it will try again looking for artifactId and groupId only.
- *
+ *
* @param artifact representing configured file.
* @throws MojoExecutionException
*/
private void fillMissingArtifactVersion( ArtifactItem artifact )
throws MojoExecutionException
{
- @SuppressWarnings( "unchecked" )
- List<Dependency> deps = project.getDependencies();
- @SuppressWarnings( "unchecked" )
- List<Dependency> depMngt = project.getDependencyManagement() == null
+ @SuppressWarnings( "unchecked" ) List<Dependency> deps = project.getDependencies();
+ @SuppressWarnings( "unchecked" ) List<Dependency> depMngt = project.getDependencyManagement() == null
? Collections.<Dependency>emptyList()
: project.getDependencyManagement().getDependencies();
- if ( !findDependencyVersion( artifact, deps, false )
- && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, false ) )
- && !findDependencyVersion( artifact, deps, true )
+ if ( !findDependencyVersion( artifact, deps, false ) && ( project.getDependencyManagement() == null
+ || !findDependencyVersion( artifact, depMngt, false ) ) && !findDependencyVersion( artifact, deps, true )
&& ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, true ) ) )
{
- 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." );
}
}
/**
* Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct
* version.
- *
- * @param artifact representing configured file.
+ *
+ * @param artifact representing configured file.
* @param dependencies list of dependencies to search.
- * @param looseMatch only look at artifactId and groupId
+ * @param looseMatch only look at artifactId and groupId
* @return the found dependency
*/
private boolean findDependencyVersion( ArtifactItem artifact, List<Dependency> dependencies, boolean looseMatch )
{
for ( Dependency dependency : dependencies )
{
- if ( StringUtils.equals( dependency.getArtifactId(), artifact.getArtifactId() )
- && StringUtils.equals( dependency.getGroupId(), artifact.getGroupId() )
- && ( looseMatch || StringUtils.equals( dependency.getClassifier(), artifact.getClassifier() ) )
- && ( looseMatch || StringUtils.equals( dependency.getType(), artifact.getType() ) ) )
+ if ( StringUtils.equals( dependency.getArtifactId(), artifact.getArtifactId() ) && StringUtils.equals(
+ dependency.getGroupId(), artifact.getGroupId() ) && ( looseMatch || StringUtils.equals(
+ dependency.getClassifier(), artifact.getClassifier() ) ) && ( looseMatch || StringUtils.equals(
+ dependency.getType(), artifact.getType() ) ) )
{
artifact.setVersion( dependency.getVersion() );
@@ -416,7 +404,7 @@ public abstract class AbstractFromConfig
/**
* Override the base to
- *
+ *
* @return Returns the local.
*/
protected ArtifactRepository getLocal()
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java Wed Jul 4 13:28:33 2012
@@ -19,38 +19,38 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.util.List;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter;
import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import java.io.File;
+import java.util.List;
/**
* Goal that copies a list of artifacts from the repository to defined locations.
- *
- * @goal copy
- * @since 1.0
- * @phase process-sources
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
+ * @since 1.0
*/
+@Mojo( name = "copy", defaultPhase = LifecyclePhase.PROCESS_SOURCES )
public class CopyMojo
extends AbstractFromConfigurationMojo
{
/**
* Strip artifact version during copy
- *
- * @parameter expression="${mdep.stripVersion}" default-value="false"
- * @parameter
*/
+ @Parameter( property = "mdep.stripVersion", defaultValue = "false" )
private boolean stripVersion = false;
/**
* Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to
* copyArtifact.
- *
+ *
* @throws MojoExecutionException with a message if an error occurs.
* @see ArtifactItem
* @see #getArtifactItems
@@ -80,7 +80,7 @@ public class CopyMojo
/**
* Resolves the artifact from the repository and copies it to the specified location.
- *
+ *
* @param artifactItem containing the information about the Artifact to copy.
* @throws MojoExecutionException with a message if an error occurs.
* @see DependencyUtil#copyFile(File, File, Log)
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java Wed Jul 4 13:28:33 2012
@@ -19,60 +19,61 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.util.List;
-
import org.apache.maven.plugin.MojoExecutionException;
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.MarkerHandler;
import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+import java.util.List;
+
/**
* Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.
- *
- * @since 1.0
- * @goal unpack
- * @phase process-sources
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
+ * @since 1.0
*/
+@Mojo( name = "unpack", defaultPhase = LifecyclePhase.PROCESS_SOURCES )
public final class UnpackMojo
extends AbstractFromConfigurationMojo
{
/**
* Directory to store flag files after unpack
- *
- * @parameter expression="${project.build.directory}/dependency-maven-plugin-markers"
*/
+ @Parameter( defaultValue = "${project.build.directory}/dependency-maven-plugin-markers" )
private File markersDirectory;
/**
* A comma separated list of file patterns to include when unpacking the artifact. i.e. **\/*.xml,**\/*.properties
* NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name
* );)
- *
+ *
* @since 2.0-alpha-5
- * @parameter expression="${mdep.unpack.includes}"
*/
+ @Parameter( property = "mdep.unpack.includes" )
private String includes;
/**
* A comma separated list of file patterns to exclude when unpacking the artifact. i.e. **\/*.xml,**\/*.properties
* NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name
* );)
- *
+ *
* @since 2.0-alpha-5
- * @parameter expression="${mdep.unpack.excludes}"
*/
+ @Parameter( property = "mdep.unpack.excludes" )
private String excludes;
/**
* Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to
* unpackArtifact.
- *
+ *
* @throws MojoExecutionException with a message if an error occurs.
* @see ArtifactItem
* @see #getArtifactItems
@@ -102,7 +103,7 @@ public final class UnpackMojo
/**
* This method gets the Artifact object and calls DependencyUtil.unpackFile.
- *
+ *
* @param artifactItem containing the information about the Artifact to unpack.
* @throws MojoExecutionException with a message if an error occurs.
* @see #getArtifact
@@ -122,8 +123,8 @@ public final class UnpackMojo
{
MarkerHandler handler = new UnpackFileMarkerHandler( item, this.markersDirectory );
- return new MarkerFileFilter( this.isOverWriteReleases(), this.isOverWriteSnapshots(),
- this.isOverWriteIfNewer(), handler );
+ return new MarkerFileFilter( this.isOverWriteReleases(), this.isOverWriteSnapshots(), this.isOverWriteIfNewer(),
+ handler );
}
protected List<ArtifactItem> getProcessedArtifactItems( boolean removeVersion )
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java Wed Jul 4 13:28:33 2012
@@ -19,25 +19,27 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.AbstractResolveMojo;
import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import java.util.Set;
+
/**
* Goal that resolves all project dependencies, including plugins and reports
* and their dependencies.
- *
- * @goal go-offline
- * @execute goal=resolve-plugins
- * @requiresDependencyResolution test
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
* @since 2.0
*/
+@Mojo( name = "go-offline", requiresDependencyResolution = ResolutionScope.TEST )
+@Execute( goal = "resolve-plugins" )
public class GoOfflineMojo
extends AbstractResolveMojo
{
@@ -45,16 +47,13 @@ public class GoOfflineMojo
/**
* Main entry into mojo. Gets the list of dependencies and iterates through
* displaying the resolved version.
- *
- * @throws MojoExecutionException
- * with a message if an error occurs.
- *
+ *
+ * @throws MojoExecutionException with a message if an error occurs.
*/
public void execute()
throws MojoExecutionException
{
- @SuppressWarnings( "unchecked" )
- Set<Artifact> artifacts = project.getArtifacts();
+ @SuppressWarnings( "unchecked" ) Set<Artifact> artifacts = project.getArtifacts();
if ( !silent )
{
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java Wed Jul 4 13:28:33 2012
@@ -19,53 +19,53 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.AbstractDependencyMojo;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
/**
* Goal that resolves all project dependencies and then lists the repositories
* used by the build and by the transitive dependencies
*
- * @goal list-repositories
- * @requiresDependencyResolution test
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id: GoOfflineMojo.java 728546 2008-12-21 22:56:51Z bentmann $
* @since 2.2
*/
+@Mojo( name = "list-repositories", requiresDependencyResolution = ResolutionScope.TEST )
public class ListRepositoriesMojo
extends AbstractDependencyMojo
{
- /**
+ /**
* Displays a list of the repositories used by this build.
- * @throws MojoExecutionException
- * with a message if an error occurs.
- *
- */
+ *
+ * @throws MojoExecutionException with a message if an error occurs.
+ */
public void execute()
throws MojoExecutionException
- {
- try
- {
+ {
+ try
+ {
ArtifactResolutionResult result =
this.artifactCollector.collect( project.getArtifacts(), project.getArtifact(), this.getLocal(),
this.remoteRepos, this.artifactMetadataSource,
new ScopeArtifactFilter( Artifact.SCOPE_TEST ), new ArrayList() );
- Set repos = new HashSet();
- Set<ResolutionNode> nodes = result.getArtifactResolutionNodes();
+ Set repos = new HashSet();
+ Set<ResolutionNode> nodes = result.getArtifactResolutionNodes();
for ( ResolutionNode node : nodes )
- {
+ {
repos.addAll( node.getRemoteRepositories() );
- }
+ }
this.getLog().info( "Repositories Used by this build:" );
for ( Iterator i = repos.iterator(); i.hasNext(); )
@@ -77,5 +77,5 @@ public class ListRepositoriesMojo
{
throw new MojoExecutionException( "Unable to resolve artifacts", e );
}
- }
+ }
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java Wed Jul 4 13:28:33 2012
@@ -19,26 +19,29 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.IOException;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.AbstractResolveMojo;
import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
import org.apache.maven.plugin.dependency.utils.DependencyUtil;
import org.apache.maven.plugin.dependency.utils.filters.ResolveFileFilter;
import org.apache.maven.plugin.dependency.utils.markers.SourcesFileMarkerHandler;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import java.io.IOException;
+
/**
* Goal that resolves the project dependencies from the repository.
*
- * @goal resolve
- * @requiresDependencyResolution test
- * @phase generate-sources
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
* @since 2.0
*/
+@Mojo( name = "resolve", requiresDependencyResolution = ResolutionScope.TEST,
+ defaultPhase = LifecyclePhase.GENERATE_SOURCES )
public class ResolveDependenciesMojo
extends AbstractResolveMojo
{
@@ -46,9 +49,9 @@ public class ResolveDependenciesMojo
/**
* If we should display the scope when resolving
*
- * @parameter expression="${mdep.outputScope}" default-value="true"
* @since 2.0-alpha-2
*/
+ @Parameter( property = "mdep.outputScope", defaultValue = "true" )
protected boolean outputScope;
/**
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java Wed Jul 4 13:28:33 2012
@@ -19,8 +19,6 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.IOException;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.AbstractResolveMojo;
@@ -28,18 +26,22 @@ import org.apache.maven.plugin.dependenc
import org.apache.maven.plugin.dependency.utils.DependencyUtil;
import org.apache.maven.plugin.dependency.utils.filters.ResolveFileFilter;
import org.apache.maven.plugin.dependency.utils.markers.SourcesFileMarkerHandler;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import java.io.IOException;
+
/**
* Goal that resolves the project source dependencies from the repository.
*
- * @goal sources
- * @phase generate-sources
- * @requiresDependencyResolution test
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
* @since 2.0-alpha2
*/
+@Mojo( name = "sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES,
+ requiresDependencyResolution = ResolutionScope.TEST )
public class ResolveDependencySourcesMojo
extends AbstractResolveMojo
{
@@ -57,9 +59,7 @@ public class ResolveDependencySourcesMoj
* Main entry into mojo. Gets the list of dependencies and iterates through
* resolving the source jars.
*
- * @throws MojoExecutionException
- * with a message if an error occurs.
- *
+ * @throws MojoExecutionException with a message if an error occurs.
*/
public void execute()
throws MojoExecutionException
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java Wed Jul 4 13:28:33 2012
@@ -15,13 +15,6 @@ package org.apache.maven.plugin.dependen
* the License.
*/
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -29,47 +22,50 @@ import org.apache.maven.artifact.resolve
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.AbstractResolveMojo;
import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
import org.codehaus.plexus.util.IOUtil;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* Goal that resolves all project plugins and reports and their dependencies.
- *
- * @goal resolve-plugins
- * @phase generate-sources
+ *
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
* @version $Id$
* @since 2.0
*/
+@Mojo( name = "resolve-plugins", defaultPhase = LifecyclePhase.GENERATE_SOURCES )
public class ResolvePluginsMojo
extends AbstractResolveMojo
{
/**
* Remote repositories which will be searched for plugins.
- *
- * @parameter default-value="${project.pluginArtifactRepositories}"
- * @required
- * @readonly
*/
+ @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
private List<ArtifactRepository> remotePluginRepositories;
/**
* If we should exclude transitive dependencies
- *
- * @parameter expression="${excludeTransitive}" default-value="false"
*/
+ @Parameter( property = "excludeTransitive", defaultValue = "false" )
private boolean excludeTransitive;
/**
* Main entry into mojo. Gets the list of dependencies and iterates through
* displaying the resolved version.
- *
- * @throws MojoExecutionException
- * with a message if an error occurs.
- *
+ *
+ * @throws MojoExecutionException with a message if an error occurs.
*/
public void execute()
throws MojoExecutionException
@@ -112,7 +108,7 @@ public class ResolvePluginsMojo
{
this.getLog().info( logStr );
}
-
+
if ( outputWriter != null )
{
outputWriter.write( logStr );
@@ -151,30 +147,21 @@ public class ResolvePluginsMojo
/**
* This method resolves the plugin artifacts from the project.
- *
- * @param project
- * The POM.
- * @param artifactFactory
- * component to build artifact objects.
- * @param localRepository
- * where to resolve artifacts.
- * @param remotePluginRepositories
- * list of remote repositories used to resolve plugins.
- * @param artifactResolver
- * component used to resolve artifacts.
- *
+ *
+ * @param project The POM.
+ * @param artifactFactory component to build artifact objects.
+ * @param localRepository where to resolve artifacts.
+ * @param remotePluginRepositories list of remote repositories used to resolve plugins.
+ * @param artifactResolver component used to resolve artifacts.
* @return set of resolved plugin artifacts.
- *
* @throws ArtifactResolutionException
* @throws ArtifactNotFoundException
*/
protected Set<Artifact> resolvePluginArtifacts()
throws ArtifactResolutionException, ArtifactNotFoundException
{
- @SuppressWarnings( "unchecked" )
- Set<Artifact> plugins = project.getPluginArtifacts();
- @SuppressWarnings( "unchecked" )
- Set<Artifact> reports = project.getReportArtifacts();
+ @SuppressWarnings( "unchecked" ) Set<Artifact> plugins = project.getPluginArtifacts();
+ @SuppressWarnings( "unchecked" ) Set<Artifact> reports = project.getReportArtifacts();
Set<Artifact> artifacts = new HashSet<Artifact>();
artifacts.addAll( reports );
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java Wed Jul 4 13:28:33 2012
@@ -19,16 +19,17 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-
import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+
/**
* @author <a href="mailto:dbradicich@comcast.net">Damian Bradicich</a>
* @version $Id$
*/
-public class UnpackFileMarkerHandler extends DefaultFileMarkerHandler
+public class UnpackFileMarkerHandler
+ extends DefaultFileMarkerHandler
{
protected ArtifactItem artifactItem;
@@ -52,9 +53,8 @@ public class UnpackFileMarkerHandler ext
* times with different include/exclude parameters
*/
File markerFile = null;
- if ( this.artifactItem == null
- || ( StringUtils.isEmpty( this.artifactItem.getIncludes() )
- && StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) )
+ if ( this.artifactItem == null || ( StringUtils.isEmpty( this.artifactItem.getIncludes() )
+ && StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) )
{
markerFile = super.getMarkerFile();
}
@@ -72,7 +72,8 @@ public class UnpackFileMarkerHandler ext
includeExcludeHash += this.artifactItem.getExcludes().hashCode();
}
- markerFile = new File( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash );
+ markerFile =
+ new File( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash );
}
return markerFile;
@@ -88,7 +89,7 @@ public class UnpackFileMarkerHandler ext
}
}
- public ArtifactItem getArtifactItem( )
+ public ArtifactItem getArtifactItem()
{
return this.artifactItem;
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java?rev=1357251&r1=1357250&r2=1357251&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java Wed Jul 4 13:28:33 2012
@@ -19,11 +19,6 @@ package org.apache.maven.plugin.dependen
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
@@ -32,23 +27,30 @@ import org.apache.maven.plugin.dependenc
import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
import org.apache.maven.plugin.testing.stubs.StubArtifactCollector;
import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
public class TestIncludeExcludeUnpackMojo
- extends AbstractDependencyMojoTestCase
+ extends AbstractDependencyMojoTestCase
{
- private final String PACKED_FILE = "test.zip";
+ private final String PACKED_FILE = "test.zip";
+
+ private final String UNPACKED_FILE_PREFIX = "test";
- private final String UNPACKED_FILE_PREFIX = "test";
- private final String UNPACKED_FILE_SUFFIX = ".txt";
+ private final String UNPACKED_FILE_SUFFIX = ".txt";
- private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE;
+ private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE;
- UnpackMojo mojo;
+ UnpackMojo mojo;
protected void setUp()
throws Exception
{
- // required for mojo lookups to work
+ // required for mojo lookups to work
super.setUp( "unpack", true );
File testPom = new File( getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml" );
@@ -68,6 +70,8 @@ public class TestIncludeExcludeUnpackMoj
assertNotNull( mojo );
assertNotNull( mojo.getProject() );
+ mojo.setArchiverManager( (ArchiverManager) lookup( ArchiverManager.ROLE ) );
+
mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
mojo.setMarkersDirectory( new File( this.testDir, "markers" ) );
@@ -106,112 +110,118 @@ public class TestIncludeExcludeUnpackMoj
private void assertUnpacked( boolean unpacked, String fileName )
{
- File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName );
- assertEquals(unpacked, destFile.exists());
+ File destFile = new File( mojo.getOutputDirectory().getAbsolutePath(), fileName );
+ assertEquals( unpacked, destFile.exists() );
}
/**
* This test will validate that only the 1 and 11 files get unpacked
+ *
* @throws Exception
*/
public void testUnpackIncludesManyFiles()
- throws Exception
- {
+ throws Exception
+ {
mojo.setIncludes( "**/*1" + UNPACKED_FILE_SUFFIX );
mojo.execute();
assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
/**
* This test will verify only the 2 file gets unpacked
+ *
* @throws Exception
*/
public void testUnpackIncludesSingleFile()
- throws Exception
- {
+ throws Exception
+ {
mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX );
mojo.execute();
assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
/**
* This test will verify all files get unpacked
+ *
* @throws Exception
*/
public void testUnpackIncludesAllFiles()
- throws Exception
- {
+ throws Exception
+ {
mojo.setIncludes( "**/*" );
mojo.execute();
assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
/**
* This test will validate that only the 2 and 3 files get unpacked
+ *
* @throws Exception
*/
public void testUnpackExcludesManyFiles()
- throws Exception
- {
+ throws Exception
+ {
mojo.setExcludes( "**/*1" + UNPACKED_FILE_SUFFIX );
mojo.execute();
assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
/**
* This test will verify only the 1, 11 & 3 files get unpacked
+ *
* @throws Exception
*/
public void testUnpackExcludesSingleFile()
- throws Exception
- {
+ throws Exception
+ {
mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX );
mojo.execute();
assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
/**
* This test will verify no files get unpacked
+ *
* @throws Exception
*/
public void testUnpackExcludesAllFiles()
- throws Exception
- {
+ throws Exception
+ {
mojo.setExcludes( "**/*" );
mojo.execute();
assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
public void testNoIncludeExcludes()
- throws Exception
- {
+ throws Exception
+ {
mojo.execute();
assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
public void testIncludeArtifactItemOverride()
- throws Exception
+ throws Exception
{
Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
ArtifactItem item = stubFactory.getArtifactItem( artifact );
@@ -228,8 +238,8 @@ public class TestIncludeExcludeUnpackMoj
}
public void testExcludeArtifactItemOverride()
- throws Exception
- {
+ throws Exception
+ {
Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
ArtifactItem item = stubFactory.getArtifactItem( artifact );
item.setExcludes( "**/*" );
@@ -242,11 +252,11 @@ public class TestIncludeExcludeUnpackMoj
assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- }
+ }
public void testIncludeArtifactItemMultipleMarker()
- throws Exception
- {
+ throws Exception
+ {
List<ArtifactItem> list = new ArrayList<ArtifactItem>();
Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
ArtifactItem item = stubFactory.getArtifactItem( artifact );
@@ -264,11 +274,11 @@ public class TestIncludeExcludeUnpackMoj
assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
assertMarkerFiles( mojo.getArtifactItems(), true );
- }
+ }
public void testIncludeArtifactItemMultipleExecutions()
- throws Exception
- {
+ throws Exception
+ {
List<ArtifactItem> list = new ArrayList<ArtifactItem>();
Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
ArtifactItem item = stubFactory.getArtifactItem( artifact );
@@ -287,20 +297,20 @@ public class TestIncludeExcludeUnpackMoj
assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
assertMarkerFiles( mojo.getArtifactItems(), true );
- // Now run again and make sure the extracted files haven't gotten overwritten
+ // Now run again and make sure the extracted files haven't gotten overwritten
File destFile2 =
new File( mojo.getOutputDirectory().getAbsolutePath(), UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
File destFile3 =
new File( mojo.getOutputDirectory().getAbsolutePath(), UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
- long time = System.currentTimeMillis();
+ long time = System.currentTimeMillis();
time = time - ( time % 1000 );
destFile2.setLastModified( time );
destFile3.setLastModified( time );
assertEquals( time, destFile2.lastModified() );
assertEquals( time, destFile3.lastModified() );
Thread.sleep( 100 );
- mojo.execute();
- assertEquals( time, destFile2.lastModified() );
+ mojo.execute();
+ assertEquals( time, destFile2.lastModified() );
assertEquals( time, destFile3.lastModified() );
- }
+ }
}