Coverage Report - org.apache.maven.model.converter.plugins.PCCJavadoc
 
Classes in this File Line Coverage Branch Coverage Complexity
PCCJavadoc
97%
69/71
74%
25/34
5,667
 
 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  4
 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  0
         return "maven-javadoc-plugin";
 45  
     }
 46  
 
 47  
     public String getType()
 48  
     {
 49  0
         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  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.additionalparam", "additionalparam" );
 57  
 
 58  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.author", "author" );
 59  
 
 60  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.bottom", "bottom" );
 61  
 
 62  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.destdir", "destDir" );
 63  
 
 64  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.doclet", "doclet" );
 65  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.docletpath", "docletPath" );
 66  
 
 67  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "doctitle" );
 68  
 
 69  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.excludepackagenames",
 70  
                                "excludePackageNames" );
 71  
 
 72  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.footer", "footer" );
 73  
 
 74  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.header", "header" );
 75  
 
 76  4
         String online = projectProperties.getProperty( "maven.javadoc.mode.online" );
 77  4
         if ( online != null )
 78  
         {
 79  2
             addConfigurationChild( configuration, "isOffline", PropertyUtils.invertBoolean( online ) );
 80  
         }
 81  
 
 82  4
         String links = projectProperties.getProperty( "maven.javadoc.links" );
 83  4
         if ( links != null )
 84  
         {
 85  2
             StringTokenizer tokenizer = new StringTokenizer( links, " ," );
 86  2
             if ( tokenizer.hasMoreTokens() )
 87  
             {
 88  2
                 Xpp3Dom linksConfiguration = new Xpp3Dom( "links" );
 89  6
                 while ( tokenizer.hasMoreTokens() )
 90  
                 {
 91  4
                     String link = tokenizer.nextToken();
 92  4
                     addConfigurationChild( linksConfiguration, "link", link );
 93  
                 }
 94  2
                 configuration.addChild( linksConfiguration );
 95  
             }
 96  
         }
 97  
 
 98  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.locale", "locale" );
 99  
 
 100  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.maxmemory", "maxmemory" );
 101  
 
 102  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.offlineLinks", "offlineLinks" );
 103  
 
 104  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.overview", "overview" );
 105  
 
 106  4
         String show = projectProperties.getProperty( "maven.javadoc.private" );
 107  4
         if ( show != null && Boolean.valueOf( show ).booleanValue() )
 108  
         {
 109  1
             addConfigurationChild( configuration, "show", "private" );
 110  
         }
 111  
         else
 112  
         {
 113  3
             show = projectProperties.getProperty( "maven.javadoc.package" );
 114  3
             if ( show != null && Boolean.valueOf( show ).booleanValue() )
 115  
             {
 116  2
                 addConfigurationChild( configuration, "show", "package" );
 117  
             }
 118  
             else
 119  
             {
 120  1
                 show = projectProperties.getProperty( "maven.javadoc.public" );
 121  1
                 if ( show != null && Boolean.valueOf( show ).booleanValue() )
 122  
                 {
 123  1
                     addConfigurationChild( configuration, "show", "public" );
 124  
                 }
 125  
             }
 126  
         }
 127  
 
 128  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.source", "source" );
 129  
 
 130  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.stylesheet", "stylesheetfile" );
 131  
 
 132  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.taglets", "taglet" );
 133  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.tagletpath", "tagletpath" );
 134  
 
 135  4
         String customtags = projectProperties.getProperty( "maven.javadoc.customtags" );
 136  4
         if ( customtags != null )
 137  
         {
 138  2
             StringTokenizer tokenizer = new StringTokenizer( customtags );
 139  2
             if ( tokenizer.hasMoreTokens() )
 140  
             {
 141  2
                 Xpp3Dom tagsConfiguration = new Xpp3Dom( "tags" );
 142  6
                 while ( tokenizer.hasMoreTokens() )
 143  
                 {
 144  4
                     String tag = tokenizer.nextToken();
 145  4
                     Xpp3Dom tagConfiguration = new Xpp3Dom( "tag" );
 146  4
                     addConfigurationChild( tagConfiguration, projectProperties, tag + ".description", "head" );
 147  4
                     addConfigurationChild( tagConfiguration, projectProperties, tag + ".name", "name" );
 148  4
                     String placement = "";
 149  4
                     String enabled = projectProperties.getProperty( tag + ".enabled" );
 150  4
                     if ( !Boolean.valueOf( enabled ).booleanValue() )
 151  
                     {
 152  2
                         placement = "X";
 153  
                     }
 154  4
                     String scope = projectProperties.getProperty( tag + ".scope" );
 155  4
                     if ( "all".equals( scope ) )
 156  
                     {
 157  4
                         placement += "a";
 158  
                     }
 159  4
                     if ( placement.length() > 0 )
 160  
                     {
 161  4
                         addConfigurationChild( tagConfiguration, "placement", placement );
 162  
                     }
 163  4
                     tagsConfiguration.addChild( tagConfiguration );
 164  
                 }
 165  2
                 configuration.addChild( tagsConfiguration );
 166  
             }
 167  
         }
 168  
 
 169  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.use", "use" );
 170  
 
 171  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.version", "version" );
 172  
 
 173  4
         addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "windowtitle" );
 174  
 
 175  
         // Only add these if we have any other configuration for the javadoc-plugin
 176  4
         if ( configuration.getChildCount() > 0 )
 177  
         {
 178  
             // The Maven 1 plugin uses the same outputencoding as the generated documentation.
 179  4
             addConfigurationChild( configuration, projectProperties, "maven.docs.outputencoding", "docencoding" );
 180  
 
 181  
             // The Maven 1 plugin uses the same encoding as the compile plugin.
 182  4
             addConfigurationChild( configuration, projectProperties, "maven.compile.encoding", "encoding" );
 183  
 
 184  
             // The Maven 1 plugin uses the same package as the pom.
 185  4
             addConfigurationChild( configuration, projectProperties, "pom.package", "subpackages" );
 186  
         }
 187  4
     }
 188  
 }