How to make the XDoclet 1.2.x plugin for Maven 2 play along with Java 1.5 syntax

Categories: TechNotes
Tags:
Comments: No Comments
Published on: May 24, 2008

I’m currently working for a software company which mainly uses Java for it’s projects. Some time ago we decided to convert our existing J2EE-projects from using the Ant build tool to use the Maven 2 project framework. The conversion was in most cases straight forward. If you however have an odd build setup, there can be a problem that the documentation on Maven 2 is not so good. You will probably spend a lot of time playing around on Google to find a solution fullfilling your requirements. Hopefully this will improve when the official Maven 2 documentation (Maven: The Definitive Guide) is being released this summer.


We have gained some experience now and we are very pleased with using Maven 2. There is however one limitation of our initial setup that has really annoyed me. The XDoclet 1.2.x plugin for Maven 2 does not handle Java 1.5 syntax like for instance annotations and the Enum type. In new projects we use EJB3, so XDoclet is not needed, but the old projects is not rewritten jo EJB3 yet. Last week I decided to spend some time to finally solve this problem. I found a surprisingly easy but very poorly documented solution.

In short, you need to download the plugin source, download a specific xjavadoc-jar file. Then you change a couple of lines in the†pom.xml and rebuild the plugin. That’s it!

  1. Download the required xjavadoc dependency
  2. # wget†http://sourceforge.net/project/downloading.php?groupname=xdoclet&filename=xjavadoc-1.5-snapshot050611.jar&use_mirror=switch
  3. Install the xjavadoc in local maven repository
  4. # mvn install:install-file -DgroupId=xjavadoc -DartifactId=xjavadoc
    -Dversion=1.5-snapshot050611 -Dpackaging=jar -Dfile=/path/to/dowloadfile
  5. Download the maven xdoclet pluging from the SVN repository. Note: I received a warning about the certificate, but just accept it.
  6. # svn checkout https://svn.codehaus.org/mojo/trunk/mojo/xdoclet-maven-plugin
  7. Change the following in the plugin project pom.xml
    <blockquote><code> &lt;packaging&gt;maven-plugin&lt;/packaging&gt;
    - &lt;version&gt;1.0-beta-1-SNAPSHOT&lt;/version&gt;
    +†&lt;version&gt;1.0-beta-1-java15&lt;/version&gt;&lt;properties&gt;
    &lt;xdoclet.version&gt;1.2.3&lt;/xdoclet.version&gt;
    -    ††&lt;xjavadoc.version&gt;1.1&lt;/xjavadoc.version&gt;
    +    ††&lt;xjavadoc.version&gt;1.5-050611&lt;/xjavadoc.version&gt;
    &lt;/properties&gt;&lt;dependency&gt;
    -      ††&lt;groupId&gt;xdoclet&lt;/groupId&gt;
    + †      &lt;groupId&gt;xjavadoc&lt;/groupId&gt;
    &lt;artifactId&gt;xjavadoc&lt;/artifactId&gt;
    &lt;version&gt;${xjavadoc.version}&lt;/version&gt;
    &lt;/dependency&gt;
     

     

     

  8. Build and install the plugin
  9. # mvn install
  10. Change the XDoclet config in you project to use the new plugin build (snippet from our pom.xml)
  11.  &lt;plugin&gt;
    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
    &lt;artifactId&gt;xdoclet-maven-plugin&lt;/artifactId&gt;
    -†       &lt;version&gt;1.0-alpha-2&lt;/version&gt;
    + †&lt;version&gt;1.0-beta-1-java15&lt;/version&gt;......&lt;/plugin&gt;
     

     

Voila!

You can now use Java 1.5 syntax in your existing XDoclet EJB2 projects.

  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • Google Bookmarks
  • StumbleUpon
  • FriendFeed

Leave a Reply

Your email address will not be published. Required fields are marked *

*


− 2 = two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Welcome , today is Sunday, February 5, 2012