From 2643ee2461e3fbee28105a33b39b338ea7160840 Mon Sep 17 00:00:00 2001 From: brett Date: Wed, 15 Jun 2005 12:00:09 +0000 Subject: [PATCH] incorporate vdoclet plugin git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@190737 13f79535-47bb-0310-9956-ffa450edef68 --- tasklist/plugin.jelly | 20 ++ tasklist/project.xml | 29 +++ .../org/apache/maven/vdoclet/VDocletBean.java | 186 ++++++++++++++++++ 3 files changed, 235 insertions(+) create mode 100644 tasklist/src/main/org/apache/maven/vdoclet/VDocletBean.java diff --git a/tasklist/plugin.jelly b/tasklist/plugin.jelly index 7fad47bb..50842e29 100644 --- a/tasklist/plugin.jelly +++ b/tasklist/plugin.jelly @@ -21,6 +21,7 @@ @@ -71,4 +72,23 @@ + + + + + + + + + diff --git a/tasklist/project.xml b/tasklist/project.xml index 02b88e3b..97ce70c8 100644 --- a/tasklist/project.xml +++ b/tasklist/project.xml @@ -97,4 +97,33 @@ MAVEN_TASKLIST_2_3 + + + vdoclet + vdoclet + 20020711 + + + commons-jelly + commons-jelly + 1.0-RC1 + http://jakarta.apache.org/commons/jelly/ + + + commons-jelly + commons-jelly-tags-velocity + 1.0 + http://jakarta.apache.org/commons/jelly/ + + + velocity + velocity + 1.4 + + + vdoclet + qdox + current + + diff --git a/tasklist/src/main/org/apache/maven/vdoclet/VDocletBean.java b/tasklist/src/main/org/apache/maven/vdoclet/VDocletBean.java new file mode 100644 index 00000000..1f07cd56 --- /dev/null +++ b/tasklist/src/main/org/apache/maven/vdoclet/VDocletBean.java @@ -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; + } +} +