search

Generate application.xml from ivy.xml for packaging an ear

After a lot of trouble with maven 2 I tried ant with ivy as a build and dependency resolving system. For multi-project builds with ivy you’ll have to dig into the documentation and ivy samples a little deeper but finaly I must say I like it. One show stopper for me was that maven 2 generated an application.xml from the pom. I use now a xslt stylesheet to make an application.xml from an ivy resolution report:

<target name="appxml" depends="resolve">
<property name="meta.dir" value="${basedir}/src/main/resources/META-INF/"/>
<property name="appxml.filename" value="application.xml"/>
<property name="appxml.file" value="${build.dir}/${appxml.filename}"/>
<ivy:report todir="${build.dir}"
outputpattern="ivy.xml"
xml="true"/>
<xslt in="${build.dir}/ivy.xml" style="ivy2appxml.xslt" out="${appxml.file}"/>
</target>

The stylsheet I use currently is simple but does it job. No support for web archvies and connectors yet, or any configuration but it’s doing it’s job:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/application_5.xsd">
<xsl:template match="ivy-report">
<application>
<display-name>
<xsl:value-of select="info/module"/>
</display-name>
<xsl:apply-templates/>
</application>
</xsl:template>
<xsl:template match="dependencies">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="artifact[@type='jar']">
<module>
<java>
<xsl:value-of select="concat(@name, '.', @ext)"/>
</java>
</module>
</xsl:template>
<xsl:template match="artifact[@type='ejb']">
<module>
<ejb>
<xsl:value-of select="concat(@name, '.', @ext)"/>
</ejb>
</module>
</xsl:template>
<xsl:template match="artifact[@type='sar']">
<module>
<java>
<xsl:value-of select="concat(@name, '.', @ext)"/>
</java>
</module>
</xsl:template>
</xsl:stylesheet>

Tags: , , , ,

terms

{ 1 comment to read ... please submit second! }

{ 1 Pingbacks/Trackbacks }

  1. sample systems used
notice
copyright
Bear
language