Externalise output directory and encoding.
JellyDoc report works correctly now with multiproject git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114226 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -36,6 +36,16 @@
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Emmanuel Venisse</name>
|
||||
<id>evenisse</id>
|
||||
<email>emmanuel@venisse.net</email>
|
||||
<organization/>
|
||||
<roles>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
<timezone>+18</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -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 org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
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 @@ import com.sun.javadoc.Tag;
|
||||
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;
|
||||
@@ -401,4 +407,75 @@ public class TagXMLDoclet extends Doclet {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 java.util.Vector;
|
||||
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 @@ public class XMLDoclet extends Doclet
|
||||
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
|
||||
{
|
||||
@@ -720,4 +726,75 @@ public class XMLDoclet extends Doclet
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user