ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Wiedmann <>
Subject Build Script Templates
Date Tue, 12 Dec 2017 12:54:07 GMT

over the last months, I was working in a larger project in a Java
environment, but not directly a Java project. Suffice it to say, that
we have a number of Java subprojects, but generally aren't so much
interested in Java builds, etc.

There's no rule without exceptions, so I've been tasked with
streamlining these subprojects into a form, which allows to maintain
them in a simple, and uniform manner.

Not surprising, I was thinking "Maven" initially, and started to
rewrite some of these subprojects for Maven. However, it quickly
turned out, that access to the Internet is a problem in my particular
corporate environment, so I dropped Maven from the picture.

What I came up with, instead, was a set of conventions, which closely
resemble the Maven projects, and a "Maven Jar Template" (MJT). The MJT
is an Ant build script, which is generic, and shared by all our
subprojects. The actual build scripts typically specify a small set of
properties (, project.version,, and the like), and import the MJT. As the
project follows the MJT conventions, that's it in most cases, apart
from things like a uber jar, etc., which aren't handled by the MJT.
However, these are mostly resolved by "overwriting" one of the
imported tasks.

In general, our build scripts are unusually small, and concise (for
Ant scripts, that is). The experiemce is so good, that I wonder, if we
couldn't start distributing some of these templates with Ant Core, or
as a separate ant-templates.jar? If so, a build script could look like


   <project name="MySampleProject" default="dist">
        <property name="" value="MySampleProject"/>
        <property name="project.version" value="0.1"/>

        <!-- Specify targets, like "clean", "compile", "package", etc.
              following the Maven goals. -->
        <import resource="org/apache/ant/templates/MavenJarTemplate-0.1.xml"/>

        <!-- Specify our own targets -->
        <target name="dist" depends="clean,install"/>

The next time you hear: "Don't reinvent the wheel!"

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message