Author: bentmann
Date: Sun Aug 16 16:28:59 2009
New Revision: 804712
URL: http://svn.apache.org/viewvc?rev=804712&view=rev
Log:
o Refactored code
Added:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
(with props)
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
(with props)
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/IntegrationTestMojo.java
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerReport.java
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/VerifyMojo.java
maven/plugins/trunk/maven-invoker-plugin/src/site/site.xml
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
Sun Aug 16 16:28:59 2009
@@ -580,21 +580,20 @@
getLog().warn( "Filtering of parent/child POMs is not supported
without cloning the projects" );
}
- List failures = runBuilds( projectsDir, buildJobs );
+ runBuilds( projectsDir, buildJobs );
- processResults( buildJobs, failures );
+ processResults( new InvokerSession( buildJobs ) );
}
/**
* Processes the results of invoking the build jobs.
- * @param buildJobs The set of build jobs which were invoked
- * @param failures The failed build jobs.
- * @throws MojoExecutionException If the mojo had an execution exception
as a result of invoking the build jobs.
+ *
+ * @param invokerSession The session with the build jobs, must not be
<code>null</code>.
* @throws MojoFailureException If the mojo had failed as a result of
invoking the build jobs.
* @since 1.4
*/
- protected abstract void processResults( BuildJob[] buildJobs, List
failures )
- throws MojoExecutionException, MojoFailureException;
+ abstract void processResults( InvokerSession invokerSession )
+ throws MojoFailureException;
/**
* Creates a new reader for the specified file, using the plugin's
{...@link #encoding} parameter.
@@ -881,14 +880,11 @@
*
* @param projectsDir The base directory of all projects, must not be
<code>null</code>.
* @param buildJobs The build jobs to run must not be <code>null</code>
nor contain <code>null</code> elements.
- * @return The list of build jobs that failed, can be empty but never
<code>null</code>.
* @throws org.apache.maven.plugin.MojoExecutionException If any build
could not be launched.
*/
- protected List runBuilds( File projectsDir, BuildJob[] buildJobs )
+ private void runBuilds( File projectsDir, BuildJob[] buildJobs )
throws MojoExecutionException
{
- List failures = new ArrayList();
-
if ( !localRepositoryPath.exists() )
{
localRepositoryPath.mkdirs();
@@ -914,14 +910,7 @@
for ( int i = 0; i < buildJobs.length; i++ )
{
BuildJob project = buildJobs[i];
- try
- {
- runBuild( projectsDir, project, interpolatedSettingsFile );
- }
- catch ( BuildFailureException e )
- {
- failures.add( project );
- }
+ runBuild( projectsDir, project, interpolatedSettingsFile );
}
}
finally
@@ -931,8 +920,6 @@
interpolatedSettingsFile.delete();
}
}
-
- return failures;
}
/**
@@ -943,10 +930,9 @@
* @param settingsFile The (already interpolated) user settings file for
the build, may be <code>null</code> to use
* the current user settings.
* @throws org.apache.maven.plugin.MojoExecutionException If the project
could not be launched.
- * @throws org.apache.maven.plugin.invoker.BuildFailureException If either
a hook script or the build itself failed.
*/
private void runBuild( File projectsDir, BuildJob buildJob, File
settingsFile )
- throws MojoExecutionException, BuildFailureException
+ throws MojoExecutionException
{
File pomFile = new File( projectsDir, buildJob.getProject() );
File basedir;
@@ -1020,7 +1006,6 @@
getLog().info( "..FAILED " + formatTime( buildJob.getTime() )
);
getLog().info( " " + e.getMessage() );
}
- throw e;
}
finally
{
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/IntegrationTestMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/IntegrationTestMojo.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/IntegrationTestMojo.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/IntegrationTestMojo.java
Sun Aug 16 16:28:59 2009
@@ -19,11 +19,7 @@
* under the License.
*/
-import java.util.List;
-
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.invoker.model.BuildJob;
/**
* Searches for integration test Maven projects, and executes each, collecting
a log in the project directory, will
@@ -41,17 +37,8 @@
extends AbstractInvokerMojo
{
- /**
- * Processes the results of invoking the build jobs.
- *
- * @param buildJobs The set of build jobs which were invoked
- * @param failures The failed build jobs.
- * @throws MojoExecutionException If the mojo had an execution exception
as a result of invoking the build jobs.
- * @throws MojoFailureException If the mojo had failed as a result of
invoking the build jobs.
- * @since 1.4
- */
- protected void processResults( BuildJob[] buildJobs, List failures )
- throws MojoExecutionException, MojoFailureException
+ void processResults( InvokerSession invokerSession )
+ throws MojoFailureException
{
// do nothing
}
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
Sun Aug 16 16:28:59 2009
@@ -19,12 +19,7 @@
* under the License.
*/
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.invoker.model.BuildJob;
/**
* Searches for integration test Maven projects, and executes each, collecting
a log in the project directory, and
@@ -52,70 +47,15 @@
*/
private boolean ignoreFailures;
- /**
- * Processes the results of invoking the build jobs.
- *
- * @param buildJobs The set of build jobs which were invoked
- * @param failures The failed build jobs.
- * @throws MojoExecutionException If the mojo had an execution exception
as a result of invoking the build jobs.
- * @throws MojoFailureException If the mojo had failed as a result of
invoking the build jobs.
- * @since 1.4
- */
- protected void processResults( BuildJob[] buildJobs, List failures )
- throws MojoExecutionException, MojoFailureException
+ void processResults( InvokerSession invokerSession )
+ throws MojoFailureException
{
-
if ( !suppressSummaries )
{
- getLog().info( "---------------------------------------" );
- getLog().info( "Execution Summary:" );
- getLog().info( " Builds Passing: " + ( buildJobs.length -
failures.size() ) );
- getLog().info( " Builds Failing: " + failures.size() );
- getLog().info( "---------------------------------------" );
-
- if ( !failures.isEmpty() )
- {
- String heading = "The following builds failed:";
- if ( ignoreFailures )
- {
- getLog().warn( heading );
- }
- else
- {
- getLog().error( heading );
- }
-
- for ( final Iterator it = failures.iterator(); it.hasNext(); )
- {
- BuildJob buildJob = (BuildJob) it.next();
- String item = "* " + buildJob.getProject();
- if ( ignoreFailures )
- {
- getLog().warn( item );
- }
- else
- {
- getLog().error( item );
- }
- }
-
- getLog().info( "---------------------------------------" );
- }
+ invokerSession.logSummary( getLog(), ignoreFailures );
}
- if ( !failures.isEmpty() )
- {
- String message = failures.size() + " build" + ( failures.size() ==
1 ? "" : "s" ) + " failed.";
-
- if ( ignoreFailures )
- {
- getLog().warn( "Ignoring that " + message );
- }
- else
- {
- throw new MojoFailureException( this, message, message );
- }
- }
+ invokerSession.handleFailures( getLog(), ignoreFailures );
}
}
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerReport.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerReport.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerReport.java
Sun Aug 16 16:28:59 2009
@@ -135,7 +135,7 @@
// ----------------------------------
// build buildJob beans
// ----------------------------------
- File[] reportFiles = getReportFiles();
+ File[] reportFiles = ReportUtils.getReportFiles( reportsDirectory );
if ( reportFiles.length <= 0 )
{
getLog().info( "no invoker report files found, skip report
generation" );
@@ -335,22 +335,7 @@
public boolean canGenerateReport()
{
- return getReportFiles().length > 0;
- }
-
- /**
- * Gets the paths to the available invoker reports to generate the site
output from.
- *
- * @return The paths to the invoker reports, can be empty but never
<code>null</code>.
- */
- private File[] getReportFiles()
- {
- File[] reportFiles = ( reportsDirectory != null ) ?
reportsDirectory.listFiles() : null;
- if ( reportFiles == null )
- {
- reportFiles = new File[0];
- }
- return reportFiles;
+ return ReportUtils.getReportFiles( reportsDirectory ).length > 0;
}
private String getText( Locale locale, String key )
Added:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java?rev=804712&view=auto
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
(added)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
Sun Aug 16 16:28:59 2009
@@ -0,0 +1,248 @@
+package org.apache.maven.plugin.invoker;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.invoker.model.BuildJob;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * Tracks a set of build jobs and their results.
+ *
+ * @author Benjamin Bentmann
+ */
+class InvokerSession
+{
+
+ private List buildJobs;
+
+ private List failedJobs;
+
+ private List successfulJobs;
+
+ private List skippedJobs;
+
+ /**
+ * Creates a new empty session.
+ */
+ public InvokerSession()
+ {
+ buildJobs = new ArrayList();
+ }
+
+ /**
+ * Creates a session that initially contains the specified build jobs.
+ *
+ * @param buildJobs The build jobs to set, must not be <code>null</code>.
+ */
+ public InvokerSession( BuildJob[] buildJobs )
+ {
+ this.buildJobs = new ArrayList( Arrays.asList( buildJobs ) );
+ }
+
+ /**
+ * Adds the specified build job to this session.
+ *
+ * @param buildJob The build job to add, must not be <code>null</code>.
+ */
+ public void addJob( BuildJob buildJob )
+ {
+ buildJobs.add( buildJob );
+
+ resetStats();
+ }
+
+ /**
+ * Sets the build jobs of this session.
+ *
+ * @param buildJobs The build jobs to set, must not be <code>null</code>.
+ */
+ public void setJobs( List buildJobs )
+ {
+ this.buildJobs = new ArrayList( buildJobs );
+
+ resetStats();
+ }
+
+ /**
+ * Gets the build jobs in this session.
+ *
+ * @return The build jobs in this session, can be empty but never
<code>null</code>.
+ */
+ public List getJobs()
+ {
+ return buildJobs;
+ }
+
+ /**
+ * Gets the successful build jobs in this session.
+ *
+ * @return The successful build jobs in this session, can be empty but
never <code>null</code>.
+ */
+ public List getSuccessfulJobs()
+ {
+ updateStats();
+
+ return successfulJobs;
+ }
+
+ /**
+ * Gets the failed build jobs in this session.
+ *
+ * @return The failed build jobs in this session, can be empty but never
<code>null</code>.
+ */
+ public List getFailedJobs()
+ {
+ updateStats();
+
+ return failedJobs;
+ }
+
+ /**
+ * Gets the skipped build jobs in this session.
+ *
+ * @return The skipped build jobs in this session, can be empty but never
<code>null</code>.
+ */
+ public List getSkippedJobs()
+ {
+ updateStats();
+
+ return skippedJobs;
+ }
+
+ private void resetStats()
+ {
+ successfulJobs = null;
+ failedJobs = null;
+ skippedJobs = null;
+ }
+
+ private void updateStats()
+ {
+ if ( successfulJobs != null && skippedJobs != null && failedJobs !=
null )
+ {
+ return;
+ }
+
+ successfulJobs = new ArrayList();
+ failedJobs = new ArrayList();
+ skippedJobs = new ArrayList();
+
+ for ( Iterator iterator = buildJobs.iterator(); iterator.hasNext(); )
+ {
+ BuildJob buildJob = (BuildJob) iterator.next();
+
+ if ( BuildJob.Result.SUCCESS.equals( buildJob.getResult() ) )
+ {
+ successfulJobs.add( buildJob );
+ }
+ else if ( BuildJob.Result.SKIPPED.equals( buildJob.getResult() ) )
+ {
+ skippedJobs.add( buildJob );
+ }
+ else if ( buildJob.getResult() != null )
+ {
+ failedJobs.add( buildJob );
+ }
+ }
+ }
+
+ /**
+ * Prints a summary of this session to the specified logger.
+ *
+ * @param logger The mojo logger to output messages to, must not be
<code>null</code>.
+ * @param ignoreFailures A flag whether failures should be ignored or
whether a build failure should be signaled.
+ */
+ public void logSummary( Log logger, boolean ignoreFailures )
+ {
+ updateStats();
+
+ String separator = "---------------------------------------";
+
+ logger.info( separator );
+ logger.info( "Execution Summary:" );
+ logger.info( " Builds Passing: " + successfulJobs.size() );
+ logger.info( " Builds Failing: " + failedJobs.size() );
+ logger.info( separator );
+
+ if ( !failedJobs.isEmpty() )
+ {
+ String heading = "The following builds failed:";
+ if ( ignoreFailures )
+ {
+ logger.warn( heading );
+ }
+ else
+ {
+ logger.error( heading );
+ }
+
+ for ( Iterator it = failedJobs.iterator(); it.hasNext(); )
+ {
+ BuildJob buildJob = (BuildJob) it.next();
+
+ String item = "* " + buildJob.getProject();
+ if ( ignoreFailures )
+ {
+ logger.warn( item );
+ }
+ else
+ {
+ logger.error( item );
+ }
+ }
+
+ logger.info( separator );
+ }
+ }
+
+ /**
+ * Handles the build failures in this session.
+ *
+ * @param logger The mojo logger to output messages to, must not be
<code>null</code>.
+ * @param ignoreFailures A flag whether failures should be ignored or
whether a build failure should be signaled.
+ * @throws MojoFailureException If failures are present and not ignored.
+ */
+ public void handleFailures( Log logger, boolean ignoreFailures )
+ throws MojoFailureException
+ {
+ updateStats();
+
+ if ( !failedJobs.isEmpty() )
+ {
+ String message = failedJobs.size() + " build" + (
failedJobs.size() == 1 ? "" : "s" ) + " failed.";
+
+ if ( ignoreFailures )
+ {
+ logger.warn( "Ignoring that " + message );
+ }
+ else
+ {
+ throw new MojoFailureException( this, message, message );
+ }
+ }
+ }
+
+}
Propchange:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerSession.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java?rev=804712&view=auto
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
(added)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
Sun Aug 16 16:28:59 2009
@@ -0,0 +1,50 @@
+package org.apache.maven.plugin.invoker;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+/**
+ * Provides utility methods for invoker report processing.
+ *
+ * @author Benjamin Bentmann
+ */
+class ReportUtils
+{
+
+ /**
+ * Gets the paths to the invoker reports available in the specified
directory.
+ *
+ *...@param reportsDirectory The base directory where the invoker reports
are located in, may be <code>null</code>.
+ * @return The paths to the invoker reports, can be empty but never
<code>null</code>.
+ */
+ public static File[] getReportFiles( File reportsDirectory )
+ {
+ File[] reportFiles = ( reportsDirectory != null ) ?
reportsDirectory.listFiles() : null;
+
+ if ( reportFiles == null )
+ {
+ reportFiles = new File[0];
+ }
+
+ return reportFiles;
+ }
+
+}
Propchange:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/ReportUtils.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/VerifyMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/VerifyMojo.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/VerifyMojo.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/VerifyMojo.java
Sun Aug 16 16:28:59 2009
@@ -23,15 +23,11 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.invoker.model.io.xpp3.BuildJobXpp3Reader;
-import org.apache.maven.plugin.invoker.model.BuildJob;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
/**
* Checks the results of maven-invoker-plugin based integration tests and
fails the build if any tests failed.
@@ -43,6 +39,7 @@
*/
public class VerifyMojo extends AbstractMojo
{
+
/**
* Flag used to suppress certain invocations. This is useful in tailoring
the build using profiles.
*
@@ -52,7 +49,7 @@
private boolean skipInvocation;
/**
- * Base directory where all build reports are written to.
+ * Base directory where all build reports are read from.
*
* @parameter expression="${invoker.reportsDirectory}"
default-value="${project.build.directory}/invoker-reports"
* @since 1.4
@@ -92,21 +89,22 @@
+ " If this is incorrect, ensure the skipInvocation parameter
is not set to true." );
return;
}
- File[] reportFiles = getReportFiles();
+
+ File[] reportFiles = ReportUtils.getReportFiles( reportsDirectory );
if ( reportFiles.length <= 0 )
{
getLog().info( "No invoker report files found, nothing to check."
);
return;
}
- List buildJobs = new ArrayList( reportFiles.length );
+ InvokerSession invokerSession = new InvokerSession();
for ( int i = 0, size = reportFiles.length; i < size; i++ )
{
File reportFile = reportFiles[i];
try
{
BuildJobXpp3Reader reader = new BuildJobXpp3Reader();
- buildJobs.add( reader.read( ReaderFactory.newXmlReader(
reportFile ) ) );
+ invokerSession.addJob( reader.read(
ReaderFactory.newXmlReader( reportFile ) ) );
}
catch ( XmlPullParserException e )
{
@@ -118,89 +116,12 @@
}
}
- List failures = new ArrayList();
- List successes = new ArrayList();
-
- for ( Iterator iterator = buildJobs.iterator(); iterator.hasNext();)
- {
- BuildJob buildJob = (BuildJob) iterator.next();
- if ( BuildJob.Result.SUCCESS.equals( buildJob.getResult() ) )
- {
- successes.add( buildJob );
- }
- else if ( !BuildJob.Result.SKIPPED.equals( buildJob.getResult() ) )
- {
- failures.add( buildJob );
- }
- }
-
if ( !suppressSummaries )
{
- getLog().info( "---------------------------------------" );
- getLog().info( "Execution Summary:" );
- getLog().info( " Builds Passing: " + ( buildJobs.size() -
failures.size() ) );
- getLog().info( " Builds Failing: " + failures.size() );
- getLog().info( "---------------------------------------" );
-
- if ( !failures.isEmpty() )
- {
- String heading = "The following builds failed:";
- if ( ignoreFailures )
- {
- getLog().warn( heading );
- }
- else
- {
- getLog().error( heading );
- }
-
- for ( final Iterator it = failures.iterator(); it.hasNext(); )
- {
- BuildJob buildJob = (BuildJob) it.next();
- String item = "* " + buildJob.getProject();
- if ( ignoreFailures )
- {
- getLog().warn( item );
- }
- else
- {
- getLog().error( item );
- }
- }
-
- getLog().info( "---------------------------------------" );
- }
- }
-
- if ( !failures.isEmpty() )
- {
- String message = failures.size() + " build" + ( failures.size() ==
1 ? "" : "s" ) + " failed.";
-
- if ( ignoreFailures )
- {
- getLog().warn( "Ignoring that " + message );
- }
- else
- {
- throw new MojoFailureException( this, message, message );
- }
+ invokerSession.logSummary( getLog(), ignoreFailures );
}
- }
-
- /**
- * Gets the paths to the available invoker reports to generate the site
output from.
- *
- * @return The paths to the invoker reports, can be empty but never
<code>null</code>.
- */
- private File[] getReportFiles()
- {
- File[] reportFiles = ( reportsDirectory != null ) ?
reportsDirectory.listFiles() : null;
- if ( reportFiles == null )
- {
- reportFiles = new File[0];
- }
- return reportFiles;
+ invokerSession.handleFailures( getLog(), ignoreFailures );
}
}
Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/site.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/site.xml?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/site.xml Sun Aug 16
16:28:59 2009
@@ -22,7 +22,7 @@
<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0
http://maven.apache.org/xsd/decoration-1.0.0.xsd"
- name="Maven Invoker plugin">
+ name="Maven Invoker Plugin">
<body>
<menu name="Overview">
<item name="Introduction" href="index.html"/>
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java?rev=804712&r1=804711&r2=804712&view=diff
==============================================================================
---
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
(original)
+++
maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
Sun Aug 16 16:28:59 2009
@@ -104,10 +104,10 @@
public void testAlreadyCloned()
throws Exception
{
- assertFalse( InvokerMojo.alreadyCloned( "dir", Collections.EMPTY_LIST
) );
- assertTrue( InvokerMojo.alreadyCloned( "dir",
Collections.singletonList( "dir" ) ) );
- assertTrue( InvokerMojo.alreadyCloned( "dir" + File.separator + "sub",
Collections.singletonList( "dir" ) ) );
- assertFalse( InvokerMojo.alreadyCloned( "dirs",
Collections.singletonList( "dir" ) ) );
+ assertFalse( AbstractInvokerMojo.alreadyCloned( "dir",
Collections.EMPTY_LIST ) );
+ assertTrue( AbstractInvokerMojo.alreadyCloned( "dir",
Collections.singletonList( "dir" ) ) );
+ assertTrue( AbstractInvokerMojo.alreadyCloned( "dir" + File.separator
+ "sub", Collections.singletonList( "dir" ) ) );
+ assertFalse( AbstractInvokerMojo.alreadyCloned( "dirs",
Collections.singletonList( "dir" ) ) );
}
}