ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject Re: Build Script Templates
Date Tue, 12 Dec 2017 13:53:10 GMT
MG>quick comments below

From: Jochen Wiedmann <>
Sent: Tuesday, December 12, 2017 7:54 AM
Subject: Build Script Templates


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,
MG>my internet access was problematic so i dropped IVY ..
MG>in maven you can test your pom.xml against local repository with -o option e.g.
MG>mvn -o

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),
MG>Nota Bene:if you add project.groupId and project.artifactId you will satisfy the GAV
reference to a maven artifact

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.
MG>same concept applies in maven where you declare template in <dependencyManagement>
MG>and / or <pluginManagement> in parent pom
MG>then later on you can 'override' either declaration for plugin or dependency in your
artifact's local pom.xml

In general, our build scripts are unusually small, and concise (for
Ant scripts, that is). The experience 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"/>
MG>do you have a mock of MavenJarTemplate-0.1.xml you can display for us?

        <!-- Specify our own targets -->
        <target name="dist" depends="clean,install"/>
MG>assume install target is declared in MavenJarTemplate-0.1.xml ?

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


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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message