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 java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Iterator;
26 import java.util.List;
27 import java.util.Locale;
28 import java.util.ResourceBundle;
29
30 import org.apache.maven.doxia.siterenderer.Renderer;
31 import org.apache.maven.model.ReportPlugin;
32 import org.apache.maven.project.MavenProject;
33 import org.apache.maven.reporting.AbstractMavenReport;
34 import org.apache.maven.reporting.MavenReportException;
35 import org.codehaus.plexus.util.PathTool;
36 import org.codehaus.plexus.util.StringUtils;
37
38
39 /**
40 * Creates a nicely formatted Surefire Test Report in html format.
41 *
42 * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
43 * @version $Id: SurefireReportMojo.java 1204901 2011-11-22 10:35:17Z stephenc $
44 * @goal report
45 * @execute phase="test" lifecycle="surefire"
46 */
47 public class SurefireReportMojo
48 extends AbstractSurefireReportMojo
49 {
50
51 /**
52 * The filename to use for the report.
53 *
54 * @parameter expression="${outputName}" default-value="surefire-report"
55 * @required
56 * @noinspection UnusedDeclaration
57 */
58 private String outputName;
59
60 /**
61 * If set to true the surefire report will be generated even when there are no surefire result files.
62 * Defaulyts to <code>true</code> to preserve legacy behaviour pre 2.10.
63 *
64 * @parameter expression="${alwaysGenerateSurefireReport}" default-value="true"
65 * @noinspection UnusedDeclaration
66 * @since 2.11
67 */
68 private boolean alwaysGenerateSurefireReport;
69
70 /**
71 * If set to true the surefire report generation will be skipped.
72 *
73 * @parameter expression="${skipSurefireReport}" default-value="false"
74 * @noinspection UnusedDeclaration
75 * @since 2.11
76 */
77 private boolean skipSurefireReport;
78
79 protected File getSurefireReportsDirectory( MavenProject subProject )
80 {
81 String buildDir = subProject.getBuild().getDirectory();
82 return new File( buildDir + "/surefire-reports" );
83 }
84
85 public String getOutputName()
86 {
87 return outputName;
88 }
89
90 protected boolean isSkipped()
91 {
92 return skipSurefireReport;
93 }
94
95 protected boolean isGeneratedWhenNoResults()
96 {
97 return alwaysGenerateSurefireReport;
98 }
99 }