Skip to content

Instantly share code, notes, and snippets.

@mvelbaum
Last active March 21, 2016 05:42
Show Gist options
  • Save mvelbaum/f0a79f88a90571c06b68 to your computer and use it in GitHub Desktop.
Save mvelbaum/f0a79f88a90571c06b68 to your computer and use it in GitHub Desktop.
POM for generating jaxb.index files for custom JAXB model classes
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<model.out.dir>${project.build.outputDirectory}/model</model.out.dir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<!-- Generates the jaxb.index files for JAXB -->
<execution>
<id>gen-jaxb.index</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ac:for param="dir" xmlns:ac="antlib:net.sf.antcontrib">
<dirset dir="${model.out.dir}"/>
<sequential>
<delete file="@{dir}/jaxb.index" quiet="true"/>
<echo>[jaxb.index] Processing directory @{dir}</echo>
<ac:for param="file" xmlns:ac="antlib:net.sf.antcontrib">
<fileset dir="@{dir}" includes="*.class" excludes="*$*"/>
<sequential>
<local name="class.filename"/>
<basename property="class.filename" file="@{file}" suffix=".class"/>
<echo file="@{dir}/jaxb.index" append="true">
${class.filename}${line.separator}
</echo>
</sequential>
</ac:for>
</sequential>
</ac:for>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment