evenisse 2003/10/21 08:04:59 Modified: src/plugins-build/jellydoc plugin.jelly project.xml src/plugins-build/jellydoc/src/main/org/apache/maven/jellydoc TagXMLDoclet.java XMLDoclet.java src/plugins-build/jellydoc/xdocs changes.xml Log: Externalise output directory and encoding. JellyDoc report works correctly now with multiproject Revision Changes Path 1.16 +12 -10 maven/src/plugins-build/jellydoc/plugin.jelly Index: plugin.jelly =================================================================== RCS file: /home/cvs/maven/src/plugins-build/jellydoc/plugin.jelly,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- plugin.jelly 1 Oct 2003 12:11:42 -0000 1.15 +++ plugin.jelly 21 Oct 2003 15:04:58 -0000 1.16 @@ -54,14 +54,13 @@ <ant:javadoc sourcepath="${pom.build.sourceDirectory}" packagenames="${maven.jellydoc.packages}" - classpathref="doclet.classpath" - docletpathref="doclet.classpath" - doclet="org.apache.maven.jellydoc.TagXMLDoclet"> + classpathref="doclet.classpath"> + <doclet name="org.apache.maven.jellydoc.TagXMLDoclet" + pathref="doclet.classpath"> + <param name="-d" value="${maven.build.dir}"/> + <param name="-encoding" value="${maven.docs.outputencoding}"/> + </doclet> </ant:javadoc> - - <!-- if ran inside the reactor then lets copy the generated file --> - <!-- the doclet dumps taglib.xml into ${user.dir}/target --> - <ant:copy tofile="${maven.build.dir}/taglib.xml" file="${user.dir}/target/taglib.xml"/> </goal> <!-- runs the XML doclet --> @@ -71,9 +70,12 @@ <ant:javadoc sourcepath="${pom.build.sourceDirectory}" packagenames="${pom.package}.*" - classpathref="doclet.classpath" - docletpathref="doclet.classpath" - doclet="org.apache.maven.jellydoc.XMLDoclet"> + classpathref="doclet.classpath"> + <doclet name="org.apache.maven.jellydoc.XMLDoclet" + pathref="doclet.classpath"> + <param name="-d" value="${maven.build.dir}"/> + <param name="-encoding" value="${maven.docs.outputencoding}"/> + </doclet> </ant:javadoc> </goal> 1.21 +10 -0 maven/src/plugins-build/jellydoc/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/maven/src/plugins-build/jellydoc/project.xml,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- project.xml 1 Oct 2003 12:11:42 -0000 1.20 +++ project.xml 21 Oct 2003 15:04:58 -0000 1.21 @@ -36,6 +36,16 @@ <role>Java Developer</role> </roles> </developer> + <developer> + <name>Emmanuel Venisse</name> + <id>evenisse</id> + <email>[EMAIL PROTECTED]</email> + <organization/> + <roles> + <role>Java Developer</role> + </roles> + <timezone>+18</timezone> + </developer> </developers> <dependencies> <dependency> 1.4 +81 -4 maven/src/plugins-build/jellydoc/src/main/org/apache/maven/jellydoc/TagXMLDoclet.java Index: TagXMLDoclet.java =================================================================== RCS file: /home/cvs/maven/src/plugins-build/jellydoc/src/main/org/apache/maven/jellydoc/TagXMLDoclet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TagXMLDoclet.java 8 Feb 2003 11:40:25 -0000 1.3 +++ TagXMLDoclet.java 21 Oct 2003 15:04:59 -0000 1.4 @@ -63,6 +63,7 @@ package org.apache.maven.jellydoc; import java.beans.Introspector; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.StringReader; @@ -79,6 +80,7 @@ import com.sun.javadoc.ClassDoc; import com.sun.javadoc.Doc; +import com.sun.javadoc.DocErrorReporter; import com.sun.javadoc.Doclet; import com.sun.javadoc.MethodDoc; import com.sun.javadoc.PackageDoc; @@ -100,16 +102,20 @@ public class TagXMLDoclet extends Doclet { private String xmlns = "jvx"; - private String encodingFormat="UTF-8"; + private String encodingFormat = "UTF-8"; private String localName = "javadoc"; private ContentHandler cm = null; - private String targetFileName="target/taglib.xml"; + private String targetFileName = null; private Attributes emptyAtts = new AttributesImpl(); - public TagXMLDoclet (RootDoc root) throws Exception { - + public TagXMLDoclet (RootDoc root) throws Exception + { + readOptions(root); + File targetFile = new File(targetFileName); + targetFile.getParentFile().mkdirs(); FileOutputStream writer = new FileOutputStream(targetFileName); OutputFormat format = OutputFormat.createPrettyPrint(); + format.setEncoding(encodingFormat); XMLWriter xmlWriter = new XMLWriter(writer, format); try { cm = xmlWriter; @@ -400,5 +406,76 @@ System.exit(1); return false; } + } + + private void readOptions(RootDoc root) + { + String[][] options = root.options(); + for (int i = 0; i < options.length; i++) + { + String[] opt = options[i]; + if (opt[0].equals("-d")) + { + targetFileName = opt[1] + "/taglib.xml"; + } + if (opt[0].equals("-encoding")) + { + encodingFormat = opt[1]; + } + } + } + + public static int optionLength(String option) + { + if(option.equals("-d")) + { + return 2; + } + if(option.equals("-encoding")) + { + return 2; + } + return 0; + } + + public static boolean validOptions(String options[][], + DocErrorReporter reporter) + { + boolean foundEncodingOption = false; + boolean foundDirOption = false; + for (int i = 0; i < options.length; i++) + { + String[] opt = options[i]; + if (opt[0].equals("-d")) + { + if (foundDirOption) + { + reporter.printError("Only one -d option allowed."); + return false; + } + else + { + foundDirOption = true; + } + } + if (opt[0].equals("-encoding")) + { + if (foundEncodingOption) + { + reporter.printError("Only one -encoding option allowed."); + return false; + } + else + { + foundEncodingOption = true; + } + } + } + if (!foundDirOption) + { + reporter.printError("Usage: javadoc -d <directory> -doclet TagXMLDoclet ..."); + return false; + } + return true; } } 1.4 +78 -1 maven/src/plugins-build/jellydoc/src/main/org/apache/maven/jellydoc/XMLDoclet.java Index: XMLDoclet.java =================================================================== RCS file: /home/cvs/maven/src/plugins-build/jellydoc/src/main/org/apache/maven/jellydoc/XMLDoclet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- XMLDoclet.java 14 Sep 2003 06:44:39 -0000 1.3 +++ XMLDoclet.java 21 Oct 2003 15:04:59 -0000 1.4 @@ -59,6 +59,7 @@ package org.apache.maven.jellydoc; import java.io.IOException; +import java.io.File; import java.io.FileOutputStream; import java.util.Enumeration; import java.util.Vector; @@ -66,6 +67,7 @@ import com.sun.javadoc.ClassDoc; import com.sun.javadoc.ConstructorDoc; import com.sun.javadoc.Doc; +import com.sun.javadoc.DocErrorReporter; import com.sun.javadoc.Doclet; import com.sun.javadoc.ExecutableMemberDoc; import com.sun.javadoc.FieldDoc; @@ -99,12 +101,16 @@ private String encodingFormat="UTF-8"; private String localName = "javadoc"; private ContentHandler cm = null; - private String targetFileName="target/javadoc.xml"; + private String targetFileName = null; private Attributes emptyAtts = new AttributesImpl(); public XMLDoclet (RootDoc root) throws Exception { + readOptions(root); + File targetFile = new File(targetFileName); + targetFile.getParentFile().mkdirs(); FileOutputStream writer = new FileOutputStream(targetFileName); OutputFormat format = OutputFormat.createPrettyPrint(); + format.setEncoding(encodingFormat); XMLWriter xmlWriter = new XMLWriter(writer, format); try { @@ -719,5 +725,76 @@ System.exit(1); return false; } + } + + private void readOptions(RootDoc root) + { + String[][] options = root.options(); + for (int i = 0; i < options.length; i++) + { + String[] opt = options[i]; + if (opt[0].equals("-d")) + { + targetFileName = opt[1] + "/javadoc.xml"; + } + if (opt[0].equals("-encoding")) + { + encodingFormat = opt[1]; + } + } + } + + public static int optionLength(String option) + { + if(option.equals("-d")) + { + return 2; + } + if(option.equals("-encoding")) + { + return 2; + } + return 0; + } + + public static boolean validOptions(String options[][], + DocErrorReporter reporter) + { + boolean foundEncodingOption = false; + boolean foundDirOption = false; + for (int i = 0; i < options.length; i++) + { + String[] opt = options[i]; + if (opt[0].equals("-d")) + { + if (foundDirOption) + { + reporter.printError("Only one -d option allowed."); + return false; + } + else + { + foundDirOption = true; + } + } + if (opt[0].equals("-encoding")) + { + if (foundEncodingOption) + { + reporter.printError("Only one -encoding option allowed."); + return false; + } + else + { + foundEncodingOption = true; + } + } + } + if (!foundDirOption) + { + reporter.printError("Usage: javadoc -d <directory> -doclet TagXMLDoclet ..."); + return false; + } + return true; } } 1.8 +4 -0 maven/src/plugins-build/jellydoc/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/maven/src/plugins-build/jellydoc/xdocs/changes.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- changes.xml 1 Oct 2003 12:11:42 -0000 1.7 +++ changes.xml 21 Oct 2003 15:04:59 -0000 1.8 @@ -9,6 +9,10 @@ <body> <release version="1.2" date="in CVS"> + <action dev="evenisse" type="fix"> + Externalise output directory and encoding. + JellyDoc report works correctly now with multiproject. + </action> <action dev="dion" type="fix"> Only register report if sources exist </action>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]