1 package org.apache.maven.plugins.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugins.annotations.Mojo;
23 import org.apache.maven.plugins.annotations.Parameter;
24 import org.apache.maven.project.MavenProject;
25
26 import java.io.File;
27 import java.util.Locale;
28 import java.util.ResourceBundle;
29
30 import static org.apache.maven.shared.utils.StringUtils.isEmpty;
31
32
33
34
35
36
37
38
39
40
41 @Mojo( name = "failsafe-report-only" )
42 @SuppressWarnings( "unused" )
43 public class FailsafeReportMojo
44 extends AbstractSurefireReportMojo
45 {
46
47
48
49
50 @Parameter( defaultValue = "failsafe-report", property = "outputName", required = true )
51 private String outputName;
52
53
54
55
56
57
58 @Parameter( defaultValue = "false", property = "alwaysGenerateFailsafeReport" )
59 private boolean alwaysGenerateFailsafeReport;
60
61
62
63
64
65 @Parameter( defaultValue = "false", property = "skipFailsafeReport" )
66 private boolean skipFailsafeReport;
67
68
69
70
71
72 @Parameter( defaultValue = "", property = "failsafe.report.title" )
73 private String title;
74
75
76
77
78
79 @Parameter( defaultValue = "", property = "failsafe.report.description" )
80 private String description;
81
82 @Override
83 protected File getSurefireReportsDirectory( MavenProject subProject )
84 {
85 String buildDir = subProject.getBuild().getDirectory();
86 return new File( buildDir + "/failsafe-reports" );
87 }
88
89 @Override
90 public String getOutputName()
91 {
92 return outputName;
93 }
94
95 @Override
96 protected LocalizedProperties getBundle( Locale locale, ClassLoader resourceBundleClassLoader )
97 {
98 ResourceBundle bundle = ResourceBundle.getBundle( "surefire-report", locale, resourceBundleClassLoader );
99 return new LocalizedProperties( bundle )
100 {
101 @Override
102 public String getReportName()
103 {
104 return isEmpty( FailsafeReportMojo.this.getTitle() )
105 ? toLocalizedValue( "report.failsafe.name" ) : FailsafeReportMojo.this.getTitle();
106 }
107
108 @Override
109 public String getReportDescription()
110 {
111 return isEmpty( FailsafeReportMojo.this.getDescription() )
112 ? toLocalizedValue( "report.failsafe.description" ) : FailsafeReportMojo.this.getDescription();
113 }
114
115 @Override
116 public String getReportHeader()
117 {
118 return isEmpty( FailsafeReportMojo.this.getTitle() )
119 ? toLocalizedValue( "report.failsafe.header" ) : FailsafeReportMojo.this.getTitle();
120 }
121 };
122 }
123
124 @Override
125 protected boolean isSkipped()
126 {
127 return skipFailsafeReport;
128 }
129
130 @Override
131 protected boolean isGeneratedWhenNoResults()
132 {
133 return alwaysGenerateFailsafeReport;
134 }
135
136 @Override
137 public void setTitle( String title )
138 {
139 this.title = title;
140 }
141
142 @Override
143 public String getTitle()
144 {
145 return title;
146 }
147
148 @Override
149 public void setDescription( String description )
150 {
151 this.description = description;
152 }
153
154 @Override
155 public String getDescription()
156 {
157 return description;
158 }
159 }