From 8477e3bf29a1375777ec3131ff21c68ee97b5677 Mon Sep 17 00:00:00 2001 From: kaz Date: Mon, 3 Mar 2003 21:18:08 +0000 Subject: [PATCH] Enhanced the vdoclet plugin. Previous versions did not provide access to the Jelly context within the vdoclet velocity templates. Thus, as a result, support of the maven.tasklist.taskTag was dropped and the tasklist plugin was hardcoded to use "@todo" because there was no way to get the value from the Jelly context. - VDocletBean can now be passed a JellyContext which gets wrapped in the same JellyContextAdapter that I wrote from the Velocity taglib. To access the context from a vdoclet template, use '$jellyContext'. - Updated the taglib and tag defined in plugin.jelly to automatically include the current context. - Updated the POM to include the jelly deps. On a side note, also had to update the POM of the xdoc plugin as it had a dependency on the velocity taglib as well, and it was being loaded before the jar specified in this POM. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113032 13f79535-47bb-0310-9956-ffa450edef68 --- vdoclet/plugin.jelly | 1 + vdoclet/project.xml | 11 ++++++ .../org/apache/maven/vdoclet/VDocletBean.java | 36 ++++++++++++++++++- xdoc/project.xml | 2 +- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/vdoclet/plugin.jelly b/vdoclet/plugin.jelly index 55653c35..574e4a0d 100644 --- a/vdoclet/plugin.jelly +++ b/vdoclet/plugin.jelly @@ -17,6 +17,7 @@ template="${template}" outputFile="${outputFile}" encoding="${encoding}" + jellyContext="${context}" /> diff --git a/vdoclet/project.xml b/vdoclet/project.xml index 285f9543..9d4cd804 100644 --- a/vdoclet/project.xml +++ b/vdoclet/project.xml @@ -50,6 +50,17 @@ oro 2.0.6 + + commons-jelly + 1.0-beta-4 + http://jakarta.apache.org/commons/jelly/ + + + commons-jelly + commons-jelly-tags-velocity + 20030303.205659 + http://jakarta.apache.org/commons/jelly/ + logkit 1.0.1 diff --git a/vdoclet/src/main/org/apache/maven/vdoclet/VDocletBean.java b/vdoclet/src/main/org/apache/maven/vdoclet/VDocletBean.java index 3d525ae1..c7cab4e6 100644 --- a/vdoclet/src/main/org/apache/maven/vdoclet/VDocletBean.java +++ b/vdoclet/src/main/org/apache/maven/vdoclet/VDocletBean.java @@ -1,9 +1,15 @@ package org.apache.maven.vdoclet; -import com.thoughtworks.qdox.model.JavaSource; 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; @@ -34,6 +40,9 @@ public class VDocletBean /** docinfo */ DocInfo docInfo; + /** The jelly context */ + JellyContext jellyContext; + /** * Alias for srcPath */ @@ -50,6 +59,16 @@ public class VDocletBean this.destDir = destDir; } + /** + * Set the Jelly context. + * + * @param jellyContext the Jelly context + */ + public void setJellyContext(JellyContext jellyContext) + { + this.jellyContext = jellyContext; + } + /** * destDir attribute */ @@ -125,11 +144,26 @@ public class VDocletBean 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; + } } diff --git a/xdoc/project.xml b/xdoc/project.xml index 64765a8f..1c25fecd 100644 --- a/xdoc/project.xml +++ b/xdoc/project.xml @@ -88,7 +88,7 @@ commons-jelly commons-jelly-tags-velocity - 20030211.144921 + 20030303.205659 commons-jelly