Author: brianf Date: Sun Jan 14 16:09:28 2007 New Revision: 496197 URL: http://svn.apache.org/viewvc?view=rev&rev=496197 Log: MDEP-26: added site info
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java?view=diff&rev=496197&r1=496196&r2=496197 ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java Sun Jan 14 16:09:28 2007 @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; import java.util.List; import org.apache.maven.plugin.AbstractMojo; @@ -33,6 +34,7 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.ReflectionUtils; /** * @author brianf @@ -203,6 +205,11 @@ unArchiver.setDestDirectory( location ); + if (this.silent) + { + silenceUnarchiver(unArchiver); + } + unArchiver.extract(); } catch ( NoSuchArchiverException e ) @@ -221,6 +228,24 @@ e.printStackTrace(); throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location + "\r\n" + e.toString(), e ); + } + } + + private void silenceUnarchiver( UnArchiver unArchiver ) + { + // dangerous but handle any errors. It's the only way to silence the + // unArchiver. + try + { + Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( "logger", unArchiver.getClass() ); + + field.setAccessible( true ); + + field.set( unArchiver, this.getLog() ); + } + catch ( Exception e ) + { + // was a nice try. Don't bother logging because the log is silent. } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java?view=diff&rev=496197&r1=496196&r2=496197 ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java Sun Jan 14 16:09:28 2007 @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.Writer; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -39,13 +38,13 @@ import org.apache.maven.plugin.dependency.utils.filters.ArtifactsFilter; /** - * Goal that copies the project dependencies from the repository to a defined - * location. + * This goal will output a classpath string of dependencies from the local repository to a file or log. * * @goal build-classpath * @requiresDependencyResolution compile - * @phase process-sources + * @phase generate-sources * @author ankostis + * @since 2.0-alpha-2 */ public class BuildClasspathMojo extends AbstractDependencyFilterMojo @@ -53,7 +52,7 @@ { /** - * Strip artifact version during copy + * Strip artifact version during copy (only works if prefix is set) * * @parameter expression="${stripVersion}" default-value="false" * @parameter Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt?view=diff&rev=496197&r1=496196&r2=496197 ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt Sun Jan 14 16:09:28 2007 @@ -21,7 +21,7 @@ Allan Ramirez Brian Fox ------ - Nov 2006 + Jan 2007 ------ Maven Dependency Plugin @@ -32,7 +32,7 @@ * Goals Overview - Dependency plugin has 9 goals: + Dependency plugin has 10 goals: *{{{copy-mojo.html}dependency:copy}} takes a list of artifacts defined in the plugin configuration section and copies them to a specified location, @@ -63,6 +63,10 @@ *{{{purge-local-repository-mojo.html}dependency:purge-local-repository}} tells Maven to clear all dependency-artifact files out of the local repository, and optionally re-resolve them. + + *{{{build-classpath-mojo.html}dependency:build-classpath}} tells + Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp + [] Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt?view=diff&rev=496197&r1=496196&r2=496197 ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt Sun Jan 14 16:09:28 2007 @@ -402,3 +402,60 @@ correct resolution. +* The <<<dependency:build-classpath>>> mojo + + Since: 2.0-alpha-2 + + This goal will output a classpath string of dependencies from the local repository to a file or log. For instance, the file would contain a classpath string like this: + ++---+ +/home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ .... ++---+ + + The resulting file could then be used like this: + ++---+ +java -cp `cat resultFile` MyClass ++---+ + + In its simplest form, to output the classpath to the log, the mojo can be called like this: + ++---+ +mvn dependency:build-classpath ++---+ + + or to write the classpath to cp.txt.: + ++---+ +mvn dependency:build-classpath -Dmaven.dep.cpFile=cp.txt ++---+ + + The goal can also be bound to a lifecycle phase with the following configuration: + ++---+ + <project> + [...] + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>build-classpath</id> + <phase>generate-sources</phase> + <goals> + <goal>build-classpath</goal> + </goals> + <configuration> + <!-- configure the plugin here --> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + [...] +</project> ++---+ + Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java?view=diff&rev=496197&r1=496196&r2=496197 ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java Sun Jan 14 16:09:28 2007 @@ -22,9 +22,6 @@ import java.io.File; import java.util.Set; -import org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo; -import org.apache.maven.plugin.dependency.utils.DependencyStatusSets; -import org.apache.maven.plugin.dependency.utils.SilentLog; import org.apache.maven.project.MavenProject; public class TestBuildClasspathMojo