1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package com.soebes.maven.plugins.doxygen;
23
24 import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
25 import org.apache.maven.doxia.siterenderer.Renderer;
26 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugin.MojoFailureException;
29 import org.apache.maven.plugins.annotations.Component;
30 import org.apache.maven.plugins.annotations.LifecyclePhase;
31 import org.apache.maven.plugins.annotations.Mojo;
32 import org.apache.maven.plugins.annotations.Parameter;
33 import org.apache.maven.project.MavenProject;
34 import org.apache.maven.reporting.MavenReport;
35 import org.apache.maven.reporting.MavenReportException;
36 import org.codehaus.doxia.sink.Sink;
37 import java.io.File;
38 import java.util.Locale;
39
40
41
42
43
44
45 @Mojo( name = "report", defaultPhase = LifecyclePhase.SITE, requiresProject = true, threadSafe = true )
46 public class DoxygenReport
47 extends AbstractDoxygenMojo
48 implements MavenReport
49 {
50
51 @Component
52 private Renderer siteRenderer;
53
54
55
56
57
58 @Parameter(defaultValue = "${project.reporting.outputDirectory}", property = "reportOutputDirectory", required = true)
59 private File reportOutputDirectory;
60
61
62
63
64
65 @Parameter(defaultValue = "doxygen", property = "destDir")
66 private String destDir;
67
68
69
70 public void execute()
71 throws MojoExecutionException, MojoFailureException
72 {
73 if ( isSkip() )
74 {
75 getLog().info( "Skipping doxgenc generation" );
76 return;
77 }
78
79 try
80 {
81 RenderingContext context = new RenderingContext( getOutputDirectory(), getOutputName() + ".html" );
82 SiteRendererSink sink = new SiteRendererSink( context );
83 Locale locale = Locale.getDefault();
84 generate( sink, locale );
85 }
86 catch ( MavenReportException e )
87 {
88
89
90
91
92
93
94 getLog().error( "An error has occurred in " + getName( Locale.ENGLISH )
95 + " report generation:" + e.getMessage(), e );
96 }
97 catch ( RuntimeException e )
98 {
99 getLog().error( e.getMessage(), e );
100 }
101 }
102
103
104 public void generate( Sink sink, Locale locale )
105 throws MavenReportException
106 {
107 setOutputDirectory(getReportOutputDirectory());
108
109 executeReport( locale );
110 }
111
112
113
114 public File getReportOutputDirectory() {
115 if (reportOutputDirectory == null) {
116 return reportOutputDirectory;
117 }
118
119 return reportOutputDirectory;
120 }
121
122
123 protected MavenProject getProject() {
124 return getProject();
125 }
126
127
128 public String getCategoryName()
129 {
130 return CATEGORY_PROJECT_REPORTS;
131 }
132
133
134
135 public String getOutputName()
136 {
137 return "doxygen" + "/index";
138 }
139
140
141 public boolean isExternalReport()
142 {
143 return true;
144 }
145
146
147 public String getDescription(Locale locale) {
148 return "Doxygen Report";
149 }
150
151
152 public String getName(Locale locale) {
153 return "Doxygen";
154 }
155
156 public void setDestDir(String destDir) {
157 this.destDir = destDir;
158 }
159
160 public String getDestDir() {
161 return destDir;
162 }
163
164 public boolean canGenerateReport() {
165 return true;
166 }
167
168 public void setReportOutputDirectory(File reportOutputDirectory) {
169 this.reportOutputDirectory = getOutputDirectory();
170 }
171 }