HOWTO: using ServingXML in a Maven project

ServingXML is a powerful library to transform data from one format to another format by using a XML resource to define the transformation.

ServingXML comes with a console app, and also documents an API for embedding the software in a standard Java or J2EE application.

Apache Maven logo.
Image via Wikipedia

So, I decided to use this library in an enterprise integration application where normally I use Apache Maven for the Lifecycle Management. In the public Maven repos I couldn’t find the ServingXML dependency so I built a POM by myself tring to find which dependencies of ServingXML are present on public Maven repos and which are not.

Firstly I downloaded the latest version of ServingXML and extracted it on a local directory.

I adjusted the build-extensions.xml file as follows to obtain a minimal version of the library:

<project basedir="." default="build.extensions">
  <target name="build.extensions">
    <ant antfile="build.xml" dir="servingxml-msv" target="${ext.target}"/>
    <ant antfile="build.xml" dir="servingxml-saxon" target="${ext.target}"/>
    <ant antfile="build.xml" dir="servingxmlx" target="${ext.target}"/>
  </target>
</project>

So I had in my target/servingxml directory the built binary with dependenies in the lib folder. I figured out that some jar was the result of a transitive dependency so I decided to add progressively the libraries to my project using the install goal and then build and run tests to see if it worked.

Finally I obtained this POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.servingxml</groupId>
  <artifactId>servingxml</artifactId>
  <version>1.1.2</version>
  <description>Artifactory auto generated POM</description>
<dependencies>
        <dependency>
           <groupId>net.sourceforge.saxon</groupId>
           <artifactId>saxon</artifactId>
           <version>9.1.0.8</version>
        </dependency>
        <dependency>
            <groupId>isorelax</groupId>
            <artifactId>isorelax</artifactId>
            <version>20030108</version>
        </dependency>
        <dependency>
            <groupId>com.sun.msv.datatype.xsd</groupId>
            <artifactId>xsdlib</artifactId>
            <version>2011.1</version>
        </dependency>
        <dependency>
            <groupId>com.servingxml</groupId>
            <artifactId>msv</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>com.servingxml</groupId>
            <artifactId>saxon</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>com.servingxml</groupId>
            <artifactId>x</artifactId>
            <version>1.1.2</version>
        </dependency>
    </dependencies>
</project>

This, properly uploaded in my Artifactory toghether with the deployment of all Ant generated jars, gave me the opportunity to build with Maven “minimal embedded ServingXML” applications within my organization.