maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java SurefireFailureResponse.java
Date Tue, 22 Mar 2005 13:40:14 GMT
brett       2005/03/22 05:40:14

  Modified:    maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
                        SurefirePlugin.java
  Removed:     maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
                        SurefireFailureResponse.java
  Log:
  convert surefire plugin to new execute()
  
  Revision  Changes    Path
  1.21      +45 -25    maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java
  
  Index: SurefirePlugin.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SurefirePlugin.java	15 Mar 2005 21:41:06 -0000	1.20
  +++ SurefirePlugin.java	22 Mar 2005 13:40:14 -0000	1.21
  @@ -1,8 +1,23 @@
   package org.apache.maven.test;
   
  +/*
  + * Copyright 2001-2005 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import org.apache.maven.plugin.AbstractPlugin;
  -import org.apache.maven.plugin.PluginExecutionRequest;
  -import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.apache.maven.plugin.PluginExecutionException;
   import org.codehaus.surefire.SurefireBooter;
   
   import java.io.File;
  @@ -76,36 +91,36 @@
   public class SurefirePlugin
       extends AbstractPlugin
   {
  -    public void execute( PluginExecutionRequest request, PluginExecutionResponse response
)
  -        throws Exception
  -    {
  -        // ----------------------------------------------------------------------
  -        //
  -        // ----------------------------------------------------------------------
  +    private String mavenRepoLocal;
   
  -        String mavenRepoLocal = (String) request.getParameter( "mavenRepoLocal" );
  +    private String basedir;
   
  -        String basedir = (String) request.getParameter( "basedir" );
  +    private String classesDirectory;
   
  -        String classesDirectory = (String) request.getParameter( "classesDirectory" );
  +    private String testClassesDirectory;
   
  -        String testClassesDirectory = (String) request.getParameter( "testClassesDirectory"
);
  +    private List classpathElements;
   
  -        List testClasspathElements = (List) request.getParameter( "classpathElements" );
  +    private String reportsDirectory;
   
  -        String reportsDirectory = (String) request.getParameter( "reportsDirectory" );
  +    private String test;
   
  -        String test = (String) request.getParameter( "test" );
  +    private List includes;
   
  +    private List excludes;
  +
  +    public void execute()
  +        throws PluginExecutionException
  +    {
           // ----------------------------------------------------------------------
           // Setup the surefire booter
           // ----------------------------------------------------------------------
   
           SurefireBooter surefireBooter = new SurefireBooter();
   
  -        System.out.println("Setting reports dir: " + reportsDirectory);
  +        System.out.println( "Setting reports dir: " + reportsDirectory );
           System.out.flush();
  -        
  +
           surefireBooter.setReportsDirectory( reportsDirectory );
   
           // ----------------------------------------------------------------------
  @@ -133,10 +148,6 @@
           }
           else
           {
  -            List includes = (List) request.getParameter( "includes" );
  -
  -            List excludes = (List) request.getParameter( "excludes" );
  -
               // defaults here, qdox doesn't like the end javadoc value
               if ( includes == null )
               {
  @@ -168,7 +179,7 @@
   
           surefireBooter.addClassPathUrl( new File( testClassesDirectory ).getPath() );
   
  -        for ( Iterator i = testClasspathElements.iterator(); i.hasNext(); )
  +        for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
           {
               surefireBooter.addClassPathUrl( (String) i.next() );
           }
  @@ -177,11 +188,20 @@
   
           surefireBooter.addReport( "org.codehaus.surefire.report.FileReporter" );
   
  -        boolean success = surefireBooter.run();
  +        boolean success = false;
  +        try
  +        {
  +            success = surefireBooter.run();
  +        }
  +        catch ( Exception e )
  +        {
  +            // TODO: better handling
  +            throw new PluginExecutionException( "Error executing surefire", e );
  +        }
   
           if ( !success )
           {
  -            response.setExecutionFailure( new SurefireFailureResponse( null ) );
  +            throw new PluginExecutionException( "There are some test failures." );
           }
       }
   
  
  
  

Mime
View raw message