This is an automated email from the ASF dual-hosted git repository. hboutemy pushed a commit to annotated tag maven-help-plugin-2.0.2 in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
commit b46eb5c3e5dea5ac0660ae7c12823ed845dc4e75 Author: Brian E Fox <bri...@apache.org> AuthorDate: Thu Jun 7 03:44:00 2007 +0000 MPH-24: moved tree over to dependency plugin git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-help-plugin@545050 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 6 +- .../maven/plugins/help/DependenciesMojo.java | 258 --------------------- src/site/apt/index.apt | 3 +- src/site/apt/usage.apt | 14 +- 4 files changed, 3 insertions(+), 278 deletions(-) diff --git a/pom.xml b/pom.xml index e70d609..0f88434 100644 --- a/pom.xml +++ b/pom.xml @@ -49,11 +49,6 @@ <artifactId>maven-plugin-descriptor</artifactId> <version>2.0</version> </dependency> - <dependency> - <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-dependency-tree</artifactId> - <version>1.0-alpha-2</version> - </dependency> </dependencies> <reporting> <plugins> @@ -65,3 +60,4 @@ </reporting> </project> + diff --git a/src/main/java/org/apache/maven/plugins/help/DependenciesMojo.java b/src/main/java/org/apache/maven/plugins/help/DependenciesMojo.java deleted file mode 100644 index cffb119..0000000 --- a/src/main/java/org/apache/maven/plugins/help/DependenciesMojo.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.maven.plugins.help; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; -import java.util.Iterator; - -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.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.dependency.tree.DependencyNode; -import org.apache.maven.shared.dependency.tree.DependencyTree; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; - -/** - * Displays the dependency tree for this project. - * - * @author <a href="mailto:markhob...@gmail.com">Mark Hobson</a> - * @version $Id$ - * @goal dependencies - * @requiresDependencyResolution test - */ -public class DependenciesMojo extends AbstractMojo -{ - // constants -------------------------------------------------------------- - - /** - * The indentation string to use when serialising the dependency tree. - */ - private static final String INDENT = " "; - - /** - * The newline string to use when serialising the dependency tree. - */ - private static final String NEWLINE = System.getProperty( "line.separator" ); - - // fields ----------------------------------------------------------------- - - /** - * The Maven project. - * - * @parameter expression="${project}" - * @required - * @readonly - */ - private MavenProject project; - - /** - * The artifact respository to use. - * - * @parameter expression="${localRepository}" - * @required - * @readonly - */ - private ArtifactRepository localRepository; - - /** - * The artifact factory to use. - * - * @component - */ - private ArtifactFactory artifactFactory; - - /** - * The artifact metadata source to use. - * - * @component - */ - private ArtifactMetadataSource artifactMetadataSource; - - /** - * The artifact collector to use. - * - * @component - */ - private ArtifactCollector artifactCollector; - - /** - * The dependency tree builder to use. - * - * @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. - * - * @parameter expression="${output}" - */ - private File output; - - // Mojo methods ----------------------------------------------------------- - - /* - * @see org.apache.maven.plugin.Mojo#execute() - */ - public void execute() throws MojoExecutionException, MojoFailureException - { - try - { - DependencyTree dependencyTree = - dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory, - artifactMetadataSource, artifactCollector ); - - String dependencyTreeString = serialiseDependencyTree( dependencyTree ); - - 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 ); - } - } - - // private methods -------------------------------------------------------- - - /** - * Serialises the specified dependency tree to a string. - * - * @param tree - * the dependency tree to serialise - * @return the serialised dependency tree - */ - private String serialiseDependencyTree( DependencyTree tree ) - { - StringBuffer buffer = new StringBuffer(); - - serialiseDependencyNode( tree.getRootNode(), buffer ); - - return buffer.toString(); - } - - /** - * Serialises the specified dependency node and it's children to the specified string buffer. - * - * @param node - * the dependency node to log - * @param buffer - * the string buffer to serialise to - */ - private void serialiseDependencyNode( DependencyNode node, StringBuffer buffer ) - { - // serialise node - - for ( int i = 0; i < node.getDepth(); i++ ) - { - buffer.append( INDENT ); - } - - buffer.append( node.getArtifact() ).append( NEWLINE ); - - // serialise children - - for ( Iterator iterator = node.getChildren().iterator(); iterator.hasNext(); ) - { - DependencyNode child = (DependencyNode) iterator.next(); - - serialiseDependencyNode( child, buffer ); - } - } - - /** - * 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(); - } -} diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index 4562697..a1dac85 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -19,8 +19,6 @@ Maven 2 Help Plugin * {{{active-profiles-mojo.html}help:active-profiles}} lists the profiles which are currently active for the build. - * {{{dependencies-mojo.html}help:dependencies}} prints out the dependency tree for the project. - * {{{describe-mojo.html}help:describe}} describes the attirbutes of a plugin and/or plugin mojo. For its execution, it requires the groupId and artifactId or the plugin prefix of the plugin to be specified. @@ -42,3 +40,4 @@ Maven 2 Help Plugin * {{{examples/describe-configuration.html}Configuring Describe Mojo}} + diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index 7436c0d..8467f6e 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -25,19 +25,6 @@ Usage mvn help:active-profiles -Doutput=/path/to/file +-----+ -* The <<<help:dependencies>>> Mojo - - The <<<dependencies>>> mojo is used to view the dependency hierarchy of the project currently being built. - It will output the resolved tree of dependencies that the Maven build process actually uses. - - Optionally, the <<<output>>> parameter can be specified to divert this output to a file. - - You can execute this mojo using the following command: - -+-----+ -mvn help:dependencies -Doutput=/path/to/file -+-----+ - * The <<<help:describe>>> Mojo The <<<describe>>> mojo is used to discover information about Maven plugins. Given a plugin prefix or groupId, artifactId, @@ -89,3 +76,4 @@ mvn help:effective-settings -Doutput=/path/to/file +-----+ + -- To stop receiving notification emails like this one, please contact "commits@maven.apache.org" <commits@maven.apache.org>.