incorporate vdoclet plugin
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@190737 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
fcf741e6d0
commit
2643ee2461
3 files changed
+235
No files matched your search
@@ -21,6 +21,7 @@
|
||||
<project
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:doc="doc"
|
||||
xmlns:define="jelly:define"
|
||||
xmlns:vdoclet="vdoclet">
|
||||
|
||||
<goal name="maven-tasklist-plugin:register">
|
||||
@@ -71,4 +72,23 @@
|
||||
|
||||
</goal>
|
||||
|
||||
<define:taglib uri="vdoclet">
|
||||
<define:jellybean
|
||||
name="vdocletBean"
|
||||
className="org.apache.maven.vdoclet.VDocletBean"
|
||||
method="execute">
|
||||
</define:jellybean>
|
||||
|
||||
<define:tag name="vdoclet">
|
||||
<vdoclet:vdocletBean
|
||||
srcDir="${srcDir}"
|
||||
destDir="${destDir}"
|
||||
template="${template}"
|
||||
outputFile="${outputFile}"
|
||||
encoding="${encoding}"
|
||||
jellyContext="${context}"
|
||||
/>
|
||||
</define:tag>
|
||||
</define:taglib>
|
||||
|
||||
</project>
|
||||
@@ -97,4 +97,33 @@
|
||||
<tag>MAVEN_TASKLIST_2_3</tag>
|
||||
</version>
|
||||
</versions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>vdoclet</groupId>
|
||||
<artifactId>vdoclet</artifactId>
|
||||
<version>20020711</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly</artifactId>
|
||||
<version>1.0-RC1</version>
|
||||
<url>http://jakarta.apache.org/commons/jelly/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly-tags-velocity</artifactId>
|
||||
<version>1.0</version>
|
||||
<url>http://jakarta.apache.org/commons/jelly/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>vdoclet</groupId>
|
||||
<artifactId>qdox</artifactId>
|
||||
<version>current</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,186 @@
|
||||
package org.apache.maven.vdoclet;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 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 java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.jelly.JellyContext;
|
||||
import org.apache.commons.jelly.tags.velocity.JellyContextAdapter;
|
||||
import org.apache.velocity.context.Context;
|
||||
|
||||
import com.thoughtworks.qdox.model.JavaSource;
|
||||
|
||||
import vdoclet.Generator;
|
||||
import vdoclet.docinfo.DocInfo;
|
||||
import vdoclet.docinfo.QDoxBuilder;
|
||||
|
||||
/**
|
||||
* Command-line entry-point to vDoclet
|
||||
*/
|
||||
public class VDocletBean
|
||||
{
|
||||
/** output directory */
|
||||
File srcDir;
|
||||
|
||||
/** output directory */
|
||||
File destDir;
|
||||
|
||||
/** output directory */
|
||||
String outputFile;
|
||||
|
||||
/** control template */
|
||||
String template;
|
||||
|
||||
/** encoding */
|
||||
String encoding;
|
||||
|
||||
/** verbose flag */
|
||||
boolean verbose = false;
|
||||
|
||||
/** docinfo */
|
||||
DocInfo docInfo;
|
||||
|
||||
/** The jelly context */
|
||||
JellyContext jellyContext;
|
||||
|
||||
/**
|
||||
* Alias for srcPath
|
||||
*/
|
||||
public void setSrcDir(File srcDir)
|
||||
{
|
||||
this.srcDir = srcDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* destDir attribute
|
||||
*/
|
||||
public void setDestDir(File destDir)
|
||||
{
|
||||
this.destDir = destDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Jelly context.
|
||||
*
|
||||
* @param jellyContext the Jelly context
|
||||
*/
|
||||
public void setJellyContext(JellyContext jellyContext)
|
||||
{
|
||||
this.jellyContext = jellyContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* destDir attribute
|
||||
*/
|
||||
public void setOutputFile(String outputFile)
|
||||
{
|
||||
this.outputFile = outputFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* template attribute
|
||||
*/
|
||||
public void setTemplate(String template)
|
||||
{
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
/**
|
||||
* encoding attribute
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*/
|
||||
public void execute()
|
||||
throws Exception
|
||||
{
|
||||
parseSources();
|
||||
generate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*/
|
||||
void log(String msg)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
System.err.println(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the source-files
|
||||
*/
|
||||
void parseSources()
|
||||
throws IOException
|
||||
{
|
||||
com.thoughtworks.qdox.JavaDocBuilder builder =
|
||||
new com.thoughtworks.qdox.JavaDocBuilder();
|
||||
|
||||
builder.addSourceTree(srcDir);
|
||||
|
||||
JavaSource[] javaSources = builder.getSources();
|
||||
log(javaSources.length + " source-files");
|
||||
docInfo = QDoxBuilder.build(javaSources);
|
||||
docInfo.setSourcePath(srcDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick-start generation
|
||||
*/
|
||||
void generate()
|
||||
throws Exception
|
||||
{
|
||||
if (!destDir.exists())
|
||||
{
|
||||
destDir.mkdirs();
|
||||
}
|
||||
|
||||
Generator generator = new Generator(destDir);
|
||||
generator.setAttribute("docInfo", docInfo);
|
||||
|
||||
if (jellyContext != null)
|
||||
{
|
||||
generator.setAttribute("jellyContext", getJellyContextAdapter());
|
||||
}
|
||||
|
||||
if (encoding != null)
|
||||
{
|
||||
generator.setAttribute("encoding", encoding);
|
||||
}
|
||||
generator.eval(template, new FileWriter(new File(destDir, outputFile)));
|
||||
}
|
||||
|
||||
private Context getJellyContextAdapter()
|
||||
{
|
||||
JellyContextAdapter adapter = new JellyContextAdapter(jellyContext);
|
||||
|
||||
adapter.setReadOnly(true);
|
||||
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user