1 package org.codehaus.mojo.pde;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 }