maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dant...@apache.org
Subject svn commit: r894988 - /maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
Date Fri, 01 Jan 2010 10:14:28 GMT
Author: dantran
Date: Fri Jan  1 10:14:27 2010
New Revision: 894988

URL: http://svn.apache.org/viewvc?rev=894988&view=rev
Log:
[MDEP-161] Honor outputFile configuration in depenendy:resolve-plugins goal

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java

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=894988&r1=894987&r2=894988&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
Fri Jan  1 10:14:27 2010
@@ -1,24 +1,23 @@
 package org.apache.maven.plugin.dependency.resolvers;
 
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.    
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
  */
 
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -33,6 +32,7 @@
 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;
 
 /**
  * Goal that resolves all project plugins and reports and their dependencies.
@@ -74,32 +74,62 @@
     public void execute()
         throws MojoExecutionException
     {
+        Writer outputWriter = null;
+
         try
         {
             Set plugins = resolvePluginArtifacts();
+
+            if ( this.outputFile != null )
+            {
+                outputFile.getParentFile().mkdirs();
+
+                outputWriter = new FileWriter( outputFile );
+            }
+
             for ( Iterator i = plugins.iterator(); i.hasNext(); )
             {
                 Artifact plugin = (Artifact) i.next();
+
+                String logStr = "Plugin Resolved: " + DependencyUtil.getFormattedFileName(
plugin, false );
                 if ( !silent )
                 {
-                    this.getLog().info( "Plugin Resolved: " + DependencyUtil.getFormattedFileName(
plugin, false ) );
+                    this.getLog().info( logStr );
+                }
+
+                if ( outputWriter != null )
+                {
+                    outputWriter.write( logStr );
+                    outputWriter.write( "\n" );
                 }
+
                 if ( !excludeTransitive )
                 {
                     Set transitiveDependencies = this.resolveArtifactDependencies( plugin
);
-                    if ( !silent )
+
+                    for ( Iterator transIter = transitiveDependencies.iterator(); transIter.hasNext();
)
                     {
-                        for ( Iterator transIter = transitiveDependencies.iterator(); transIter.hasNext();
)
+                        logStr = "    Plugin Dependency Resolved: "
+                            + DependencyUtil.getFormattedFileName( (Artifact) transIter.next(),
false );
+
+                        if ( !silent )
+                        {
+                            this.getLog().info( logStr );
+                        }
+                        
+                        if ( outputWriter != null )
                         {
-                            this.getLog().info(
-                                                "    Plugin Dependency Resolved: "
-                                                    + DependencyUtil.getFormattedFileName(
(Artifact) transIter.next(),
-                                                                                        
  false ) );
+                            outputWriter.write( logStr );
+                            outputWriter.write( "\n" );
                         }
                     }
                 }
             }
         }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Nested:", e );
+        }
         catch ( ArtifactResolutionException e )
         {
             throw new MojoExecutionException( "Nested:", e );
@@ -116,6 +146,10 @@
         {
             throw new MojoExecutionException( "Nested:", e );
         }
+        finally
+        {
+            IOUtil.close( outputWriter );
+        }
 
     }
 



Mime
View raw message