Hi,

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.name, project.version,
project.java.source.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
below,

Jochen

   <project name="MySampleProject" default="dist">
        <property name="project.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"/>
   </project>


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

http://www.keystonedevelopment.co.uk/wp-content/uploads/2014/10/evolution-of-the-wheel-300x85.jpg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to