View Javadoc
1   /**
2    * The Doxygen Maven Plugin (dmp)
3    *
4    * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 by SoftwareEntwicklung Beratung Schulung (SoEBeS)
5    * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 by Karl Heinz Marbaise
6    *
7    * Licensed to the Apache Software Foundation (ASF) under one or more
8    * contributor license agreements.  See the NOTICE file distributed with
9    * this work for additional information regarding copyright ownership.
10   * The ASF licenses this file to You under the Apache License, Version 2.0
11   * (the "License"); you may not use this file except in compliance with
12   * the License.  You may obtain a copy of the License at
13   *
14   *    http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   */
22  package com.soebes.maven.plugins.doxygen;
23  
24  import java.io.BufferedWriter;
25  import java.io.File;
26  import java.io.FileWriter;
27  import java.io.IOException;
28  import java.io.PrintWriter;
29  import java.io.StringWriter;
30  import java.io.Writer;
31  import java.util.Locale;
32  
33  import org.apache.maven.execution.MavenSession;
34  import org.apache.maven.plugins.annotations.Parameter;
35  import org.apache.maven.reporting.MavenReportException;
36  import org.apache.maven.toolchain.Toolchain;
37  import org.apache.maven.toolchain.ToolchainManager;
38  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
39  import org.codehaus.plexus.util.cli.CommandLineException;
40  import org.codehaus.plexus.util.cli.CommandLineUtils;
41  import org.codehaus.plexus.util.cli.Commandline;
42  import org.codehaus.plexus.util.cli.StreamConsumer;
43  import org.codehaus.plexus.util.cli.WriterStreamConsumer;
44  
45  /**
46   * This abstract class contains all configurable parameters for the doxygen plugin.
47   * 
48   * @author Karl Heinz Marbaise
49   */
50  public abstract class AbstractDoxygenMojo
51      extends AbstractDoxygenConfigurationMojo
52  {
53  
54      /**
55       * The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) base path where the generated
56       * documentation will be put. If a relative path is entered, it will be relative to the location where doxygen was
57       * started. If left blank the current directory will be used.
58       */
59      @Parameter( property = "doxygen.outputDirectory", defaultValue = "${project.reporting.outputDirectory}" )
60      private File outputDirectory;
61  
62      /**
63       * This defines the name and/or the absolute path to he doxygen executable. Usually you shouldn't change this, cause
64       * the plugin will automatically search for the executable.
65       * 
66       */
67      @Parameter( property = "doxygen.executable", defaultValue = "doxygen" )
68      private String executable;
69  
70      /**
71       * The current build session instance. This is used for toolchain manager API calls.
72       *
73       */
74      @Parameter ( defaultValue = "${session}", required = true, readonly = true)
75      private MavenSession session;
76  
77      /**
78       * This is the basedir.
79       */
80      @Parameter( property = "basedir", defaultValue = "${project.basedir}", required = true, readonly = true )
81      private File basedir;
82  
83      /**
84       * This is the skip parameter to simply skip the doxygen generation part.
85       * 
86       */
87      @Parameter( property = "skip", defaultValue = "false", required = true, readonly = true )
88      private boolean skip;
89  
90      protected File getOutputDirectory()
91      {
92          if ( !outputDirectory.isAbsolute() )
93          {
94              outputDirectory = new File( getBasedir(), outputDirectory.getPath() );
95          }
96          // Create the folder structure.
97          if ( !outputDirectory.exists() )
98          {
99              outputDirectory.mkdirs();
100         }
101 
102         return outputDirectory.getAbsoluteFile();
103     }
104 
105     /**
106      * This code is lent from
107      * http://fisheye.codehaus.org/browse/~raw,r=8882/mojo/trunk/mojo/exec-maven-plugin/src/main/java/org/codehaus/mojo/
108      * exec/ExecMojo.java
109      * 
110      * @return Toolchain instance.
111      */
112     private Toolchain getToolchain()
113     {
114         Toolchain tc = null;
115 
116         try
117         {
118             if ( session != null ) // session is null in tests..
119             {
120                 ToolchainManager toolchainManager =
121                     (ToolchainManager) session.getContainer().lookup( ToolchainManager.ROLE );
122 
123                 if ( toolchainManager != null )
124                 {
125                     tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
126                 }
127             }
128         }
129         catch ( ComponentLookupException componentLookupException )
130         {
131             // just ignore, could happen in pre-2.0.9 builds..
132         }
133         return tc;
134     }
135 
136     /**
137      * This will check if the given information for the doxygen executable is enough. If not than we search on the path
138      * for doxygen executable.
139      * 
140      * @return Path to the doxygen executable.
141      */
142     private String getExecutablePath()
143     {
144         File execFile = new File( executable );
145         if ( execFile.exists() )
146         {
147             getLog().debug( "Toolchains are ignored, 'executable' parameter is set to " + executable );
148             return execFile.getAbsolutePath();
149         }
150         else
151         {
152             Toolchain tc = getToolchain();
153 
154             // if the file doesn't exist & toolchain is null, the exec is probably in the PATH...
155             // we should probably also test for isFile and canExecute, but the second one is only
156             // available in SDK 6.
157             if ( tc != null )
158             {
159                 getLog().info( "Toolchain in doxygen plugin: " + tc );
160                 executable = tc.findTool( executable );
161             }
162         }
163 
164         return executable;
165     }
166 
167     /**
168      * This method will get an existing configuration file for doxygen or will create a new one with the configured
169      * parameters.
170      * 
171      * @return The configuration file.
172      * @throws MavenReportException
173      */
174     public File buildConfigurationFile()
175         throws MavenReportException
176     {
177         File ret = getConfigurationFile();
178 
179         if ( ret == null )
180         {
181             ret = new File( getOutputDirectory(), "doxygen.config" );
182             buildConfigurationFile( ret );
183         }
184         else if ( !ret.exists() )
185         {
186             buildConfigurationFile( ret );
187         }
188 
189         return ret;
190     }
191 
192     /**
193      * This method will create the configuration for calling doxygen. Furthermore is will put all configurable items
194      * into the configuration file.
195      * 
196      * @param config The configuration.
197      * @throws MavenReportException
198      */
199     public void buildConfigurationFile( File config )
200         throws MavenReportException
201     {
202         config.getParentFile().mkdirs();
203 
204         PrintWriter out = null;
205         try
206         {
207             out = new PrintWriter( new BufferedWriter( new FileWriter( config ) ) );
208             addConfiguration( out, DoxygenParameters.DOXYFILE_ENCODING, getDoxyfileEncoding() );
209             addConfiguration( out, DoxygenParameters.PROJECT_NAME, getProjectName() );
210             addConfiguration( out, DoxygenParameters.PROJECT_NUMBER, getProjectNumber() );
211             addConfiguration( out, DoxygenParameters.OUTPUT_DIRECTORY, getOutputDirectory().getAbsolutePath() );
212             addConfiguration( out, DoxygenParameters.CREATE_SUBDIRS, isCreateSubdirs() );
213             addConfiguration( out, DoxygenParameters.OUTPUT_LANGUAGE, getOutputLanguage() );
214             addConfiguration( out, DoxygenParameters.BRIEF_MEMBER_DESC, isBriefMemberDesc() );
215             addConfiguration( out, DoxygenParameters.REPEAT_BRIEF, isRepeatBrief() );
216             addConfiguration( out, DoxygenParameters.ABBREVIATE_BRIEF, getAbbreviateBrief() );
217             addConfiguration( out, DoxygenParameters.ALWAYS_DETAILED_SEC, isAlwaysDetailedSec() );
218             addConfiguration( out, DoxygenParameters.INLINE_INHERITED_MEMB, isInlineInheritedMemb() );
219             addConfiguration( out, DoxygenParameters.FULL_PATH_NAMES, isFullPathNames() );
220             addConfiguration( out, DoxygenParameters.STRIP_FROM_PATH, getStripFromPath() );
221             addConfiguration( out, DoxygenParameters.STRIP_FROM_INC_PATH, getStripFromIncPath() );
222             addConfiguration( out, DoxygenParameters.SHORT_NAMES, isShortNames() );
223             addConfiguration( out, DoxygenParameters.JAVADOC_AUTOBRIEF, isJavadocAutobrief() );
224             addConfiguration( out, DoxygenParameters.QT_AUTOBRIEF, isQtAutobrief() );
225             addConfiguration( out, DoxygenParameters.MULTILINE_CPP_IS_BRIEF, isMultilineCppIsBrief() );
226             addConfiguration( out, DoxygenParameters.INHERIT_DOCS, isInheritDocs() );
227             addConfiguration( out, DoxygenParameters.SEPARATE_MEMBER_PAGES, isSeparateMemberPages() );
228             addConfiguration( out, DoxygenParameters.TAB_SIZE, getTabSize() );
229             addConfiguration( out, DoxygenParameters.ALIASES, getAliases() );
230             addConfiguration( out, DoxygenParameters.OPTIMIZE_OUTPUT_FOR_C, isOptimizeOutputForC() );
231             addConfiguration( out, DoxygenParameters.OPTIMIZE_OUTPUT_JAVA, isOptimizeOutputJava() );
232             addConfiguration( out, DoxygenParameters.OPTIMIZE_FOR_FORTRAN, isOptimizeForFortran() );
233             addConfiguration( out, DoxygenParameters.OPTIMIZE_OUTPUT_VHDL, isOptimizeOutputVhdl() );
234             addConfiguration( out, DoxygenParameters.BUILTIN_STL_SUPPORT, isBuiltinStlSupport() );
235             addConfiguration( out, DoxygenParameters.CPP_CLI_SUPPORT, isCppCliSupport() );
236             addConfiguration( out, DoxygenParameters.SIP_SUPPORT, isSipSupport() );
237             addConfiguration( out, DoxygenParameters.IDL_PROPERTY_SUPPORT, isIdlPropertySupport() );
238             addConfiguration( out, DoxygenParameters.DISTRIBUTE_GROUP_DOC, isDistributeGroupDoc() );
239             addConfiguration( out, DoxygenParameters.SUBGROUPING, isSubgrouping() );
240             addConfiguration( out, DoxygenParameters.TYPEDEF_HIDES_STRUCT, isTypedefHidesStruct() );
241             addConfiguration( out, DoxygenParameters.SYMBOL_CACHE_SIZE, getSymbolCacheSize() );
242             addConfiguration( out, DoxygenParameters.EXTRACT_ALL, isExtractAll() );
243             addConfiguration( out, DoxygenParameters.EXTRACT_PRIVATE, isExtractPrivate() );
244             addConfiguration( out, DoxygenParameters.EXTRACT_STATIC, isExtractStatic() );
245             addConfiguration( out, DoxygenParameters.EXTRACT_LOCAL_CLASSES, isExtractLocalClasses() );
246             addConfiguration( out, DoxygenParameters.EXTRACT_LOCAL_METHODS, isExtractLocalMethods() );
247             addConfiguration( out, DoxygenParameters.EXTRACT_ANON_NSPACES, isExtractAnonNspaces() );
248             addConfiguration( out, DoxygenParameters.HIDE_UNDOC_MEMBERS, isHideUndocMembers() );
249             addConfiguration( out, DoxygenParameters.HIDE_UNDOC_CLASSES, isHideUndocClasses() );
250             addConfiguration( out, DoxygenParameters.HIDE_FRIEND_COMPOUNDS, isHideFriendCompounds() );
251             addConfiguration( out, DoxygenParameters.HIDE_IN_BODY_DOCS, isHideInBodyDocs() );
252             addConfiguration( out, DoxygenParameters.INTERNAL_DOCS, isInternalDocs() );
253             addConfiguration( out, DoxygenParameters.CASE_SENSE_NAMES, isCaseSenseNames() );
254             addConfiguration( out, DoxygenParameters.HIDE_SCOPE_NAMES, isHideScopeNames() );
255             addConfiguration( out, DoxygenParameters.SHOW_INCLUDE_FILES, isShowIncludeFiles() );
256             addConfiguration( out, DoxygenParameters.INLINE_INFO, isInlineInfo() );
257             addConfiguration( out, DoxygenParameters.SORT_MEMBER_DOCS, isSortMemberDocs() );
258             addConfiguration( out, DoxygenParameters.SORT_BRIEF_DOCS, isSortBriefDocs() );
259             addConfiguration( out, DoxygenParameters.SORT_GROUP_NAMES, isSortGroupNames() );
260             addConfiguration( out, DoxygenParameters.SORT_BY_SCOPE_NAME, isSortByScopeName() );
261             addConfiguration( out, DoxygenParameters.GENERATE_TODOLIST, isGenerateTodolist() );
262             addConfiguration( out, DoxygenParameters.GENERATE_TESTLIST, isGenerateTestlist() );
263             addConfiguration( out, DoxygenParameters.GENERATE_BUGLIST, isGenerateBuglist() );
264             addConfiguration( out, DoxygenParameters.GENERATE_DEPRECATEDLIST, isGenerateDeprecatedlist() );
265             addConfiguration( out, DoxygenParameters.ENABLED_SECTIONS, getEnabledSections() );
266             addConfiguration( out, DoxygenParameters.MAX_INITIALIZER_LINES, getMaxInitializerLines() );
267             addConfiguration( out, DoxygenParameters.SHOW_USED_FILES, isShowUsedFiles() );
268             addConfiguration( out, DoxygenParameters.SHOW_DIRECTORIES, isShowDirectories() );
269             addConfiguration( out, DoxygenParameters.SHOW_FILES, isShowFiles() );
270             addConfiguration( out, DoxygenParameters.SHOW_NAMESPACES, isShowNamespaces() );
271             addConfiguration( out, DoxygenParameters.FILE_VERSION_FILTER, getFileVersionFilter() );
272             addConfiguration( out, DoxygenParameters.LAYOUT_FILE, getLayoutFile() );
273             addConfiguration( out, DoxygenParameters.QUIET, isQuiet() );
274             addConfiguration( out, DoxygenParameters.WARNINGS, isWarnings() );
275             addConfiguration( out, DoxygenParameters.WARN_IF_UNDOCUMENTED, isWarnIfUndocumented() );
276             addConfiguration( out, DoxygenParameters.WARN_IF_DOC_ERROR, isWarnIfDocError() );
277             addConfiguration( out, DoxygenParameters.WARN_NO_PARAMDOC, isWarnNoParamdoc() );
278             addConfiguration( out, DoxygenParameters.WARN_FORMAT, getWarnFormat() );
279             addConfiguration( out, DoxygenParameters.WARN_LOGFILE, getWarnLogfile() );
280             addConfiguration( out, DoxygenParameters.INPUT, getInput() );
281             addConfiguration( out, DoxygenParameters.INPUT_ENCODING, getInputEncoding() );
282             addConfiguration( out, DoxygenParameters.FILE_PATTERNS, getFilePatterns() );
283             addConfiguration( out, DoxygenParameters.RECURSIVE, isRecursive() );
284             addConfiguration( out, DoxygenParameters.EXCLUDE, getExclude() );
285             addConfiguration( out, DoxygenParameters.EXCLUDE_SYMLINKS, isExcludeSymlinks() );
286             addConfiguration( out, DoxygenParameters.EXCLUDE_PATTERNS, getExcludePatterns() );
287             addConfiguration( out, DoxygenParameters.EXCLUDE_SYMBOLS, getExcludeSymbols() );
288             addConfiguration( out, DoxygenParameters.EXAMPLE_PATH, getExamplePath() );
289             addConfiguration( out, DoxygenParameters.EXAMPLE_PATTERNS, getExamplePatterns() );
290             addConfiguration( out, DoxygenParameters.EXAMPLE_RECURSIVE, isExampleRecursive() );
291             addConfiguration( out, DoxygenParameters.IMAGE_PATH, getImagePath() );
292             addConfiguration( out, DoxygenParameters.INPUT_FILTER, getInputFilter() );
293             addConfiguration( out, DoxygenParameters.FILTER_PATTERNS, getFilterPatterns() );
294             addConfiguration( out, DoxygenParameters.FILTER_SOURCE_FILES, isFilterSourceFiles() );
295             addConfiguration( out, DoxygenParameters.SOURCE_BROWSER, isSourceBrowser() );
296             addConfiguration( out, DoxygenParameters.INLINE_SOURCES, isInlineSources() );
297             addConfiguration( out, DoxygenParameters.STRIP_CODE_COMMENTS, isStripCodeComments() );
298             addConfiguration( out, DoxygenParameters.REFERENCED_BY_RELATION, isReferencedByRelation() );
299             addConfiguration( out, DoxygenParameters.REFERENCES_RELATION, isReferencesRelation() );
300             addConfiguration( out, DoxygenParameters.REFERENCES_LINK_SOURCE, isReferencesLinkSource() );
301             addConfiguration( out, DoxygenParameters.USE_HTAGS, isUseHtags() );
302             addConfiguration( out, DoxygenParameters.VERBATIM_HEADERS, isVerbatimHeaders() );
303             addConfiguration( out, DoxygenParameters.ALPHABETICAL_INDEX, isAlphabeticalIndex() );
304             addConfiguration( out, DoxygenParameters.COLS_IN_ALPHA_INDEX, getColsInAlphaIndex() );
305             addConfiguration( out, DoxygenParameters.IGNORE_PREFIX, getIgnorePrefix() );
306             addConfiguration( out, DoxygenParameters.GENERATE_HTML, isGenerateHtml() );
307             addConfiguration( out, DoxygenParameters.HTML_OUTPUT, getHtmlOutput() );
308             addConfiguration( out, DoxygenParameters.HTML_FILE_EXTENSION, getHtmlFileExtension() );
309             addConfiguration( out, DoxygenParameters.HTML_HEADER, getHtmlHeader() );
310             addConfiguration( out, DoxygenParameters.HTML_FOOTER, getHtmlFooter() );
311             addConfiguration( out, DoxygenParameters.HTML_STYLESHEET, getHtmlStylesheet() );
312             addConfiguration( out, DoxygenParameters.HTML_ALIGN_MEMBERS, isHtmlAlignMembers() );
313             addConfiguration( out, DoxygenParameters.HTML_DYNAMIC_SECTIONS, isHtmlDynamicSections() );
314             addConfiguration( out, DoxygenParameters.GENERATE_DOCSET, isGenerateDocset() );
315             addConfiguration( out, DoxygenParameters.DOCSET_FEEDNAME, getDocsetFeedname() );
316             addConfiguration( out, DoxygenParameters.DOCSET_BUNDLE_ID, getDocsetBundleId() );
317             addConfiguration( out, DoxygenParameters.GENERATE_HTMLHELP, isGenerateHtmlhelp() );
318             addConfiguration( out, DoxygenParameters.CHM_FILE, getChmFile() );
319             addConfiguration( out, DoxygenParameters.HHC_LOCATION, getHhcLocation() );
320             addConfiguration( out, DoxygenParameters.GENERATE_CHI, isGenerateChi() );
321             addConfiguration( out, DoxygenParameters.CHM_INDEX_ENCODING, getChmIndexEncoding() );
322             addConfiguration( out, DoxygenParameters.BINARY_TOC, isBinaryToc() );
323             addConfiguration( out, DoxygenParameters.TOC_EXPAND, isTocExpand() );
324             addConfiguration( out, DoxygenParameters.GENERATE_QHP, isGenerateQhp() );
325             addConfiguration( out, DoxygenParameters.QCH_FILE, getQchFile() );
326             addConfiguration( out, DoxygenParameters.QHP_NAMESPACE, getQhpNamespace() );
327             addConfiguration( out, DoxygenParameters.QHP_VIRTUAL_FOLDER, getQhpVirtualFolder() );
328             addConfiguration( out, DoxygenParameters.QHG_LOCATION, getQhgLocation() );
329             addConfiguration( out, DoxygenParameters.DISABLE_INDEX, isDisableIndex() );
330             addConfiguration( out, DoxygenParameters.ENUM_VALUES_PER_LINE, getEnumValuesPerLine() );
331             addConfiguration( out, DoxygenParameters.GENERATE_TREEVIEW, getGenerateTreeview() );
332             addConfiguration( out, DoxygenParameters.TREEVIEW_WIDTH, getTreeviewWidth() );
333             addConfiguration( out, DoxygenParameters.FORMULA_FONTSIZE, getFormulaFontsize() );
334             addConfiguration( out, DoxygenParameters.GENERATE_LATEX, isGenerateLatex() );
335             addConfiguration( out, DoxygenParameters.LATEX_OUTPUT, getLatexOutput() );
336             addConfiguration( out, DoxygenParameters.LATEX_CMD_NAME, getLatexCmdName() );
337             addConfiguration( out, DoxygenParameters.MAKEINDEX_CMD_NAME, getMakeindexCmdName() );
338             addConfiguration( out, DoxygenParameters.COMPACT_LATEX, isCompactLatex() );
339             addConfiguration( out, DoxygenParameters.PAPER_TYPE, getPaperType() );
340             addConfiguration( out, DoxygenParameters.EXTRA_PACKAGES, getExtraPackages() );
341             addConfiguration( out, DoxygenParameters.LATEX_HEADER, getLatexHeader() );
342             addConfiguration( out, DoxygenParameters.PDF_HYPERLINKS, isPdfHyperlinks() );
343             addConfiguration( out, DoxygenParameters.USE_PDFLATEX, isUsePdflatex() );
344             addConfiguration( out, DoxygenParameters.LATEX_BATCHMODE, isLatexBatchmode() );
345             addConfiguration( out, DoxygenParameters.LATEX_HIDE_INDICES, isLatexHideIndices() );
346             addConfiguration( out, DoxygenParameters.GENERATE_RTF, isGenerateRtf() );
347             addConfiguration( out, DoxygenParameters.RTF_OUTPUT, getRtfOutput() );
348             addConfiguration( out, DoxygenParameters.COMPACT_RTF, isCompactRtf() );
349             addConfiguration( out, DoxygenParameters.RTF_HYPERLINKS, isRtfHyperlinks() );
350             addConfiguration( out, DoxygenParameters.RTF_STYLESHEET_FILE, getRtfStylesheetFile() );
351             addConfiguration( out, DoxygenParameters.RTF_EXTENSIONS_FILE, getRtfExtensionsFile() );
352             addConfiguration( out, DoxygenParameters.GENERATE_MAN, isGenerateMan() );
353             addConfiguration( out, DoxygenParameters.MAN_OUTPUT, getManOutput() );
354             addConfiguration( out, DoxygenParameters.MAN_EXTENSION, getManExtension() );
355             addConfiguration( out, DoxygenParameters.MAN_LINKS, isManLinks() );
356             addConfiguration( out, DoxygenParameters.GENERATE_XML, isGenerateXml() );
357             addConfiguration( out, DoxygenParameters.XML_OUTPUT, getXmlOutput() );
358             addConfiguration( out, DoxygenParameters.XML_SCHEMA, getXmlSchema() );
359             addConfiguration( out, DoxygenParameters.XML_DTD, getXmlDtd() );
360             addConfiguration( out, DoxygenParameters.XML_PROGRAMLISTING, isXmlProgramlisting() );
361             addConfiguration( out, DoxygenParameters.GENERATE_AUTOGEN_DEF, isGenerateAutogenDef() );
362             addConfiguration( out, DoxygenParameters.GENERATE_PERLMOD, isGeneratePerlmod() );
363             addConfiguration( out, DoxygenParameters.PERLMOD_LATEX, isPerlmodLatex() );
364             addConfiguration( out, DoxygenParameters.PERLMOD_PRETTY, isPerlmodPretty() );
365             addConfiguration( out, DoxygenParameters.PERLMOD_MAKEVAR_PREFIX, getPerlmodMakevarPrefix() );
366             addConfiguration( out, DoxygenParameters.ENABLE_PREPROCESSING, isEnablePreprocessing() );
367             addConfiguration( out, DoxygenParameters.MACRO_EXPANSION, isMacroExpansion() );
368             addConfiguration( out, DoxygenParameters.EXPAND_ONLY_PREDEF, isExpandOnlyPredef() );
369             addConfiguration( out, DoxygenParameters.SEARCH_INCLUDES, isSearchIncludes() );
370             addConfiguration( out, DoxygenParameters.INCLUDE_PATH, getIncludePath() );
371             addConfiguration( out, DoxygenParameters.INCLUDE_FILE_PATTERNS, getIncludeFilePatterns() );
372             addConfiguration( out, DoxygenParameters.PREDEFINED, getPredefined() );
373             addConfiguration( out, DoxygenParameters.EXPAND_AS_DEFINED, getExpandAsDefined() );
374             addConfiguration( out, DoxygenParameters.SKIP_FUNCTION_MACROS, isSkipFunctionMacros() );
375             addConfiguration( out, DoxygenParameters.TAGFILES, getTagfiles() );
376             addConfiguration( out, DoxygenParameters.GENERATE_TAGFILE, getGenerateTagfile() );
377             addConfiguration( out, DoxygenParameters.ALLEXTERNALS, isAllexternals() );
378             addConfiguration( out, DoxygenParameters.EXTERNAL_GROUPS, isExternalGroups() );
379             addConfiguration( out, DoxygenParameters.PERL_PATH, getPerlPath() );
380             addConfiguration( out, DoxygenParameters.CLASS_DIAGRAMS, isClassDiagrams() );
381             addConfiguration( out, DoxygenParameters.MSCGEN_PATH, getMscgenPath() );
382             addConfiguration( out, DoxygenParameters.HIDE_UNDOC_RELATIONS, isHideUndocRelations() );
383             addConfiguration( out, DoxygenParameters.HAVE_DOT, isHaveDot() );
384             addConfiguration( out, DoxygenParameters.DOT_FONTNAME, getDotFontname() );
385             addConfiguration( out, DoxygenParameters.DOT_FONTSIZE, getDotFontsize() );
386             addConfiguration( out, DoxygenParameters.DOT_FONTPATH, getDotFontpath() );
387             addConfiguration( out, DoxygenParameters.CLASS_GRAPH, isClassGraph() );
388             addConfiguration( out, DoxygenParameters.COLLABORATION_GRAPH, isCollaborationGraph() );
389             addConfiguration( out, DoxygenParameters.GROUP_GRAPHS, isGroupGraphs() );
390             addConfiguration( out, DoxygenParameters.UML_LOOK, isUmlLook() );
391             addConfiguration( out, DoxygenParameters.TEMPLATE_RELATIONS, isTemplateRelations() );
392             addConfiguration( out, DoxygenParameters.INCLUDE_GRAPH, isIncludeGraph() );
393             addConfiguration( out, DoxygenParameters.INCLUDED_BY_GRAPH, isIncludedByGraph() );
394             addConfiguration( out, DoxygenParameters.CALL_GRAPH, isCallGraph() );
395             addConfiguration( out, DoxygenParameters.CALLER_GRAPH, isCallerGraph() );
396             addConfiguration( out, DoxygenParameters.GRAPHICAL_HIERARCHY, isGraphicalHierarchy() );
397             addConfiguration( out, DoxygenParameters.DIRECTORY_GRAPH, isDirectoryGraph() );
398             addConfiguration( out, DoxygenParameters.DOT_IMAGE_FORMAT, getDotImageFormat() );
399             addConfiguration( out, DoxygenParameters.DOT_PATH, getDotPath() );
400             addConfiguration( out, DoxygenParameters.DOTFILE_DIRS, getDotfileDirs() );
401             addConfiguration( out, DoxygenParameters.DOT_GRAPH_MAX_NODES, getDotGraphMaxNodes() );
402             addConfiguration( out, DoxygenParameters.MAX_DOT_GRAPH_DEPTH, getMaxDotGraphDepth() );
403             addConfiguration( out, DoxygenParameters.DOT_TRANSPARENT, isDotTransparent() );
404             addConfiguration( out, DoxygenParameters.DOT_MULTI_TARGETS, isDotMultiTargets() );
405             addConfiguration( out, DoxygenParameters.GENERATE_LEGEND, isGenerateLegend() );
406             addConfiguration( out, DoxygenParameters.DOT_CLEANUP, isDotCleanup() );
407             addConfiguration( out, DoxygenParameters.SEARCHENGINE, isSearchengine() );
408 
409         }
410         catch ( IOException ex )
411         {
412             throw new MavenReportException( "Error creating Doxygen configuration file '" + config.getAbsolutePath()
413                 + "'.", ex );
414         }
415         finally
416         {
417             if ( out != null )
418             {
419                 out.close();
420             }
421         }
422     }
423 
424     /**
425      * This is called for boolean configuration items.
426      * 
427      * @param config The configuration where to write to.
428      * @param key The configuration parameter name with it's default values etc.
429      * @param value The reals value, base on the Plugin configuration.
430      */
431     private void addConfiguration( PrintWriter config, DoxygenParameters key, boolean value )
432     {
433         if ( value )
434         {
435             addConfiguration( config, key, "YES" );
436         }
437         else
438         {
439             addConfiguration( config, key, "NO" );
440         }
441     }
442 
443     /**
444      * This is called for integer configuration items.
445      * 
446      * @param config The configuration where to write to.
447      * @param key The configuration parameter name with it's default values etc.
448      * @param value The reals value, base on the Plugin configuration.
449      */
450     private void addConfiguration( PrintWriter config, DoxygenParameters key, Integer value )
451     {
452         if ( value == null )
453         {
454             value = Integer.parseInt( key.getDefaultValue() );
455         }
456         addConfiguration( config, key, value.toString() );
457     }
458 
459     /**
460      * This is called for String configuration items.
461      * 
462      * @param config The configuration where to write to.
463      * @param key The configuration parameter name with it's default values etc.
464      * @param value The reals value, base on the Plugin configuration.
465      */
466     private void addConfiguration( PrintWriter config, DoxygenParameters key, String value )
467     {
468         if ( value == null )
469         {
470             value = key.getDefaultValue();
471         }
472         else if ( ( value.length() == 0 ) || ( value.trim().length() == 0 ) )
473         {
474             value = key.getDefaultValue();
475         }
476 
477         // If we have quoted parameters.
478         if ( key.getType().equals( DoxygenParameterType.STRING_QUOTED ) )
479         {
480             value = '"' + value + '"';
481         }
482 
483         addConfiguration( config, key.getDescription(), key.name(), value );
484     }
485 
486     /**
487      * This will write all kind of configuration items into the configuration file and will format the file.
488      * 
489      * @param config The output file.
490      * @param desc The description of the item.
491      * @param key The name of the item
492      * @param value The value of the item.
493      */
494     private void addConfiguration( PrintWriter config, String desc, String key, String value )
495     {
496         // Description first.
497         config.print( desc );
498         config.println();
499         config.printf( "%-22s", key );
500         config.print( " = " );
501         if ( value != null )
502         {
503             config.println( value );
504         }
505         else
506         {
507             config.println();
508         }
509         config.println();
510     }
511 
512     /**
513      * @param unusedLocale the wanted locale (actually unused).
514      * @throws MavenReportException if any
515      */
516     protected void executeReport( Locale unusedLocale )
517         throws MavenReportException
518     {
519 
520         File config = buildConfigurationFile();
521 
522         Commandline cli = new Commandline();
523         cli.setWorkingDirectory( getBasedir().getAbsolutePath() );
524         cli.setExecutable( getExecutablePath() );
525         cli.createArgument().setValue( config.getAbsolutePath() );
526 
527         Writer stringWriter = new StringWriter();
528         StreamConsumer out = new WriterStreamConsumer( stringWriter );
529         StreamConsumer err = new WriterStreamConsumer( stringWriter );
530 
531         try
532         {
533             int returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
534 
535             if ( !isQuiet() )
536             {
537                 // Get all output from doxygen and put it to the log out of Maven.
538                 String[] lines = stringWriter.toString().split( "\n" );
539                 for ( int i = 0; i < lines.length; i++ )
540                 {
541                     lines[i] = lines[i].replaceAll( "\n|\r", "" );
542                     getLog().info( "doxygen: " + lines[i] );
543                 }
544             }
545 
546             if ( returnCode != 0 )
547             {
548                 throw new MavenReportException( "Failed to generate Doxygen documentation." );
549             }
550 
551         }
552         catch ( CommandLineException ex )
553         {
554             throw new MavenReportException( "Error while executing Doxygen.", ex );
555         }
556 
557     }
558 
559     public void setBasedir( File basedir )
560     {
561         this.basedir = basedir;
562     }
563 
564     public File getBasedir()
565     {
566         return basedir;
567     }
568 
569     public void setOutputDirectory( File outputDirectory )
570     {
571         this.outputDirectory = outputDirectory;
572     }
573 
574     public boolean isSkip()
575     {
576         return skip;
577     }
578 
579     public void setSkip( boolean skip )
580     {
581         this.skip = skip;
582     }
583 
584 }