1 package org.apache.maven.reporting;
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.Locale;
24
25 import org.apache.maven.doxia.siterenderer.Renderer;
26 import org.apache.maven.project.MavenProject;
27
28 /**
29 * Typical code to copy as a reporting plugin start: choose the goal name, then implement getOutputName(),
30 * getName( Locale ), getDescription( Locale ) and of course executeReport( Locale ).
31 *
32 * @goal test
33 */
34 public class AbstractMavenReportTest
35 extends AbstractMavenReport
36 {
37 /**
38 * The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from
39 * the command line. If the goal is run indirectly as part of a site generation, the output directory configured in
40 * the Maven Site Plugin is used instead.
41 *
42 * @parameter expression="${project.reporting.outputDirectory}"
43 * @required
44 */
45 protected File outputDirectory;
46
47 /**
48 * The Maven Project.
49 *
50 * @parameter expression="${project}"
51 * @required
52 * @readonly
53 */
54 protected MavenProject project;
55
56 /**
57 * Doxia Site Renderer component.
58 *
59 * @component
60 */
61 protected Renderer siteRenderer;
62
63 @Override
64 protected String getOutputDirectory()
65 {
66 return outputDirectory.getAbsolutePath();
67 }
68
69 @Override
70 protected MavenProject getProject()
71 {
72 return project;
73 }
74
75 @Override
76 protected Renderer getSiteRenderer()
77 {
78 return siteRenderer;
79 }
80
81 public String getOutputName()
82 {
83 return "abstract-maven-report-test";
84 }
85
86 public String getName( Locale locale )
87 {
88 return "Abstract Maven Report Test";
89 }
90
91 public String getDescription( Locale locale )
92 {
93 return "Abstract Maven Report Test Description";
94 }
95
96 @Override
97 protected void executeReport( Locale locale )
98 throws MavenReportException
99 {
100 // direct report generation
101 /*getSink().body();
102 getSink().text( "Abstract Maven Report Test Content" );
103 getSink().body_();*/
104
105 // use a AbstractMavenReportRenderer subclass
106 MavenReportRenderer r = new DemoReportRenderer( getSink() );
107 }
108 }