Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SurefireReportMojo |
|
| 1.0;1 |
1 | package org.apache.maven.plugins.surefire.report; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.io.File; | |
23 | import org.apache.maven.plugins.annotations.Execute; | |
24 | import org.apache.maven.plugins.annotations.LifecyclePhase; | |
25 | import org.apache.maven.plugins.annotations.Mojo; | |
26 | import org.apache.maven.plugins.annotations.Parameter; | |
27 | import org.apache.maven.project.MavenProject; | |
28 | ||
29 | ||
30 | /** | |
31 | * Creates a nicely formatted Surefire Test Report in html format. | |
32 | * | |
33 | * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a> | |
34 | */ | |
35 | @Mojo(name = "report", inheritByDefault = false) | |
36 | @Execute(lifecycle = "surefire", phase = LifecyclePhase.TEST) | |
37 | 4 | public class SurefireReportMojo |
38 | extends AbstractSurefireReportMojo | |
39 | { | |
40 | ||
41 | /** | |
42 | * The filename to use for the report. | |
43 | * | |
44 | * @noinspection UnusedDeclaration | |
45 | */ | |
46 | @Parameter(defaultValue = "surefire-report", property = "outputName", required = true) | |
47 | private String outputName; | |
48 | ||
49 | /** | |
50 | * If set to true the surefire report will be generated even when there are no surefire result files. | |
51 | * Defaulyts to <code>true</code> to preserve legacy behaviour pre 2.10. | |
52 | * | |
53 | * @noinspection UnusedDeclaration | |
54 | * @since 2.11 | |
55 | */ | |
56 | @Parameter(defaultValue = "true", property = "alwaysGenerateSurefireReport") | |
57 | private boolean alwaysGenerateSurefireReport; | |
58 | ||
59 | /** | |
60 | * If set to true the surefire report generation will be skipped. | |
61 | * | |
62 | * @noinspection UnusedDeclaration | |
63 | * @since 2.11 | |
64 | */ | |
65 | @Parameter(defaultValue = "false", property = "skipSurefireReport") | |
66 | private boolean skipSurefireReport; | |
67 | ||
68 | protected File getSurefireReportsDirectory( MavenProject subProject ) | |
69 | { | |
70 | 0 | String buildDir = subProject.getBuild().getDirectory(); |
71 | 0 | return new File( buildDir + "/surefire-reports" ); |
72 | } | |
73 | ||
74 | public String getOutputName() | |
75 | { | |
76 | 4 | return outputName; |
77 | } | |
78 | ||
79 | protected boolean isSkipped() | |
80 | { | |
81 | 12 | return skipSurefireReport; |
82 | } | |
83 | ||
84 | protected boolean isGeneratedWhenNoResults() | |
85 | { | |
86 | 12 | return alwaysGenerateSurefireReport; |
87 | } | |
88 | } |