1 package org.apache.maven.plugin.cxx;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.DataOutputStream;
22 import java.io.File;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.util.Properties;
26
27 import org.apache.commons.exec.CommandLine;
28 import org.apache.commons.exec.Executor;
29 import org.apache.maven.plugin.MojoExecutionException;
30
31 import org.apache.maven.plugins.annotations.LifecyclePhase;
32 import org.apache.maven.plugins.annotations.Mojo;
33 import org.apache.maven.plugins.annotations.Parameter;
34
35
36
37
38
39
40
41 @Mojo( name = "xunit", defaultPhase = LifecyclePhase.TEST )
42 public class XUnitMojo extends LaunchMojo
43 {
44
45
46
47
48
49 @Parameter( property = "xunit.reportsfilePath", defaultValue = "${project.build.directory}/xunit-reports" )
50 private File reportsfileDir;
51
52 @Override
53 protected void preExecute( Executor exec, CommandLine commandLine, Properties enviro ) throws MojoExecutionException
54 {
55
56 String outputReportDir = new String();
57 if ( reportsfileDir.isAbsolute() )
58 {
59 outputReportDir = reportsfileDir.getAbsolutePath();
60 }
61 else
62 {
63 outputReportDir = basedir.getAbsolutePath() + "/" + reportsfileDir.getPath();
64 }
65 new File( outputReportDir ).mkdirs();
66 getLog().info( "You shall produce a xUnit report called \"" + outputReportDir + File.separator
67 + "xunit-result-*.xml\" within this xunit goal" );
68 File file = new File( outputReportDir + "/Readme.txt" );
69 try
70 {
71 DataOutputStream out = new DataOutputStream( new FileOutputStream( file ) );
72 out.writeBytes( "You shall produce xUnit reports called \"xunit-result-*.xml\" within this directory.\n" );
73 }
74 catch ( IOException e )
75 {
76 getLog().info( "Could not write to " + outputReportDir + File.separator + "Readme.txt" );
77 }
78 }
79
80
81
82
83
84
85 @Parameter( property = "xunit.skiptests", defaultValue = "false" )
86 private boolean skiptests;
87
88
89
90
91
92
93
94 @Parameter( property = "skipTests", defaultValue = "false" )
95 protected boolean skipTests;
96
97
98
99
100
101
102
103
104 @Parameter( property = "maven.test.skip", defaultValue = "false" )
105 protected boolean skip;
106
107 protected boolean isSkip()
108 {
109 return super.isSkip() || skiptests || skipTests || skip;
110 }
111 }