Skip to content

Instantly share code, notes, and snippets.

Last active December 31, 2015 13:59
What would you like to do?
Ant tasks for distributing Java projects that use RXTX binaries.
Copyright 2013 Andrew Bythell <>
Ant tasks for distributing Java applications with platform-specific RXTX
libraries as zip files. To use:
1. Get and unzip RXTX - into your project directory.
2. Copy this file (rxtx.xml) into the RXTX directory.
3. Include rxtx.xml in your build.xml.
4. Use targets "dist-all", "dist-<platform>", or "dist-clean", where
<platform> = win32, win64, mac, i686, or x86_64.
Example: Add the following to the bottom of build.xml (before the final </project>
tag) to build and clean all platforms automatically from the Netbeans IDE:
<include file="PATH-TO-RXTX-DIR/rxtx.xml" />
<target name="dist" depends="jar, rxtx.dist-all" />
<target name="-post-clean" depends="rxtx.dist-clean" />
This assumes the project output, containing the project jars, etc. are
found in ${basedir}/dist and are created by the target "jar". If the project
jars are in another location, update the ${dist.dir} property below.
Note that the Windows versions of JRE7 and JRE8 already contain RXTX, and that version will be
used by default. Only if the RXTX dll is not found will the local copy (the one installed here)
be used.
<project name="rxtx">
If your project creates final output in a directory other than
${basedir}/dist, change the following line
<property name="dist.dir" value="${basedir}/dist" />
<dirname property="rxtx.dir" file="${ant.file.rxtx}" />
<target name="zip" description="create zip from distribution dir and include>
platform-specific files" >
<zip destfile="${basedir}/${}-${platform}.zip">
<zipfileset dir="${dist.dir}" prefix="${}-${platform}" />
<zipfileset dir="${rxtx.dir}/${platform}" prefix="${}-${platform}" />
<target name="dist-win32">
<antcall target="">
<param name="platform" value="win32" />
<target name="dist-win64">
<antcall target="">
<param name="platform" value="win64" />
<target name="dist-i686">
<antcall target="">
<param name="platform" value="i686-pc-linux-gnu" />
<target name="dist-x86_64">
<antcall target="">
<param name="platform" value="x86_64-unknown-linux-gnu" />
<target name="dist-mac">
<antcall target="">
<param name="platform" value="mac-10.5" />
<target name="dist-all" depends="dist-win32, dist-win64, dist-mac, dist-i686,
<target name="dist-clean">
<fileset dir="${basedir}" includes="${}*.zip" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment