View Javadoc

1   package org.apache.maven.model.converter.plugins;
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 org.apache.maven.model.converter.ProjectConverterException;
23  import org.codehaus.plexus.util.xml.Xpp3Dom;
24  
25  import java.util.Properties;
26  import java.util.StringTokenizer;
27  
28  /**
29   * A <code>PluginConfigurationConverter</code> for the maven-javadoc-plugin.
30   *
31   * @plexus.component role="org.apache.maven.model.converter.plugins.PluginConfigurationConverter" role-hint="javadoc"
32   *
33   * @author Dennis Lundberg
34   * @version $Id: PCCJavadoc.java 661727 2008-05-30 14:21:49Z bentmann $
35   */
36  public class PCCJavadoc
37      extends AbstractPluginConfigurationConverter
38  {
39      /**
40       * @see org.apache.maven.model.converter.plugins.AbstractPluginConfigurationConverter#getArtifactId()
41       */
42      public String getArtifactId()
43      {
44          return "maven-javadoc-plugin";
45      }
46  
47      public String getType()
48      {
49          return TYPE_REPORT_PLUGIN;
50      }
51  
52      protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model,
53                                         Properties projectProperties )
54          throws ProjectConverterException
55      {
56          addConfigurationChild( configuration, projectProperties, "maven.javadoc.additionalparam", "additionalparam" );
57  
58          addConfigurationChild( configuration, projectProperties, "maven.javadoc.author", "author" );
59  
60          addConfigurationChild( configuration, projectProperties, "maven.javadoc.bottom", "bottom" );
61  
62          addConfigurationChild( configuration, projectProperties, "maven.javadoc.destdir", "destDir" );
63  
64          addConfigurationChild( configuration, projectProperties, "maven.javadoc.doclet", "doclet" );
65          addConfigurationChild( configuration, projectProperties, "maven.javadoc.docletpath", "docletPath" );
66  
67          addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "doctitle" );
68  
69          addConfigurationChild( configuration, projectProperties, "maven.javadoc.excludepackagenames",
70                                 "excludePackageNames" );
71  
72          addConfigurationChild( configuration, projectProperties, "maven.javadoc.footer", "footer" );
73  
74          addConfigurationChild( configuration, projectProperties, "maven.javadoc.header", "header" );
75  
76          String online = projectProperties.getProperty( "maven.javadoc.mode.online" );
77          if ( online != null )
78          {
79              addConfigurationChild( configuration, "isOffline", PropertyUtils.invertBoolean( online ) );
80          }
81  
82          String links = projectProperties.getProperty( "maven.javadoc.links" );
83          if ( links != null )
84          {
85              StringTokenizer tokenizer = new StringTokenizer( links, " ," );
86              if ( tokenizer.hasMoreTokens() )
87              {
88                  Xpp3Dom linksConfiguration = new Xpp3Dom( "links" );
89                  while ( tokenizer.hasMoreTokens() )
90                  {
91                      String link = tokenizer.nextToken();
92                      addConfigurationChild( linksConfiguration, "link", link );
93                  }
94                  configuration.addChild( linksConfiguration );
95              }
96          }
97  
98          addConfigurationChild( configuration, projectProperties, "maven.javadoc.locale", "locale" );
99  
100         addConfigurationChild( configuration, projectProperties, "maven.javadoc.maxmemory", "maxmemory" );
101 
102         addConfigurationChild( configuration, projectProperties, "maven.javadoc.offlineLinks", "offlineLinks" );
103 
104         addConfigurationChild( configuration, projectProperties, "maven.javadoc.overview", "overview" );
105 
106         String show = projectProperties.getProperty( "maven.javadoc.private" );
107         if ( show != null && Boolean.valueOf( show ).booleanValue() )
108         {
109             addConfigurationChild( configuration, "show", "private" );
110         }
111         else
112         {
113             show = projectProperties.getProperty( "maven.javadoc.package" );
114             if ( show != null && Boolean.valueOf( show ).booleanValue() )
115             {
116                 addConfigurationChild( configuration, "show", "package" );
117             }
118             else
119             {
120                 show = projectProperties.getProperty( "maven.javadoc.public" );
121                 if ( show != null && Boolean.valueOf( show ).booleanValue() )
122                 {
123                     addConfigurationChild( configuration, "show", "public" );
124                 }
125             }
126         }
127 
128         addConfigurationChild( configuration, projectProperties, "maven.javadoc.source", "source" );
129 
130         addConfigurationChild( configuration, projectProperties, "maven.javadoc.stylesheet", "stylesheetfile" );
131 
132         addConfigurationChild( configuration, projectProperties, "maven.javadoc.taglets", "taglet" );
133         addConfigurationChild( configuration, projectProperties, "maven.javadoc.tagletpath", "tagletpath" );
134 
135         String customtags = projectProperties.getProperty( "maven.javadoc.customtags" );
136         if ( customtags != null )
137         {
138             StringTokenizer tokenizer = new StringTokenizer( customtags );
139             if ( tokenizer.hasMoreTokens() )
140             {
141                 Xpp3Dom tagsConfiguration = new Xpp3Dom( "tags" );
142                 while ( tokenizer.hasMoreTokens() )
143                 {
144                     String tag = tokenizer.nextToken();
145                     Xpp3Dom tagConfiguration = new Xpp3Dom( "tag" );
146                     addConfigurationChild( tagConfiguration, projectProperties, tag + ".description", "head" );
147                     addConfigurationChild( tagConfiguration, projectProperties, tag + ".name", "name" );
148                     String placement = "";
149                     String enabled = projectProperties.getProperty( tag + ".enabled" );
150                     if ( !Boolean.valueOf( enabled ).booleanValue() )
151                     {
152                         placement = "X";
153                     }
154                     String scope = projectProperties.getProperty( tag + ".scope" );
155                     if ( "all".equals( scope ) )
156                     {
157                         placement += "a";
158                     }
159                     if ( placement.length() > 0 )
160                     {
161                         addConfigurationChild( tagConfiguration, "placement", placement );
162                     }
163                     tagsConfiguration.addChild( tagConfiguration );
164                 }
165                 configuration.addChild( tagsConfiguration );
166             }
167         }
168 
169         addConfigurationChild( configuration, projectProperties, "maven.javadoc.use", "use" );
170 
171         addConfigurationChild( configuration, projectProperties, "maven.javadoc.version", "version" );
172 
173         addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "windowtitle" );
174 
175         // Only add these if we have any other configuration for the javadoc-plugin
176         if ( configuration.getChildCount() > 0 )
177         {
178             // The Maven 1 plugin uses the same outputencoding as the generated documentation.
179             addConfigurationChild( configuration, projectProperties, "maven.docs.outputencoding", "docencoding" );
180 
181             // The Maven 1 plugin uses the same encoding as the compile plugin.
182             addConfigurationChild( configuration, projectProperties, "maven.compile.encoding", "encoding" );
183 
184             // The Maven 1 plugin uses the same package as the pom.
185             addConfigurationChild( configuration, projectProperties, "pom.package", "subpackages" );
186         }
187     }
188 }