maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steph...@apache.org
Subject svn commit: r945183 - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-plugin/src/main/java/org/apache/maven/plugin/sure...
Date Mon, 17 May 2010 14:36:27 GMT
Author: stephenc
Date: Mon May 17 14:36:27 2010
New Revision: 945183

URL: http://svn.apache.org/viewvc?rev=945183&view=rev
Log:
[SUREFIRE-592] More refactoring and hopefully fix build on sonatype grid

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java   (with props)
Modified:
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=945183&r1=945182&r2=945183&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java Mon May 17 14:36:27 2010
@@ -25,34 +25,20 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
 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.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
+import org.apache.maven.plugin.surefire.SurefireExecutionParameters;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooter;
@@ -60,14 +46,6 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
 import org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
-import org.apache.maven.surefire.report.BriefConsoleReporter;
-import org.apache.maven.surefire.report.BriefFileReporter;
-import org.apache.maven.surefire.report.ConsoleReporter;
-import org.apache.maven.surefire.report.DetailedConsoleReporter;
-import org.apache.maven.surefire.report.FileReporter;
-import org.apache.maven.surefire.report.ForkingConsoleReporter;
-import org.apache.maven.surefire.report.XMLReporter;
-import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
@@ -84,6 +62,7 @@ import org.codehaus.plexus.util.StringUt
  */
 public class IntegrationTestMojo
     extends AbstractSurefireMojo
+    implements SurefireExecutionParameters
 {
 
     /**
@@ -647,7 +626,7 @@ public class IntegrationTestMojo
             try
             {
                 String encoding;
-                if ( StringUtils.isEmpty( this.getEncoding() ) )
+                if ( StringUtils.isEmpty( this.encoding ) )
                 {
                     getLog().warn(
                         "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
@@ -656,7 +635,7 @@ public class IntegrationTestMojo
                 }
                 else
                 {
-                    encoding = this.getEncoding();
+                    encoding = this.encoding;
                 }
 
                 FileOutputStream fileOutputStream = new FileOutputStream( getSummaryFile() );
@@ -675,9 +654,44 @@ public class IntegrationTestMojo
         }
     }
 
-    protected boolean isTestsSkipped()
+    protected boolean verifyParameters()
+        throws MojoFailureException
     {
-        return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
+        if ( isSkip() || isSkipTests() || isSkipITs() || isSkipExec() )
+        {
+            getLog().info( "Tests are skipped." );
+            return false;
+        }
+
+        if ( !getTestClassesDirectory().exists() )
+        {
+            if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() )
+            {
+                throw new MojoFailureException( "No tests to run!" );
+            }
+            getLog().info( "No tests to run." );
+            return false;
+        }
+
+        if ( !getWorkingDirectory().exists() )
+        {
+            if ( !getWorkingDirectory().mkdirs() )
+            {
+                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() );
+            }
+        }
+
+        if ( !getWorkingDirectory().isDirectory() )
+        {
+            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() + " exists and is not a directory" );
+        }
+
+        if ( getUseSystemClassLoader() != null && ForkConfiguration.FORK_NEVER.equals( getForkMode() ) )
+        {
+            getLog().warn( "useSystemClassloader setting has no effect when not forking" );
+        }
+
+        return true;
     }
 
     protected String getPluginName()
@@ -1260,16 +1274,6 @@ public class IntegrationTestMojo
         this.objectFactory = objectFactory;
     }
 
-    public String getEncoding()
-    {
-        return encoding;
-    }
-
-    public void setEncoding( String encoding )
-    {
-        this.encoding = encoding;
-    }
-
     public ToolchainManager getToolchainManager()
     {
         return toolchainManager;

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java?rev=945183&r1=945182&r2=945183&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java Mon May 17 14:36:27 2010
@@ -34,11 +34,13 @@ import org.apache.maven.artifact.metadat
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
+import org.apache.maven.plugin.surefire.SurefireHelper;
+import org.apache.maven.plugin.surefire.SurefireReportParameters;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.surefire.booter.SurefireBooter;
 import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
 import org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Reader;
 import org.apache.maven.toolchain.ToolchainManager;
@@ -56,7 +58,8 @@ import org.codehaus.plexus.util.xml.pull
  * @phase verify
  */
 public class VerifyMojo
-    extends AbstractSurefireMojo
+    extends AbstractMojo
+    implements SurefireReportParameters
 {
 
     /**
@@ -162,7 +165,7 @@ public class VerifyMojo
             try
             {
                 String encoding;
-                if ( StringUtils.isEmpty( this.getEncoding() ) )
+                if ( StringUtils.isEmpty( this.encoding ) )
                 {
                     getLog().warn(
                         "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
@@ -171,10 +174,10 @@ public class VerifyMojo
                 }
                 else
                 {
-                    encoding = this.getEncoding();
+                    encoding = this.encoding;
                 }
 
-                FileInputStream fos = new FileInputStream( getSummaryFile() );
+                FileInputStream fos = new FileInputStream( summaryFile );
                 BufferedInputStream bos = new BufferedInputStream( fos );
                 Reader w = new InputStreamReader( bos, encoding );
                 FailsafeSummaryXpp3Reader reader = new FailsafeSummaryXpp3Reader();
@@ -193,45 +196,30 @@ public class VerifyMojo
                 throw new MojoExecutionException( e.getMessage(), e );
             }
 
-            if ( result == 0 )
-            {
-                return;
-            }
-
-            String msg;
-
-            if ( result == SurefireBooter.NO_TESTS_EXIT_CODE )
-            {
-                if ( ( getFailIfNoTests() == null ) || !getFailIfNoTests().booleanValue() )
-                {
-                    return;
-                }
-                // TODO: i18n
-                throw new MojoFailureException(
-                    "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
-            }
-            else
-            {
-                // TODO: i18n
-                msg = "There are test failures.\n\nPlease refer to " + getReportsDirectory()
-                    + " for the individual test results.";
+            SurefireHelper.reportExecution( this, result, getLog() );
+        }
+    }
 
-            }
+    protected boolean verifyParameters()
+        throws MojoFailureException
+    {
+        if ( isSkip() || isSkipTests() || isSkipITs() || isSkipExec() )
+        {
+            getLog().info( "Tests are skipped." );
+            return false;
+        }
 
-            if ( isTestFailureIgnore() )
-            {
-                getLog().error( msg );
-            }
-            else
+        if ( !getTestClassesDirectory().exists() )
+        {
+            if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() )
             {
-                throw new MojoFailureException( msg );
+                throw new MojoFailureException( "No tests to run!" );
             }
+            getLog().info( "No tests to run." );
+            return false;
         }
-    }
 
-    protected boolean isTestsSkipped()
-    {
-        return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
+        return true;
     }
 
     protected String getPluginName()
@@ -324,16 +312,6 @@ public class VerifyMojo
         this.reportsDirectory = reportsDirectory;
     }
 
-    public File getSummaryFile()
-    {
-        return summaryFile;
-    }
-
-    public void setSummaryFile( File summaryFile )
-    {
-        this.summaryFile = summaryFile;
-    }
-
     public Boolean getFailIfNoTests()
     {
         return failIfNoTests;
@@ -344,505 +322,4 @@ public class VerifyMojo
         this.failIfNoTests = failIfNoTests;
     }
 
-    public String getEncoding()
-    {
-        return encoding;
-    }
-
-    public void setEncoding( String encoding )
-    {
-        this.encoding = encoding;
-    }
-
-    // the following will be refactored out once the common code is all in one place
-
-    public File getClassesDirectory()
-    {
-        return null; // ignore
-    }
-
-    public void setClassesDirectory( File classesDirectory )
-    {
-        // ignore
-    }
-
-    public MavenProject getProject()
-    {
-        return null; // ignore
-    }
-
-    public void setProject( MavenProject project )
-    {
-        // ignore
-    }
-
-    public String getIgnoreClasspathElements()
-    {
-        return null; // ignore
-    }
-
-    public void setIgnoreClasspathElements( String ignoreClasspathElements )
-    {
-        // ignore
-    }
-
-    public List getAdditionalClasspathElements()
-    {
-        return null; // ignore
-    }
-
-    public void setAdditionalClasspathElements( List additionalClasspathElements )
-    {
-        // ignore
-    }
-
-    public File getTestSourceDirectory()
-    {
-        return null; // ignore
-    }
-
-    public void setTestSourceDirectory( File testSourceDirectory )
-    {
-        // ignore
-    }
-
-    public String getTest()
-    {
-        return null; // ignore
-    }
-
-    public void setTest( String test )
-    {
-        // ignore
-    }
-
-    public List getIncludes()
-    {
-        return null; // ignore
-    }
-
-    public void setIncludes( List includes )
-    {
-        // ignore
-    }
-
-    public List getExcludes()
-    {
-        return null; // ignore
-    }
-
-    public void setExcludes( List excludes )
-    {
-        // ignore
-    }
-
-    public ArtifactRepository getLocalRepository()
-    {
-        return null; // ignore
-    }
-
-    public void setLocalRepository( ArtifactRepository localRepository )
-    {
-        // ignore
-    }
-
-    public Properties getSystemProperties()
-    {
-        return null; // ignore
-    }
-
-    public void setSystemProperties( Properties systemProperties )
-    {
-        // ignore
-    }
-
-    public Map getSystemPropertyVariables()
-    {
-        return null; // ignore
-    }
-
-    public void setSystemPropertyVariables( Map systemPropertyVariables )
-    {
-        // ignore
-    }
-
-    public Properties getProperties()
-    {
-        return null; // ignore
-    }
-
-    public void setProperties( Properties properties )
-    {
-        // ignore
-    }
-
-    public Map getPluginArtifactMap()
-    {
-        return null; // ignore
-    }
-
-    public void setPluginArtifactMap( Map pluginArtifactMap )
-    {
-        // ignore
-    }
-
-    public Map getProjectArtifactMap()
-    {
-        return null; // ignore
-    }
-
-    public void setProjectArtifactMap( Map projectArtifactMap )
-    {
-        // ignore
-    }
-
-    public boolean isPrintSummary()
-    {
-        return false; // ignore
-    }
-
-    public void setPrintSummary( boolean printSummary )
-    {
-        // ignore
-    }
-
-    public String getReportFormat()
-    {
-        return null; // ignore
-    }
-
-    public void setReportFormat( String reportFormat )
-    {
-        // ignore
-    }
-
-    public boolean isUseFile()
-    {
-        return false; // ignore  
-    }
-
-    public void setUseFile( boolean useFile )
-    {
-        // ignore
-    }
-
-    public boolean isRedirectTestOutputToFile()
-    {
-        return false; // ignore
-    }
-
-    public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
-    {
-        // ignore
-    }
-
-    public String getForkMode()
-    {
-        return null; // ignore
-    }
-
-    public void setForkMode( String forkMode )
-    {
-        // ignore
-    }
-
-    public String getJvm()
-    {
-        return null; // ignore
-    }
-
-    public void setJvm( String jvm )
-    {
-        // ignore
-    }
-
-    public String getArgLine()
-    {
-        return null; // ignore
-    }
-
-    public void setArgLine( String argLine )
-    {
-        // ignore
-    }
-
-    public String getDebugForkedProcess()
-    {
-        return null; // ignore
-    }
-
-    public void setDebugForkedProcess( String debugForkedProcess )
-    {
-        // ignore
-    }
-
-    public int getForkedProcessTimeoutInSeconds()
-    {
-        return 0;  // ignore
-    }
-
-    public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
-    {
-        // ignore
-    }
-
-    public Map getEnvironmentVariables()
-    {
-        return null;  // ignore
-    }
-
-    public void setEnvironmentVariables( Map environmentVariables )
-    {
-        // ignore
-    }
-
-    public File getWorkingDirectory()
-    {
-        return null;  // ignore
-    }
-
-    public void setWorkingDirectory( File workingDirectory )
-    {
-        // ignore
-    }
-
-    public boolean isChildDelegation()
-    {
-        return false;  // ignore
-    }
-
-    public void setChildDelegation( boolean childDelegation )
-    {
-        // ignore
-    }
-
-    public String getGroups()
-    {
-        return null;  // ignore
-    }
-
-    public void setGroups( String groups )
-    {
-        // ignore
-    }
-
-    public String getExcludedGroups()
-    {
-        return null;  // ignore
-    }
-
-    public void setExcludedGroups( String excludedGroups )
-    {
-        // ignore
-    }
-
-    public File[] getSuiteXmlFiles()
-    {
-        return new File[0];  // ignore
-    }
-
-    public void setSuiteXmlFiles( File[] suiteXmlFiles )
-    {
-        // ignore
-    }
-
-    public String getJunitArtifactName()
-    {
-        return null;  // ignore
-    }
-
-    public void setJunitArtifactName( String junitArtifactName )
-    {
-        // ignore
-    }
-
-    public String getTestNGArtifactName()
-    {
-        return null;  // ignore
-    }
-
-    public void setTestNGArtifactName( String testNGArtifactName )
-    {
-        // ignore
-    }
-
-    public int getThreadCount()
-    {
-        return 0;  // ignore
-    }
-
-    public void setThreadCount( int threadCount )
-    {
-        // ignore
-    }
-
-    public String getPerCoreThreadCount()
-    {
-        return null;  // ignore
-    }
-
-    public void setPerCoreThreadCount( String perCoreThreadCount )
-    {
-        // ignore
-    }
-
-    public String getUseUnlimitedThreads()
-    {
-        return null;  // ignore
-    }
-
-    public void setUseUnlimitedThreads( String useUnlimitedThreads )
-    {
-        // ignore
-    }
-
-    public String getParallel()
-    {
-        return null;  // ignore
-    }
-
-    public void setParallel( String parallel )
-    {
-        // ignore
-    }
-
-    public boolean isTrimStackTrace()
-    {
-        return false;  // ignore
-    }
-
-    public void setTrimStackTrace( boolean trimStackTrace )
-    {
-        // ignore
-    }
-
-    public ArtifactResolver getArtifactResolver()
-    {
-        return null;  // ignore
-    }
-
-    public void setArtifactResolver( ArtifactResolver artifactResolver )
-    {
-        // ignore
-    }
-
-    public ArtifactFactory getArtifactFactory()
-    {
-        return null;  // ignore
-    }
-
-    public void setArtifactFactory( ArtifactFactory artifactFactory )
-    {
-        // ignore
-    }
-
-    public List getRemoteRepositories()
-    {
-        return null;  // ignore
-    }
-
-    public void setRemoteRepositories( List remoteRepositories )
-    {
-        // ignore
-    }
-
-    public ArtifactMetadataSource getMetadataSource()
-    {
-        return null;  // ignore
-    }
-
-    public void setMetadataSource( ArtifactMetadataSource metadataSource )
-    {
-        // ignore
-    }
-
-    public Properties getOriginalSystemProperties()
-    {
-        return null;  // ignore
-    }
-
-    public void setOriginalSystemProperties( Properties originalSystemProperties )
-    {
-        // ignore
-    }
-
-    public Properties getInternalSystemProperties()
-    {
-        return null;  // ignore
-    }
-
-    public void setInternalSystemProperties( Properties internalSystemProperties )
-    {
-        // ignore
-    }
-
-    public boolean isDisableXmlReport()
-    {
-        return false;  // ignore
-    }
-
-    public void setDisableXmlReport( boolean disableXmlReport )
-    {
-        // ignore
-    }
-
-    public Boolean getUseSystemClassLoader()
-    {
-        return null;  // ignore
-    }
-
-    public void setUseSystemClassLoader( Boolean useSystemClassLoader )
-    {
-        // ignore
-    }
-
-    public boolean isUseManifestOnlyJar()
-    {
-        return false;  // ignore
-    }
-
-    public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
-    {
-        // ignore
-    }
-
-    public boolean isEnableAssertions()
-    {
-        return false;  // ignore
-    }
-
-    public void setEnableAssertions( boolean enableAssertions )
-    {
-        // ignore
-    }
-
-    public MavenSession getSession()
-    {
-        return null;  // ignore
-    }
-
-    public void setSession( MavenSession session )
-    {
-        // ignore
-    }
-
-    public String getObjectFactory()
-    {
-        return null;  // ignore
-    }
-
-    public void setObjectFactory( String objectFactory )
-    {
-        // ignore
-    }
-
-    public ToolchainManager getToolchainManager()
-    {
-        return null;  // ignore
-    }
-
-    public void setToolchainManager( ToolchainManager toolchainManager )
-    {
-        // ignore
-    }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=945183&r1=945182&r2=945183&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Mon May 17 14:36:27 2010
@@ -2,24 +2,19 @@ package org.apache.maven.plugin.surefire
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
-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.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
 import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.execution.MavenSession;
 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.plugin.logging.Log;
 import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooter;
 import org.apache.maven.surefire.report.BriefConsoleReporter;
@@ -30,7 +25,6 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
 import org.apache.maven.surefire.report.XMLReporter;
 import org.apache.maven.toolchain.Toolchain;
-import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -49,7 +43,7 @@ import java.util.Properties;
  * @version $Id: SurefirePlugin.java 945065 2010-05-17 10:26:22Z stephenc $
  */
 public abstract class AbstractSurefireMojo
-    extends AbstractMojo
+    extends AbstractMojo implements SurefireExecutionParameters
 {
 
     private static final String BRIEF_REPORT_FORMAT = "brief";
@@ -58,293 +52,14 @@ public abstract class AbstractSurefireMo
 
     // common field getters/setters
 
-    public abstract boolean isSkipTests();
-
-    public abstract void setSkipTests( boolean skipTests );
-
-    public abstract boolean isSkipITs();
-
-    public abstract void setSkipITs( boolean skipITs );
-
-    public abstract boolean isSkipExec();
-
-    public abstract void setSkipExec( boolean skipExec );
-
-    public abstract boolean isSkip();
-
-    public abstract void setSkip( boolean skip );
-
-    public abstract boolean isTestFailureIgnore();
-
-    public abstract void setTestFailureIgnore( boolean testFailureIgnore );
-
-    public abstract File getBasedir();
-
-    public abstract void setBasedir( File basedir );
-
-    public abstract File getTestClassesDirectory();
-
-    public abstract void setTestClassesDirectory( File testClassesDirectory );
-
-    public abstract File getClassesDirectory();
-
-    public abstract void setClassesDirectory( File classesDirectory );
-
-    public abstract MavenProject getProject();
-
-    public abstract void setProject( MavenProject project );
-
-    public abstract String getIgnoreClasspathElements();
-
-    public abstract void setIgnoreClasspathElements( String ignoreClasspathElements );
-
-    public abstract List getAdditionalClasspathElements();
-
-    public abstract void setAdditionalClasspathElements( List additionalClasspathElements );
-
-    public abstract File getReportsDirectory();
-
-    public abstract void setReportsDirectory( File reportsDirectory );
-
-    public abstract File getTestSourceDirectory();
-
-    public abstract void setTestSourceDirectory( File testSourceDirectory );
-
-    public abstract String getTest();
-
-    public abstract void setTest( String test );
-
-    public abstract List getIncludes();
-
-    public abstract void setIncludes( List includes );
-
-    public abstract List getExcludes();
-
-    public abstract void setExcludes( List excludes );
-
-    public abstract ArtifactRepository getLocalRepository();
-
-    public abstract void setLocalRepository( ArtifactRepository localRepository );
-
-    public abstract Properties getSystemProperties();
-
-    public abstract void setSystemProperties( Properties systemProperties );
-
-    public abstract Map getSystemPropertyVariables();
-
-    public abstract void setSystemPropertyVariables( Map systemPropertyVariables );
-
-    public abstract Properties getProperties();
-
-    public abstract void setProperties( Properties properties );
-
-    public abstract Map getPluginArtifactMap();
-
-    public abstract void setPluginArtifactMap( Map pluginArtifactMap );
-
-    public abstract Map getProjectArtifactMap();
-
-    public abstract void setProjectArtifactMap( Map projectArtifactMap );
-
-    public abstract File getSummaryFile();
-
-    public abstract void setSummaryFile( File summaryFile );
-
-    public abstract boolean isPrintSummary();
-
-    public abstract void setPrintSummary( boolean printSummary );
-
-    public abstract String getReportFormat();
-
-    public abstract void setReportFormat( String reportFormat );
-
-    public abstract boolean isUseFile();
-
-    public abstract void setUseFile( boolean useFile );
-
-    public abstract boolean isRedirectTestOutputToFile();
-
-    public abstract void setRedirectTestOutputToFile( boolean redirectTestOutputToFile );
-
-    public abstract Boolean getFailIfNoTests();
-
-    public abstract void setFailIfNoTests( Boolean failIfNoTests );
-
-    public abstract String getForkMode();
-
-    public abstract void setForkMode( String forkMode );
-
-    public abstract String getJvm();
-
-    public abstract void setJvm( String jvm );
-
-    public abstract String getArgLine();
-
-    public abstract void setArgLine( String argLine );
-
-    public abstract String getDebugForkedProcess();
-
-    public abstract void setDebugForkedProcess( String debugForkedProcess );
-
-    public abstract int getForkedProcessTimeoutInSeconds();
-
-    public abstract void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds );
-
-    public abstract Map getEnvironmentVariables();
-
-    public abstract void setEnvironmentVariables( Map environmentVariables );
-
-    public abstract File getWorkingDirectory();
-
-    public abstract void setWorkingDirectory( File workingDirectory );
-
-    public abstract boolean isChildDelegation();
-
-    public abstract void setChildDelegation( boolean childDelegation );
-
-    public abstract String getGroups();
-
-    public abstract void setGroups( String groups );
-
-    public abstract String getExcludedGroups();
-
-    public abstract void setExcludedGroups( String excludedGroups );
-
-    public abstract File[] getSuiteXmlFiles();
-
-    public abstract void setSuiteXmlFiles( File[] suiteXmlFiles );
-
-    public abstract String getJunitArtifactName();
-
-    public abstract void setJunitArtifactName( String junitArtifactName );
-
-    public abstract String getTestNGArtifactName();
-
-    public abstract void setTestNGArtifactName( String testNGArtifactName );
-
-    public abstract int getThreadCount();
-
-    public abstract void setThreadCount( int threadCount );
-
-    public abstract String getPerCoreThreadCount();
-
-    public abstract void setPerCoreThreadCount( String perCoreThreadCount );
-
-    public abstract String getUseUnlimitedThreads();
-
-    public abstract void setUseUnlimitedThreads( String useUnlimitedThreads );
-
-    public abstract String getParallel();
-
-    public abstract void setParallel( String parallel );
-
-    public abstract boolean isTrimStackTrace();
-
-    public abstract void setTrimStackTrace( boolean trimStackTrace );
-
-    public abstract ArtifactResolver getArtifactResolver();
-
-    public abstract void setArtifactResolver( ArtifactResolver artifactResolver );
-
-    public abstract ArtifactFactory getArtifactFactory();
-
-    public abstract void setArtifactFactory( ArtifactFactory artifactFactory );
-
-    public abstract List getRemoteRepositories();
-
-    public abstract void setRemoteRepositories( List remoteRepositories );
-
-    public abstract ArtifactMetadataSource getMetadataSource();
-
-    public abstract void setMetadataSource( ArtifactMetadataSource metadataSource );
-
-    public abstract Properties getOriginalSystemProperties();
-
-    public abstract void setOriginalSystemProperties( Properties originalSystemProperties );
-
-    public abstract Properties getInternalSystemProperties();
-
-    public abstract void setInternalSystemProperties( Properties internalSystemProperties );
-
-    public abstract boolean isDisableXmlReport();
-
-    public abstract void setDisableXmlReport( boolean disableXmlReport );
-
-    public abstract Boolean getUseSystemClassLoader();
-
-    public abstract void setUseSystemClassLoader( Boolean useSystemClassLoader );
-
-    public abstract boolean isUseManifestOnlyJar();
-
-    public abstract void setUseManifestOnlyJar( boolean useManifestOnlyJar );
-
-    public abstract boolean isEnableAssertions();
-
-    public abstract void setEnableAssertions( boolean enableAssertions );
-
-    public abstract MavenSession getSession();
-
-    public abstract void setSession( MavenSession session );
-
-    public abstract String getObjectFactory();
-
-    public abstract void setObjectFactory( String objectFactory );
-
-    public abstract String getEncoding();
-
-    public abstract void setEncoding( String encoding );
-
-    public abstract ToolchainManager getToolchainManager();
-
-    public abstract void setToolchainManager( ToolchainManager toolchainManager );
-
     // common code
 
-    protected abstract boolean isTestsSkipped();
-
     protected abstract String getPluginName();
 
-    protected boolean verifyParameters()
-        throws MojoFailureException
-    {
-        if ( isTestsSkipped() )
-        {
-            getLog().info( "Tests are skipped." );
-            return false;
-        }
-
-        if ( !getTestClassesDirectory().exists() )
-        {
-            if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() )
-            {
-                throw new MojoFailureException( "No tests to run!" );
-            }
-            getLog().info( "No tests to run." );
-            return false;
-        }
-
-        if ( !getWorkingDirectory().exists() )
-        {
-            if ( !getWorkingDirectory().mkdirs() )
-            {
-                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() );
-            }
-        }
-
-        if ( !getWorkingDirectory().isDirectory() )
-        {
-            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() + " exists and is not a directory" );
-        }
+    protected abstract boolean verifyParameters()
+        throws MojoFailureException;
 
-        if ( getUseSystemClassLoader() != null && ForkConfiguration.FORK_NEVER.equals( getForkMode() ) )
-        {
-            getLog().warn( "useSystemClassloader setting has no effect when not forking" );
-        }
-
-        return true;
-    }
-
-    protected Toolchain getToolchain()
+    protected final Toolchain getToolchain()
     {
         Toolchain tc = null;
 
@@ -382,7 +97,7 @@ public abstract class AbstractSurefireMo
 
         if ( this.getThreadCount() > 0 )
         {
-            getProperties().setProperty( "threadcount", new Integer( this.getThreadCount() ).toString() );
+            getProperties().setProperty( "threadcount", Integer.toString( this.getThreadCount() ) );
         }
         if ( this.getObjectFactory() != null )
         {
@@ -412,7 +127,7 @@ public abstract class AbstractSurefireMo
         }
         if ( this.getThreadCount() > 0 )
         {
-            getProperties().setProperty( "threadCount", new Integer( this.getThreadCount() ).toString() );
+            getProperties().setProperty( "threadCount", Integer.toString( this.getThreadCount() ) );
         }
         if ( this.getPerCoreThreadCount() != null )
         {
@@ -1020,4 +735,5 @@ public abstract class AbstractSurefireMo
             surefireBooter.addReport( XMLReporter.class.getName(), new Object[]{ getReportsDirectory(), trimStackTrace} );
         }
     }
+
 }

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java?rev=945183&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java Mon May 17 14:36:27 2010
@@ -0,0 +1,246 @@
+package org.apache.maven.plugin.surefire;
+
+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.ArtifactResolver;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.toolchain.ToolchainManager;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The parameters required to execute surefire.
+ *
+ * @author Stephen Connolly
+ */
+public interface SurefireExecutionParameters
+{
+    boolean isSkipTests();
+
+    void setSkipTests( boolean skipTests );
+
+    boolean isSkipExec();
+
+    void setSkipExec( boolean skipExec );
+
+    boolean isSkip();
+
+    void setSkip( boolean skip );
+
+    File getBasedir();
+
+    void setBasedir( File basedir );
+
+    File getTestClassesDirectory();
+
+    void setTestClassesDirectory( File testClassesDirectory );
+
+    File getClassesDirectory();
+
+    void setClassesDirectory( File classesDirectory );
+
+    MavenProject getProject();
+
+    void setProject( MavenProject project );
+
+    String getIgnoreClasspathElements();
+
+    void setIgnoreClasspathElements( String ignoreClasspathElements );
+
+    List getAdditionalClasspathElements();
+
+    void setAdditionalClasspathElements( List additionalClasspathElements );
+
+    File getReportsDirectory();
+
+    void setReportsDirectory( File reportsDirectory );
+
+    File getTestSourceDirectory();
+
+    void setTestSourceDirectory( File testSourceDirectory );
+
+    String getTest();
+
+    void setTest( String test );
+
+    List getIncludes();
+
+    void setIncludes( List includes );
+
+    List getExcludes();
+
+    void setExcludes( List excludes );
+
+    ArtifactRepository getLocalRepository();
+
+    void setLocalRepository( ArtifactRepository localRepository );
+
+    Properties getSystemProperties();
+
+    void setSystemProperties( Properties systemProperties );
+
+    Map getSystemPropertyVariables();
+
+    void setSystemPropertyVariables( Map systemPropertyVariables );
+
+    Properties getProperties();
+
+    void setProperties( Properties properties );
+
+    Map getPluginArtifactMap();
+
+    void setPluginArtifactMap( Map pluginArtifactMap );
+
+    Map getProjectArtifactMap();
+
+    void setProjectArtifactMap( Map projectArtifactMap );
+
+    boolean isPrintSummary();
+
+    void setPrintSummary( boolean printSummary );
+
+    String getReportFormat();
+
+    void setReportFormat( String reportFormat );
+
+    boolean isUseFile();
+
+    void setUseFile( boolean useFile );
+
+    boolean isRedirectTestOutputToFile();
+
+    void setRedirectTestOutputToFile( boolean redirectTestOutputToFile );
+
+    String getForkMode();
+
+    void setForkMode( String forkMode );
+
+    String getJvm();
+
+    void setJvm( String jvm );
+
+    String getArgLine();
+
+    void setArgLine( String argLine );
+
+    String getDebugForkedProcess();
+
+    void setDebugForkedProcess( String debugForkedProcess );
+
+    int getForkedProcessTimeoutInSeconds();
+
+    void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds );
+
+    Map getEnvironmentVariables();
+
+    void setEnvironmentVariables( Map environmentVariables );
+
+    File getWorkingDirectory();
+
+    void setWorkingDirectory( File workingDirectory );
+
+    boolean isChildDelegation();
+
+    void setChildDelegation( boolean childDelegation );
+
+    String getGroups();
+
+    void setGroups( String groups );
+
+    String getExcludedGroups();
+
+    void setExcludedGroups( String excludedGroups );
+
+    File[] getSuiteXmlFiles();
+
+    void setSuiteXmlFiles( File[] suiteXmlFiles );
+
+    String getJunitArtifactName();
+
+    void setJunitArtifactName( String junitArtifactName );
+
+    String getTestNGArtifactName();
+
+    void setTestNGArtifactName( String testNGArtifactName );
+
+    int getThreadCount();
+
+    void setThreadCount( int threadCount );
+
+    String getPerCoreThreadCount();
+
+    void setPerCoreThreadCount( String perCoreThreadCount );
+
+    String getUseUnlimitedThreads();
+
+    void setUseUnlimitedThreads( String useUnlimitedThreads );
+
+    String getParallel();
+
+    void setParallel( String parallel );
+
+    boolean isTrimStackTrace();
+
+    void setTrimStackTrace( boolean trimStackTrace );
+
+    ArtifactResolver getArtifactResolver();
+
+    void setArtifactResolver( ArtifactResolver artifactResolver );
+
+    ArtifactFactory getArtifactFactory();
+
+    void setArtifactFactory( ArtifactFactory artifactFactory );
+
+    List getRemoteRepositories();
+
+    void setRemoteRepositories( List remoteRepositories );
+
+    ArtifactMetadataSource getMetadataSource();
+
+    void setMetadataSource( ArtifactMetadataSource metadataSource );
+
+    Properties getOriginalSystemProperties();
+
+    void setOriginalSystemProperties( Properties originalSystemProperties );
+
+    Properties getInternalSystemProperties();
+
+    void setInternalSystemProperties( Properties internalSystemProperties );
+
+    boolean isDisableXmlReport();
+
+    void setDisableXmlReport( boolean disableXmlReport );
+
+    Boolean getUseSystemClassLoader();
+
+    void setUseSystemClassLoader( Boolean useSystemClassLoader );
+
+    boolean isUseManifestOnlyJar();
+
+    void setUseManifestOnlyJar( boolean useManifestOnlyJar );
+
+    boolean isEnableAssertions();
+
+    void setEnableAssertions( boolean enableAssertions );
+
+    MavenSession getSession();
+
+    void setSession( MavenSession session );
+
+    String getObjectFactory();
+
+    void setObjectFactory( String objectFactory );
+
+    ToolchainManager getToolchainManager();
+
+    void setToolchainManager( ToolchainManager toolchainManager );
+
+    Boolean getFailIfNoTests();
+
+    void setFailIfNoTests( Boolean failIfNoTests );
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java?rev=945183&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java Mon May 17 14:36:27 2010
@@ -0,0 +1,58 @@
+package org.apache.maven.plugin.surefire;
+
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.surefire.booter.SurefireBooter;
+
+/**
+ * Helper class for surefire plugins
+ */
+public final class SurefireHelper
+{
+
+    /**
+     * Do not instantiate.
+     */
+    private SurefireHelper()
+    {
+        throw new IllegalAccessError( "Utility class" );
+    }
+
+    public static void reportExecution( SurefireReportParameters reportParameters, int result, Log log )
+        throws MojoFailureException
+    {
+        if ( result == 0 )
+        {
+            return;
+        }
+
+        String msg;
+
+        if ( result == SurefireBooter.NO_TESTS_EXIT_CODE )
+        {
+            if ( ( reportParameters.getFailIfNoTests() == null ) || !reportParameters.getFailIfNoTests().booleanValue() )
+            {
+                return;
+            }
+            // TODO: i18n
+            throw new MojoFailureException(
+                "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
+        }
+        else
+        {
+            // TODO: i18n
+            msg = "There are test failures.\n\nPlease refer to " + reportParameters.getReportsDirectory()
+                + " for the individual test results.";
+
+        }
+
+        if ( reportParameters.isTestFailureIgnore() )
+        {
+            log.error( msg );
+        }
+        else
+        {
+            throw new MojoFailureException( msg );
+        }
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java?rev=945183&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java Mon May 17 14:36:27 2010
@@ -0,0 +1,43 @@
+package org.apache.maven.plugin.surefire;
+
+import java.io.File;
+
+/**
+ * The parameters required to report on a surefire execution.
+ *
+ * @author Stephen Connolly
+ */
+public interface SurefireReportParameters
+{
+    boolean isSkipTests();
+
+    void setSkipTests( boolean skipTests );
+
+    boolean isSkipExec();
+
+    void setSkipExec( boolean skipExec );
+
+    boolean isSkip();
+
+    void setSkip( boolean skip );
+
+    boolean isTestFailureIgnore();
+
+    void setTestFailureIgnore( boolean testFailureIgnore );
+
+    File getBasedir();
+
+    void setBasedir( File basedir );
+
+    File getTestClassesDirectory();
+
+    void setTestClassesDirectory( File testClassesDirectory );
+
+    File getReportsDirectory();
+
+    void setReportsDirectory( File reportsDirectory );
+
+    Boolean getFailIfNoTests();
+
+    void setFailIfNoTests( Boolean failIfNoTests );
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=945183&r1=945182&r2=945183&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Mon May 17 14:36:27 2010
@@ -20,30 +20,15 @@ package org.apache.maven.plugin.surefire
  */
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
 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.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -52,14 +37,6 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.SurefireBooter;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.booter.SurefireExecutionException;
-import org.apache.maven.surefire.report.BriefConsoleReporter;
-import org.apache.maven.surefire.report.BriefFileReporter;
-import org.apache.maven.surefire.report.ConsoleReporter;
-import org.apache.maven.surefire.report.DetailedConsoleReporter;
-import org.apache.maven.surefire.report.FileReporter;
-import org.apache.maven.surefire.report.ForkingConsoleReporter;
-import org.apache.maven.surefire.report.XMLReporter;
-import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -74,6 +51,7 @@ import org.codehaus.plexus.util.StringUt
  */
 public class SurefirePlugin
     extends AbstractSurefireMojo
+    implements SurefireExecutionParameters, SurefireReportParameters
 {
 
     /**
@@ -601,45 +579,48 @@ public class SurefirePlugin
                 System.setProperties( getOriginalSystemProperties() );
             }
 
-            if ( result == 0 )
-            {
-                return;
-            }
+            SurefireHelper.reportExecution( this, result, getLog() );
+        }
+    }
 
-            String msg;
+    protected boolean verifyParameters()
+        throws MojoFailureException
+    {
+        if ( isSkip() || isSkipTests() || isSkipExec() )
+        {
+            getLog().info( "Tests are skipped." );
+            return false;
+        }
 
-            if ( result == SurefireBooter.NO_TESTS_EXIT_CODE )
-            {
-                if ( ( getFailIfNoTests() == null ) || !getFailIfNoTests().booleanValue() )
-                {
-                    return;
-                }
-                // TODO: i18n
-                throw new MojoFailureException(
-                    "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
-            }
-            else
+        if ( !getTestClassesDirectory().exists() )
+        {
+            if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue() )
             {
-                // TODO: i18n
-                msg = "There are test failures.\n\nPlease refer to " + getReportsDirectory()
-                    + " for the individual test results.";
-
+                throw new MojoFailureException( "No tests to run!" );
             }
+            getLog().info( "No tests to run." );
+            return false;
+        }
 
-            if ( isTestFailureIgnore() )
-            {
-                getLog().error( msg );
-            }
-            else
+        if ( !getWorkingDirectory().exists() )
+        {
+            if ( !getWorkingDirectory().mkdirs() )
             {
-                throw new MojoFailureException( msg );
+                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() );
             }
         }
-    }
 
-    protected boolean isTestsSkipped()
-    {
-        return isSkip() || isSkipTests() || isSkipExec();
+        if ( !getWorkingDirectory().isDirectory() )
+        {
+            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() + " exists and is not a directory" );
+        }
+
+        if ( getUseSystemClassLoader() != null && ForkConfiguration.FORK_NEVER.equals( getForkMode() ) )
+        {
+            getLog().warn( "useSystemClassloader setting has no effect when not forking" );
+        }
+
+        return true;
     }
 
     protected String getPluginName()
@@ -1224,36 +1205,4 @@ public class SurefirePlugin
         this.toolchainManager = toolchainManager;
     }
 
-    // the following will be refactored out once the common code is all in one place
-
-    public String getEncoding()
-    {
-        return null; // ignore
-    }
-
-    public void setEncoding( String encoding )
-    {
-        // ignore
-    }
-
-    public boolean isSkipITs()
-    {
-        return false; // ignore
-    }
-
-    public void setSkipITs( boolean skipITs )
-    {
-        // ignore
-    }
-
-    public File getSummaryFile()
-    {
-        return null; // ignore
-    }
-
-    public void setSummaryFile( File summaryFile )
-    {
-        // ignore
-    }
-
 }



Mime
View raw message