Upgrading Maven2 castor-maven-plugin to use Castor 1.1.2.1
Posted on | 3 September 2007 | No Comments
Tags: castor | maven
Castor is a tool for generating java objects from xsds. It provides the ability to process XML as Java objects. This is an alternative to building up a DOM tree or implementing callback methods for the SAXParser yourself.
The latest version (1.0) of castor-maven-plugin for Maven2 in the central repo uses Castor version 0.9.7. However, the newest version of Castor (1.1.2.1) is not backward compatible! The castor plugin for Maven1 has been upgraded, but not for Maven2. Has Castor gone out of fashion since Maven2 was introduced?
Anyway, my project needed Castor 1.1.2.1 for some new functionality, so I downloaded to sources for castor-maven-plugin and the pom from the central repository upgraded the dependencies to Castor 1.1.2.1.
Instead of:
<dependency>
<groupId>castor</groupId>
<artifactId>castor</artifactId>
<version>0.9.7</version>
</dependency>
I now have:
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor</artifactId>
<version>1.1.2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor-codegen</artifactId>
<version>1.1.2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.castor</groupId>
<artifactId>castor-jdo</artifactId>
<version>1.1.2.1</version>
</dependency>
Some classes for the Castor builder has been moved, so the import statements for CastorSourceGenerator had to be changed:
From:
import org.exolab.castor.builder.CollectionInfo;
import org.exolab.castor.builder.FieldInfoFactory;
To:
import org.exolab.castor.builder.info.CollectionInfo;
import org.exolab.castor.builder.factory.FieldInfoFactory;
After rebuilding everything, a new version 1.0.1-SNAPSHOT was produced for castor-maven-plugin that uses the latest version (1.1.2.1) of Castor.
I haven’t yet had time to investigate how to get it into the central repository so you can download the RAR compressed directory of castor-maven-plugin version 1.0.1-SNAPSHOT here. It is to be placed at ${local.repo}/org/codehaus/mojo/castor-maven-plugin/ together with maven-metadata-local.xml.
Comments
Leave a Reply