Author: dennisl Date: Fri Jun 16 14:35:57 2006 New Revision: 414930 URL: http://svn.apache.org/viewvc?rev=414930&view=rev Log: Add PluginConfigurationConverter for maven-javadoc-plugin
Added: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java (with props) maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java (with props) maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties (with props) maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties (with props) maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties (with props) Modified: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java Modified: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java?rev=414930&r1=414929&r2=414930&view=diff ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java (original) +++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java Fri Jun 16 14:35:57 2006 @@ -27,6 +27,7 @@ import org.apache.maven.maven1converter.plugins.PCCCompiler; import org.apache.maven.maven1converter.plugins.PCCJar; +import org.apache.maven.maven1converter.plugins.PCCJavadoc; import org.apache.maven.maven1converter.plugins.PCCMultiproject; import org.apache.maven.maven1converter.plugins.PCCSurefire; import org.apache.maven.maven1converter.plugins.PCCWar; @@ -69,8 +70,9 @@ private PluginConfigurationConverter[] converters = new PluginConfigurationConverter[] { new PCCCompiler(), new PCCJar(), - new PCCSurefire(), + new PCCJavadoc(), new PCCMultiproject(), + new PCCSurefire(), new PCCWar() }; /** Added: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java?rev=414930&view=auto ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java (added) +++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java Fri Jun 16 14:35:57 2006 @@ -0,0 +1,167 @@ +package org.apache.maven.maven1converter.plugins; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.apache.maven.plugin.MojoExecutionException; + +import java.util.Properties; +import java.util.StringTokenizer; + +/** + * A <code>PluginConfigurationConverter</code> for the maven-javadoc-plugin. + * + * @author Dennis Lundberg + * @version $Id: PCCJavadoc.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $ + */ +public class PCCJavadoc extends AbstractPluginConfigurationConverter +{ + /** + * @see org.apache.maven.maven1converter.plugins.AbstractPluginConfigurationConverter#getArtifactId() + */ + public String getArtifactId() + { + return "maven-javadoc-plugin"; + } + + public String getType() + { + return TYPE_BUILD_PLUGIN; + } + + protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model, + Properties projectProperties ) + throws MojoExecutionException + { + addConfigurationChild( configuration, projectProperties, "maven.javadoc.additionalparam", "additionalparam" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.author", "author" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.bottom", "bottom" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.destdir", "destDir" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.doclet", "doclet" ); + addConfigurationChild( configuration, projectProperties, "maven.javadoc.docletpath", "docletPath" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "doctitle" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.excludepackagenames", + "excludePackageNames" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.footer", "footer" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.header", "header" ); + + String online = projectProperties.getProperty( "maven.javadoc.mode.online" ); + if ( online != null ) + { + addConfigurationChild( configuration, "isOffline", PropertyUtils.invertBoolean( online ) ); + } + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.links", "links" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.locale", "locale" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.maxmemory", "maxmemory" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.offlineLinks", "offlineLinks" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.overview", "overview" ); + + String show = projectProperties.getProperty( "maven.javadoc.private" ); + if ( show != null && Boolean.valueOf( show ).booleanValue() ) + { + addConfigurationChild( configuration, "show", "private" ); + } + else + { + show = projectProperties.getProperty( "maven.javadoc.package" ); + if ( show != null && Boolean.valueOf( show ).booleanValue() ) + { + addConfigurationChild( configuration, "show", "package" ); + } + else + { + show = projectProperties.getProperty( "maven.javadoc.public" ); + if ( show != null && Boolean.valueOf( show ).booleanValue() ) + { + addConfigurationChild( configuration, "show", "public" ); + } + } + } + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.source", "source" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.stylesheet", "stylesheetfile" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.taglets", "taglet" ); + addConfigurationChild( configuration, projectProperties, "maven.javadoc.tagletpath", "tagletpath" ); + + String customtags = projectProperties.getProperty( "maven.javadoc.customtags" ); + if ( customtags != null ) + { + StringTokenizer tokenizer = new StringTokenizer( customtags ); + if ( tokenizer.hasMoreTokens() ) + { + Xpp3Dom tagsConfiguration = new Xpp3Dom( "tags" ); + while ( tokenizer.hasMoreTokens() ) + { + String tag = tokenizer.nextToken(); + Xpp3Dom tagConfiguration = new Xpp3Dom( "tag" ); + addConfigurationChild( tagConfiguration, projectProperties, tag + ".description", "head" ); + addConfigurationChild( tagConfiguration, projectProperties, tag + ".name", "name" ); + String placement = ""; + String enabled = projectProperties.getProperty( tag + ".enabled" ); + if ( !Boolean.valueOf( enabled ).booleanValue() ) + { + placement = "X"; + } + String scope = projectProperties.getProperty( tag + ".scope" ); + if ( "all".equals( scope ) ) + { + placement += "a"; + } + if ( placement.length() > 0 ) + { + addConfigurationChild( tagConfiguration, "placement", placement ); + } + tagsConfiguration.addChild( tagConfiguration ); + } + configuration.addChild( tagsConfiguration ); + } + } + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.use", "use" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.version", "version" ); + + addConfigurationChild( configuration, projectProperties, "maven.javadoc.windowtitle", "windowtitle" ); + + // Only add these if we have any other configuration for the javadoc-plugin + if(configuration.getChildCount() > 0) { + // The Maven 1 plugin uses the same outputencoding as the generated documentation. + addConfigurationChild( configuration, projectProperties, "maven.docs.outputencoding", "docencoding" ); + + // The Maven 1 plugin uses the same encoding as the compile plugin. + addConfigurationChild( configuration, projectProperties, "maven.compile.encoding", "encoding" ); + + // The Maven 1 plugin uses the same package as the pom. + addConfigurationChild( configuration, projectProperties, "pom.package", "subpackages" ); + } + } +} Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJavadoc.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java?rev=414930&view=auto ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java (added) +++ maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java Fri Jun 16 14:35:57 2006 @@ -0,0 +1,227 @@ +package org.apache.maven.maven1converter.plugins; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import junit.framework.Assert; +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +import java.io.IOException; + +/** + * @author Dennis Lundberg + * @version $Id: PCCJavadocTest.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $ + */ +public class PCCJavadocTest extends AbstractPCCTest +{ + protected void setUp() + throws Exception + { + super.setUp(); + + pluginConfigurationConverter = new PCCJavadoc(); + } + + public void testBuildConfiguration() + { + try + { + projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest1.properties" ) ); + + pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties ); + + String value = configuration.getChild( "additionalparam" ).getValue(); + Assert.assertEquals( "check additionalparam value", "-J-showversion", value ); + + value = configuration.getChild( "author" ).getValue(); + Assert.assertEquals( "check author value", "false", value ); + + value = configuration.getChild( "bottom" ).getValue(); + Assert.assertEquals( "check bottom value", "Copyright", value ); + + value = configuration.getChild( "destDir" ).getValue(); + Assert.assertEquals( "check destDir value", "apidocs", value ); + + value = configuration.getChild( "docencoding" ).getValue(); + Assert.assertEquals( "check docencoding value", "UTF-8", value ); + + value = configuration.getChild( "doclet" ).getValue(); + Assert.assertEquals( "check doclet value", "org.apache.MyDoclet", value ); + + value = configuration.getChild( "docletPath" ).getValue(); + Assert.assertEquals( "check docletPath value", "/path/to/doclet", value ); + + value = configuration.getChild( "doctitle" ).getValue(); + Assert.assertEquals( "check doctitle value", "The title", value ); + + value = configuration.getChild( "encoding" ).getValue(); + Assert.assertEquals( "check encoding value", "ISO-8859-1", value ); + + value = configuration.getChild( "excludePackageNames" ).getValue(); + Assert.assertEquals( "check excludePackageNames value", "org.apache.internal,org.apache.test", value ); + + value = configuration.getChild( "footer" ).getValue(); + Assert.assertEquals( "check footer value", "The footer", value ); + + value = configuration.getChild( "header" ).getValue(); + Assert.assertEquals( "check header value", "The header", value ); + + value = configuration.getChild( "isOffline" ).getValue(); + Assert.assertEquals( "check isOffline value", "false", value ); + + value = configuration.getChild( "links" ).getValue(); + Assert.assertEquals( "check links value", "http://java.sun.com/j2se/1.4/docs/api/", value ); + + value = configuration.getChild( "locale" ).getValue(); + Assert.assertEquals( "check locale value", "en_US", value ); + + value = configuration.getChild( "maxmemory" ).getValue(); + Assert.assertEquals( "check maxmemory value", "1024m", value ); + + value = configuration.getChild( "offlineLinks" ).getValue(); + Assert.assertEquals( "check offlineLinks value", "/opt/java-apidoc/j2sdk1.4.2/docs/api/", value ); + + value = configuration.getChild( "overview" ).getValue(); + Assert.assertEquals( "check overview value", "src/main/java/org/apache/overview.html", value ); + + value = configuration.getChild( "source" ).getValue(); + Assert.assertEquals( "check source value", "1.3", value ); + + value = configuration.getChild( "stylesheetfile" ).getValue(); + Assert.assertEquals( "check stylesheetfile value", "myStylesheet.css", value ); + + value = configuration.getChild( "subpackages" ).getValue(); + Assert.assertEquals( "check subpackages value", "org.apache.maven", value ); + + value = configuration.getChild( "taglet" ).getValue(); + Assert.assertEquals( "check taglet value", "org.apache.MyTaglet", value ); + + value = configuration.getChild( "tagletpath" ).getValue(); + Assert.assertEquals( "check tagletpath value", "/path/to/taglet", value ); + + Xpp3Dom tags = configuration.getChild( "tags" ); + if ( tags.getChildCount() == 2 ) + { + Xpp3Dom tagOne = tags.getChild( 0 ); + + value = tagOne.getChild( "head" ).getValue(); + Assert.assertEquals( "check tags/tag/head value", "To Do:", value ); + + value = tagOne.getChild( "name" ).getValue(); + Assert.assertEquals( "check tags/tag/name value", "todo", value ); + + value = tagOne.getChild( "placement" ).getValue(); + Assert.assertEquals( "check tags/tag/placement value", "a", value ); + + Xpp3Dom tagTwo = tags.getChild( 1 ); + + value = tagTwo.getChild( "head" ).getValue(); + Assert.assertEquals( "check tags/tag/head value", "Task:", value ); + + value = tagTwo.getChild( "name" ).getValue(); + Assert.assertEquals( "check tags/tag/name value", "task", value ); + + value = tagTwo.getChild( "placement" ).getValue(); + Assert.assertEquals( "check tags/tag/placement value", "Xa", value ); + } + else + { + Assert.fail( "Wrong number of tag elements" ); + } + + value = configuration.getChild( "use" ).getValue(); + Assert.assertEquals( "check use value", "true", value ); + + value = configuration.getChild( "version" ).getValue(); + Assert.assertEquals( "check version value", "true", value ); + + value = configuration.getChild( "windowtitle" ).getValue(); + Assert.assertEquals( "check windowtitle value", "The title", value ); + } + catch ( MojoExecutionException e ) + { + Assert.fail( e.getMessage() ); + } + catch ( IOException e ) + { + Assert.fail( "Unable to find the requested resource." ); + } + } + + public void testBuildConfigurationShow1() + { + try + { + projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest1.properties" ) ); + + pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties ); + + String value = configuration.getChild( "show" ).getValue(); + Assert.assertEquals( "check show value", "package", value ); + } + catch ( MojoExecutionException e ) + { + Assert.fail( e.getMessage() ); + } + catch ( IOException e ) + { + Assert.fail( "Unable to find the requested resource." ); + } + } + + public void testBuildConfigurationShow2() + { + try + { + projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest2.properties" ) ); + + pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties ); + + String value = configuration.getChild( "show" ).getValue(); + Assert.assertEquals( "check show value", "private", value ); + } + catch ( MojoExecutionException e ) + { + Assert.fail( e.getMessage() ); + } + catch ( IOException e ) + { + Assert.fail( "Unable to find the requested resource." ); + } + } + + public void testBuildConfigurationShow3() + { + try + { + projectProperties.load( getClassLoader().getResourceAsStream( "PCCJavadocTest3.properties" ) ); + + pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties ); + + String value = configuration.getChild( "show" ).getValue(); + Assert.assertEquals( "check show value", "public", value ); + } + catch ( MojoExecutionException e ) + { + Assert.fail( e.getMessage() ); + } + catch ( IOException e ) + { + Assert.fail( "Unable to find the requested resource." ); + } + } +} Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJavadocTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties?rev=414930&view=auto ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties (added) +++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties Fri Jun 16 14:35:57 2006 @@ -0,0 +1,57 @@ +# Copyright 2006 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +maven.compile.encoding=ISO-8859-1 + +maven.docs.outputencoding=UTF-8 + +maven.javadoc.additionalparam=-J-showversion +maven.javadoc.author=false +maven.javadoc.bottom=Copyright + +maven.javadoc.customtags=tag1 tag2 +tag1.name=todo +tag1.description=To Do: +tag1.enabled=true +tag1.scope=all + +tag2.name=task +tag2.description=Task: +tag2.enabled=false +tag2.scope=all + +maven.javadoc.destdir=apidocs +maven.javadoc.doclet=org.apache.MyDoclet +maven.javadoc.docletpath=/path/to/doclet +maven.javadoc.excludepackagenames=org.apache.internal,org.apache.test +maven.javadoc.footer=The footer +maven.javadoc.header=The header +maven.javadoc.links=http://java.sun.com/j2se/1.4/docs/api/ +maven.javadoc.locale=en_US +maven.javadoc.maxmemory=1024m +maven.javadoc.mode.online=true +maven.javadoc.offlineLinks=/opt/java-apidoc/j2sdk1.4.2/docs/api/ +maven.javadoc.overview=src/main/java/org/apache/overview.html +maven.javadoc.package=true +maven.javadoc.private=false +maven.javadoc.public=false +maven.javadoc.source=1.3 +maven.javadoc.stylesheet=myStylesheet.css +maven.javadoc.taglets=org.apache.MyTaglet +maven.javadoc.tagletpath=/path/to/taglet +maven.javadoc.use=true +maven.javadoc.version=true +maven.javadoc.windowtitle=The title + +pom.package=org.apache.maven Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest1.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties?rev=414930&view=auto ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties (added) +++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties Fri Jun 16 14:35:57 2006 @@ -0,0 +1,17 @@ +# Copyright 2006 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +maven.javadoc.package=false +maven.javadoc.private=true +maven.javadoc.public=false Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest2.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties?rev=414930&view=auto ============================================================================== --- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties (added) +++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties Fri Jun 16 14:35:57 2006 @@ -0,0 +1,17 @@ +# Copyright 2006 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +maven.javadoc.package=false +maven.javadoc.private=false +maven.javadoc.public=true Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJavadocTest3.properties ------------------------------------------------------------------------------ svn:eol-style = native