Print
Two Minute Introduction

Setting up xdoclet 2

It's really not that difficult to set up XDoclet2, but some of the dependencies (like Jelly) can give some very unhelpful error messages if they are not properly fed with a healthy lunch of the proper dependencies.

  • First, add dependencies to your project.xml. The best place to look for the current dependencies is in the project.xml from XDoclet Plugins. You only need dependencies down to the line that reads "<!-- Build/Test time only -->". If you are using Ant, include each of the JARs listed in this document in the build classpath.
  • Now, set up the instructions in your build for Maven:
    XDoclet2 Invocation with Maven
    <goal name="xdoclet">
      <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" 
                              classpathref="maven.dependency.classpath" />
      <xdoclet>
        <fileset dir="${pom.build.sourceDirectory}">
          <include name="**/*.java"/>
        </fileset>
        <component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin" 
                   destdir="${maven.build.dir}/xdoclet/hibernatedoclet"/>
        <!-- add more plugins here! -->
      </xdoclet>
    </goal>
    
    <preGoal name="java:compile">
      <!-- Add paths containing your generated sources to java:compile source set. -->
      <path id="maven.compile.src.set">
        <pathelement location="src/java"/>
        <pathelement location="target/src"/>
        <pathelement location="${maven.build.dir}/xdoclet/hibernatedoclet"/>
      </path>
      <attainGoal name="xdoclet"/>
    </preGoal>
  • ...or Ant:
    XDoclet2 Invocation with Ant
    <project name="xdoclet-sample" default="xdoclet">
    
       <property file="build.properties"/>
       <property name="xdoclet.lib.dir" value="${user.home}/.maven/repository"/>
    
       <target name="xdoclet">
           <mkdir dir="${basedir}/target/xdoclet/persistence"/>
           <path id="xdoclet.task.classpath">
               <!-- Add the xdoclet2 plugins jar here -->
               <pathelement location="${xdoclet.lib.dir}/xdoclet-plugins/jars/your-plugin.jar"/>
    
               <!-- xdoclet2 runtime dependencies -->
               <pathelement location="${xdoclet.lib.dir}/xdoclet/jars/xdoclet2-SNAPSHOT.jar"/>
               <pathelement location="${xdoclet.lib.dir}/generama/jars/generama-SNAPSHOT.jar"/>
               <pathelement location="${xdoclet.lib.dir}/picocontainer/jars/picocontainer-1.0.jar"/>
               <pathelement location="${xdoclet.lib.dir}/nanocontainer/jars/nanocontainer-1.0-beta-1.jar"/>
               <pathelement location="${xdoclet.lib.dir}/nanocontainer/jars/nanocontainer-ant-1.0-beta-1.jar"/>
               <pathelement location="${xdoclet.lib.dir}/qdox/jars/qdox-1.6-SNAPSHOT.jar"/>
               <pathelement location="${xdoclet.lib.dir}/velocity/jars/velocity-1.4.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-collections/jars/commons-collections-2.1.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-jelly/jars/commons-jelly-1.0-beta-4-SNAPSHOT.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-jelly/jars/commons-jelly-tags-define-20030211.142932.jar"/>
               <pathelement location="${xdoclet.lib.dir}/log4j/jars/log4j-1.2.8.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-logging/jars/commons-logging-1.0.4.jar"/>
               <pathelement location="${xdoclet.lib.dir}/dom4j/jars/dom4j-1.4.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-beanutils/jars/commons-beanutils-1.6.1.jar"/>
               <pathelement location="${xdoclet.lib.dir}/commons-jexl/jars/commons-jexl-1.0-beta-2.jar"/>
           </path>
    
           <taskdef
               name="xdoclet"
               classname="org.xdoclet.ant.XDocletTask"
               classpathref="xdoclet.task.classpath"
               />
    
           <xdoclet>
               <!-- defines the file handled by xdoclet2 -->
               <fileset dir="src/java">
                   <include name="**/*.java"/>
               </fileset>
    
               <!-- defines the processing of a plugin -->
               <component
                 classname="com.company.xdoclet.YourPlugin"
                 destdir="${basedir}/target/xdoclet/"
                 />
           </xdoclet>
       </target>
    
    </project>
  • Launch your build and see what happens!

If you have questions about these instructions, please join the user mailing list and ask them there.

Powered by Atlassian Confluence