This discussion belongs on xdoclet-plugin-interest mailing list!!!!! --- On Mon, 6/15/09, Justin Case <send_lotsa_spam_h...@yahoo.com> wrote:
> From: Justin Case <send_lotsa_spam_h...@yahoo.com> > Subject: [Xdoclet-user] how to create own tags using qtags > To: "End-user support for the XDoclet code generator" > <xdoclet-user@lists.sourceforge.net> > Date: Monday, June 15, 2009, 6:01 PM > > Hi all, > > Velocity code generation works fine with a VM file. I > thought I'd use also the qtags special annotations to > implement easier restrictions instead of checking everything > in the VM file. > > However I can't seem to understand how to activate them. I > created the tags as needed, put restrictions in their > annotations, started the Ant build with some broken files, > the process flows happily ignoring all the qtags > restrictions I've got there. Shouldn't I get some kind of > error? Do you see anything unusual below - or forgotten? For the qtags to work properly you shall first generate their implementations (there is xdoclet plugin for this puprose). Then you can registzer this tag library, and magic can begin. You can see how qtags plugin is invoked in xd2 plugin sources, and tag library registration (for example) in hibernate plugin. > Note: I couldn't really figure out what the "namespace" > attributes need to contain, but I picked something hopefully > appropriate. namespace is first part of tag name > Thanks a lot, > M > > Here more info: > > ---------The tag class: > package org.xdoclet.plugin.myplugin.qtags; > import com.thoughtworks.qdox.model.AbstractJavaEntity; > import org.xdoclet.XDocletTag; > /** > * @qtags.location class > * @qtags.once > */ > public class MyClassTag extends XDocletTag { > > -------- the VM file: > #set( $class = $metadata ) > public interface I${class.getName()} { > #set( $parameterTagsClass = > $class.getTagsByName("mytag.classlvl") ) > #foreach( $parameterTagClass in $parameterTagsClass > ) > #if > ($parameterTagClass.getNamedParameter("table")) > public static final String TABLE > = "$parameterTagClass.getNamedParameter("table")"; > #end > #end > > ---------- the build.xml > <taskdef > name="xdoclet2" > > classname="org.xdoclet.ant.XDocletTask" > > classpathref="lib2.class.path" /> > <xdoclet2> > > <fileset dir="${src.java.dir}"> > > <include name="**/test/*Base.java" > /> > > </fileset> > > <component > classname="org.generama.VelocityTemplateEngine"/> > <component > classname="org.generama.JellyTemplateEngine"/> > <component > > classname="org.xdoclet.plugin.qtags.impl.QTagImplPlugin" > > destdir="${build2.java.dir}" > > /> > <component > > classname="org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin" > > destdir="${build2.java.dir}" > > packagereplace="org.xdoclet.plugin.myplugin.qtags" > > /> > <component > > classname="org.xdoclet.plugin.qtags.xdoc.QTagXDocPlugin" > > destdir="${build2.java.dir}/generated-xdocs" > > namespace="myplugin" > > /> > <component > > classname="org.xdoclet.plugin.qtags.confluence.QTagConfluencePlugin" > > destdir="${build2.java.dir}/confluence" > > namespace="myplugin" > > /> > > <component > classname="org.xdoclet.plugin.myplugin.MyPlugin" > > > destdir="${build2.java.dir}" > > > fileregex="(.*)(.java)" > > > filereplace="I$1.java" > > > packageregex="test" > > > packagereplace="test.generated" /> > > --------tags registration: > package org.xdoclet.plugin.myplugin; > import org.generama.QDoxCapableMetadataProvider; > import org.generama.VelocityTemplateEngine; > import org.generama.WriterMapper; > import org.generama.defaults.JavaGeneratingPlugin; > import org.xdoclet.plugin.sqlinterface.qtags.MyClassTag; > > public class MyPlugin extends JavaGeneratingPlugin { > > public MyPlugin(VelocityTemplateEngine > templateEngine, > > QDoxCapableMetadataProvider metadataProvider, > > WriterMapper writerMapper) { > super(templateEngine, > metadataProvider, writerMapper); > > setMultioutput(true); > > > metadataProvider.getDocletTagFactory().registerTag(MyClassTag.NAME, > > MyClassTag.class); > > --------- and the broken Java source > package com.test; > /** > * @mytag.classlvl table="firstone" > * @mytag.classlvl table="second" > **/ ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ xdoclet-user mailing list xdoclet-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-user