View Javadoc

1   package org.codehaus.mojo.pde;
2   
3   /*
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.File;
20  
21  import org.apache.maven.plugin.MojoExecutionException;
22  import org.apache.maven.plugin.MojoFailureException;
23  import org.codehaus.plexus.util.cli.Commandline;
24  
25  /**
26   * Invoke test.xml if present
27   * 
28   * @version $Id:$
29   * @goal test
30   * @phase test
31   * @requiresDependencyResolution test
32   * @author dtran@gmail.com
33   */
34  
35  public class EclipsePDETestMojo
36      extends EclipsePDEMojo
37  {
38  
39      /**
40       * Test File to be invoked if present
41       * @parameter expression="${testXml}" default-value="${basedir}/test.xml"
42       */
43  
44      private File testXml;
45      
46      /**
47       * Error out if test fails
48       * @parameter expression="${failOnError}" default-value="true"
49       */
50      private boolean failOnError;
51  
52      /**
53       * {@inheritDoc}
54       */
55      public void execute()
56          throws MojoExecutionException, MojoFailureException
57      {
58          if ( testXml.exists() && System.getProperty( "maven.test.skip" ) == null )
59          {
60              super.execute();
61  
62              Commandline cl = this.createCommandLine( this.testXml, null );
63              
64              if ( ! failOnError )
65              {
66                  try 
67                  {
68                      this.executeCommandLine( cl );
69                  }
70                  catch ( MojoExecutionException e )
71                  {
72                      this.getLog().warn( "Test failure: " + e.getMessage() );
73                  }
74              }
75              else
76              {
77                  this.executeCommandLine( cl ); 
78              }
79          }
80      }
81  
82  }