You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2008/01/03 04:56:57 UTC
svn commit: r608334 - in /maven/plugins/trunk/maven-dependency-plugin/src:
main/java/org/apache/maven/plugin/dependency/
main/java/org/apache/maven/plugin/dependency/resolvers/
main/java/org/apache/maven/plugin/dependency/utils/
test/java/org/apache/ma...
Author: brianf
Date: Wed Jan 2 19:56:56 2008
New Revision: 608334
URL: http://svn.apache.org/viewvc?rev=608334&view=rev
Log:
MDEP-111: allow output to files on resolve goals and consolidate outputfile parameters
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java Wed Jan 2 19:56:56 2008
@@ -19,6 +19,7 @@
* under the License.
*/
+import java.io.File;
import java.util.Iterator;
import java.util.Set;
@@ -47,7 +48,14 @@
* @readonly
*/
protected MavenProjectBuilder mavenProjectBuilder;
-
+ /**
+ * If specified, this parameter will cause the dependencies to be written to the path specified, instead of writing
+ * to the console.
+ *
+ * @parameter expression="${outputFile}"
+ * @since 2.0-alpha-5
+ */
+ protected File outputFile;
/**
* This method resolves the dependency artifacts from the project.
*
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java Wed Jan 2 19:56:56 2008
@@ -22,6 +22,8 @@
import java.io.File;
import java.util.Locale;
import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
@@ -29,7 +31,6 @@
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException;
-import org.apache.maven.doxia.sink.Sink;
/**
* Analyzes the dependencies of this project and produces a report that summarises which are: used and declared; used
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java Wed Jan 2 19:56:56 2008
@@ -21,6 +21,7 @@
import java.util.Iterator;
import java.util.ResourceBundle;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis;
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?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- 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 Wed Jan 2 19:56:56 2008
@@ -72,12 +72,20 @@
/**
* The file to write the classpath string. If undefined, it just prints the classpath as [INFO].
- *
+ * This parameter is deprecated. Use outputFile instead.
* @parameter expression="${mdep.cpFile}"
+ * @deprecated use outputFile instead
+ * @since 2.0-alpha-5
*/
private File cpFile;
/**
+ * The file to write the classpath string. If undefined, it just prints the classpath as [INFO].
+ * @parameter expression="${mdep.outputFile}"
+ */
+ private File outputFile;
+
+ /**
* If 'true', it skips the up-to-date-check, and always regenerates the classpath file.
*
* @parameter default-value="false" expression="${mdep.regenerateFile}"
@@ -152,6 +160,13 @@
public void execute()
throws MojoExecutionException
{
+
+ if (cpFile != null)
+ {
+ getLog().warn( "The parameter cpFile is deprecated. Use outputFile instead." );
+ this.outputFile = cpFile;
+ }
+
// initialize the separators.
if ( StringUtils.isEmpty( fileSeparator ) )
{
@@ -223,7 +238,7 @@
cpString = "classpath="+ cpString;
}
- if ( cpFile == null )
+ if ( outputFile == null )
{
getLog().info( "Dependencies classpath:\n" + cpString );
}
@@ -231,11 +246,11 @@
{
if ( regenerateFile || !isUpdToDate( cpString ) )
{
- storeClasspathFile( cpString, cpFile );
+ storeClasspathFile( cpString, outputFile );
}
else
{
- this.getLog().info( "Skipped writing classpath file '" + cpFile + "'. No changes found." );
+ this.getLog().info( "Skipped writing classpath file '" + outputFile + "'. No changes found." );
}
}
if ( attach )
@@ -296,7 +311,7 @@
}
catch ( Exception ex )
{
- this.getLog().warn( "Error while reading old classpath file '" + cpFile + "' for up-to-date check: " + ex );
+ this.getLog().warn( "Error while reading old classpath file '" + outputFile + "' for up-to-date check: " + ex );
return false;
}
@@ -345,7 +360,7 @@
}
/**
- * Reads into a string the file specified by the mojo param 'cpFile'. Assumes, the instance variable 'cpFile' is not
+ * Reads into a string the file specified by the mojo param 'outputFile'. Assumes, the instance variable 'outputFile' is not
* null.
*
* @return the string contained in the classpathFile, if exists, or null ortherwise.
@@ -354,18 +369,18 @@
protected String readClasspathFile()
throws IOException
{
- if ( cpFile == null )
+ if ( outputFile == null )
{
throw new IllegalArgumentException(
- "The cpFile parameter cannot be null if the file is intended to be read." );
+ "The outputFile parameter cannot be null if the file is intended to be read." );
}
- if ( !cpFile.isFile() )
+ if ( !outputFile.isFile() )
{
return null;
}
StringBuffer sb = new StringBuffer();
- BufferedReader r = new BufferedReader( new FileReader( cpFile ) );
+ BufferedReader r = new BufferedReader( new FileReader( outputFile ) );
try
{
@@ -429,19 +444,19 @@
}
/**
- * @return the cpFile
+ * @return the outputFile
*/
public File getCpFile()
{
- return this.cpFile;
+ return this.outputFile;
}
/**
- * @param theCpFile the cpFile to set
+ * @param theCpFile the outputFile to set
*/
public void setCpFile( File theCpFile )
{
- this.cpFile = theCpFile;
+ this.outputFile = theCpFile;
}
/**
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=608334&r1=608333&r2=608334&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 Jan 2 19:56:56 2008
@@ -19,11 +19,8 @@
* under the License.
*/
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,6 +35,7 @@
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.project.MavenProject;
import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
@@ -126,16 +124,24 @@
/**
* 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}"
*/
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
+ */
+ private File outputFile;
+
+ /**
* 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-6
+ * @since 2.0-alpha-5
* @see <a href="http://jira.codehaus.org/browse/MNG-3236">MNG-3236</a>
*
* @parameter expression="${scope}"
@@ -197,6 +203,12 @@
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
+ if (output != null)
+ {
+ getLog().warn( "The parameter output is deprecated. Use outputFile instead." );
+ this.outputFile = output;
+ }
+
ArtifactFilter artifactFilter = createResolvingArtifactFilter();
try
@@ -209,15 +221,15 @@
String dependencyTreeString = serialiseDependencyTree( rootNode );
- if ( output != null )
+ if ( outputFile != null )
{
- write( dependencyTreeString, output );
+ DependencyUtil.write( dependencyTreeString, outputFile, getLog() );
- getLog().info( "Wrote dependency tree to: " + output );
+ getLog().info( "Wrote dependency tree to: " + outputFile );
}
else
{
- log( dependencyTreeString );
+ DependencyUtil.log( dependencyTreeString, getLog() );
}
}
catch ( DependencyTreeBuilderException exception )
@@ -385,63 +397,5 @@
return filters.isEmpty() ? null : new AndDependencyNodeFilter( filters );
}
- /**
- * Writes the specified string to the specified file.
- *
- * @param string
- * the string to write
- * @param file
- * the file to write to
- * @throws IOException
- * if an I/O error occurs
- */
- private void write( String string, File file ) throws IOException
- {
- file.getParentFile().mkdirs();
-
- FileWriter writer = null;
- try
- {
- writer = new FileWriter( file );
-
- 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();
- }
}
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=608334&r1=608333&r2=608334&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 Jan 2 19:56:56 2008
@@ -19,9 +19,12 @@
* 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.shared.artifact.filter.collection.ArtifactsFilter;
@@ -54,12 +57,9 @@
DependencyStatusSets results;
/**
- * 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.
+ * 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.
*/
public void execute()
throws MojoExecutionException
@@ -67,7 +67,22 @@
// get sets of dependencies
results = this.getDependencySets( false );
- results.logStatus( getLog(), outputAbsoluteArtifactFilename, outputScope );
+ String output = results.getOutput( outputAbsoluteArtifactFilename, outputScope );
+ try
+ {
+ if ( outputFile == null )
+ {
+ DependencyUtil.log( output, getLog() );
+ }
+ else
+ {
+ DependencyUtil.write( output, outputFile, getLog() );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException(e.getMessage(),e);
+ }
}
/**
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=608334&r1=608333&r2=608334&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 Jan 2 19:56:56 2008
@@ -19,12 +19,14 @@
* under the License.
*/
+import java.io.IOException;
import java.util.Iterator;
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.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.shared.artifact.filter.collection.ArtifactsFilter;
@@ -88,7 +90,22 @@
handler.setMarker();
}
- results.logStatus( getLog(), outputAbsoluteArtifactFilename, false );
+ String output = results.getOutput( outputAbsoluteArtifactFilename, false );
+ try
+ {
+ if ( outputFile == null )
+ {
+ DependencyUtil.log( output, getLog() );
+ }
+ else
+ {
+ DependencyUtil.write( output, outputFile, getLog() );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException(e.getMessage(),e);
+ }
}
protected ArtifactsFilter getMarkedArtifactFilter()
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java Wed Jan 2 19:56:56 2008
@@ -29,7 +29,6 @@
import java.util.TreeSet;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
@@ -137,18 +136,19 @@
}
}
- public void logStatus( Log log, boolean outputAbsoluteArtifactFilename )
+ public String getOutput(boolean outputAbsoluteArtifactFilename )
{
- logStatus( log, outputAbsoluteArtifactFilename, true );
+ return getOutput(outputAbsoluteArtifactFilename, true );
}
- public void logStatus( Log log, boolean outputAbsoluteArtifactFilename, boolean outputScope )
+ public String getOutput(boolean outputAbsoluteArtifactFilename, boolean outputScope )
{
- log.info( "" );
- log.info( "The following files have been resolved: " );
+ StringBuffer sb = new StringBuffer();
+ sb.append( "\n" );
+ sb.append( "The following files have been resolved:\n" );
if ( this.resolvedDependencies == null || this.resolvedDependencies.isEmpty() )
{
- log.info( " none" );
+ sb.append( " none\n" );
}
else
{
@@ -172,34 +172,35 @@
String id = outputScope ? artifact.toString() : artifact.getId();
- log.info( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) );
+ sb.append( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) +"\n");
}
}
if ( this.skippedDependencies != null && !this.skippedDependencies.isEmpty() )
{
- log.info( "" );
- log.info( "The following files where skipped: " );
+ sb.append( "\n" );
+ sb.append( "The following files where skipped:\n" );
SortedSet sortedSkippedDependencies = new TreeSet();
sortedSkippedDependencies.addAll( this.skippedDependencies );
for ( Iterator i = sortedSkippedDependencies.iterator(); i.hasNext(); )
{
- log.info( " " + ( (Artifact) i.next() ).getId() );
+ sb.append( " " + ( (Artifact) i.next() ).getId()+"\n" );
}
}
if ( this.unResolvedDependencies != null && !this.unResolvedDependencies.isEmpty() )
{
- log.info( "" );
- log.info( "The following files have NOT been resolved: " );
+ sb.append( "\n" );
+ sb.append( "The following files have NOT been resolved:\n" );
SortedSet sortedUnResolvedDependencies = new TreeSet();
sortedUnResolvedDependencies.addAll( this.unResolvedDependencies );
for ( Iterator i = sortedUnResolvedDependencies.iterator(); i.hasNext(); )
{
- log.info( " " + ( (Artifact) i.next() ).getId() );
+ sb.append( " " + ( (Artifact) i.next() ).getId()+"\n" );
}
}
- log.info( "" );
+ sb.append("\n");
+ return sb.toString();
}
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java Wed Jan 2 19:56:56 2008
@@ -19,9 +19,14 @@
* under the License.
*/
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.StringUtils;
/**
@@ -160,5 +165,65 @@
}
}
return sb.toString();
+ }
+
+ /**
+ * 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
+ */
+ public synchronized static void write( String string, File file, Log log ) throws IOException
+ {
+ file.getParentFile().mkdirs();
+
+ FileWriter writer = null;
+
+ try
+ {
+ writer = new FileWriter( file );
+
+ writer.write( string );
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException exception )
+ {
+ log.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
+ */
+ public synchronized static void log( String string, Log log ) throws IOException
+ {
+ BufferedReader reader = new BufferedReader( new StringReader( string ) );
+
+ String line;
+
+ while ( ( line = reader.readLine() ) != null )
+ {
+ log.info( line );
+ }
+
+ reader.close();
}
}
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?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- 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 Wed Jan 2 19:56:56 2008
@@ -109,7 +109,7 @@
assertNotNull( mojo );
assertNotNull( mojo.getProject() );
- MavenProject project = mojo.getProject();
+
ArtifactRepository local = new StubArtifactRepository(stubFactory.getWorkingDir().getPath());
mojo.setLocal( local );
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java?rev=608334&r1=608333&r2=608334&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java Wed Jan 2 19:56:56 2008
@@ -24,8 +24,6 @@
import java.util.Set;
import org.apache.maven.plugin.dependency.AbstractDependencyMojoTestCase;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.testing.SilentLog;
public class TestDependencyStatusSets
extends AbstractDependencyMojoTestCase
@@ -41,41 +39,21 @@
public void testDependencyStatusSettersGetters()
{
/*
- * DependencyStatusSets dss = new DependencyStatusSets();
- *
- * Set set = new HashSet();
- *
- * dss.setResolvedDependencies( set ); assertSame( set,
- * dss.getResolvedDependencies() );
- *
- * set = new HashSet();
- *
- * dss.setUnResolvedDependencies( set ); assertSame( set,
- * dss.getUnResolvedDependencies() );
- *
- * set = new HashSet();
- *
- * dss.setSkippedDependencies( set ); assertSame( set,
- * dss.getSkippedDependencies() );
- *
- * assertNotSame( dss.getResolvedDependencies(),
- * dss.getSkippedDependencies() ); assertNotSame(
- * dss.getResolvedDependencies(), dss.getUnResolvedDependencies() );
- * assertNotSame( dss.getSkippedDependencies(),
- * dss.getUnResolvedDependencies() );
+ * DependencyStatusSets dss = new DependencyStatusSets(); Set set = new HashSet(); dss.setResolvedDependencies(
+ * set ); assertSame( set, dss.getResolvedDependencies() ); set = new HashSet(); dss.setUnResolvedDependencies(
+ * set ); assertSame( set, dss.getUnResolvedDependencies() ); set = new HashSet(); dss.setSkippedDependencies(
+ * set ); assertSame( set, dss.getSkippedDependencies() ); assertNotSame( dss.getResolvedDependencies(),
+ * dss.getSkippedDependencies() ); assertNotSame( dss.getResolvedDependencies(), dss.getUnResolvedDependencies() );
+ * assertNotSame( dss.getSkippedDependencies(), dss.getUnResolvedDependencies() );
*/
}
public void testDependencyStatusConstructor()
{
/*
- * Set r = new HashSet(); Set u = new HashSet(); Set s = new HashSet();
- *
- * DependencyStatusSets dss = new DependencyStatusSets( r, u, s );
- *
- * assertSame( r, dss.getResolvedDependencies() ); assertSame( u,
- * dss.getUnResolvedDependencies() ); assertSame( s,
- * dss.getSkippedDependencies() );
+ * Set r = new HashSet(); Set u = new HashSet(); Set s = new HashSet(); DependencyStatusSets dss = new
+ * DependencyStatusSets( r, u, s ); assertSame( r, dss.getResolvedDependencies() ); assertSame( u,
+ * dss.getUnResolvedDependencies() ); assertSame( s, dss.getSkippedDependencies() );
*/
}
@@ -103,43 +81,42 @@
{
// TODO: implement logger to check correct output
// this test is just looking for unexpected exceptions.
- Log log = new SilentLog();
DependencyStatusSets dss = new DependencyStatusSets();
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( artifacts, null, null );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( null, artifacts, null );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( null, null, artifacts );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( artifacts, artifacts, null );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( null, artifacts, artifacts );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( artifacts, null, artifacts );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
+ dss.getOutput( false );
+ dss.getOutput( true );
dss = new DependencyStatusSets( artifacts, artifacts, artifacts );
- dss.logStatus( log, false );
- dss.logStatus( log, true );
- dss.logStatus( log, false, true );
- dss.logStatus( log, true, true );
- dss.logStatus( log, false, false );
- dss.logStatus( log, true, false );
+ dss.getOutput( false );
+ dss.getOutput( true );
+ dss.getOutput( false, true );
+ dss.getOutput( true, true );
+ dss.getOutput( false, false );
+ dss.getOutput( true, false );
}
}