Last weekend Antoine announced Ant 1.8.1. This is more or less a
pure bugfix release which addresses a few important issues. The fix
with the biggest impact likely is that
<extension-point> and <import>
finally work together as intended - and even documented.
The full list of issues raised against Ant that have been fixed with this release can be found in Bugzilla. We've adressed almost all issues raised against Ant 1.8.0 so far.
Thanks to the new <augment> task, detecting Ant
1.8.1 means either
<antversion property="Ant-1.8.1-or-later"
atleast="1.8.1"/>
or
<available property="Ant-1.8.1-or-later"
classname="org.apache.tools.ant.taskdefs.AugmentReference"/>
path: /en/Apache/Ant | # | Writebacks
Chris Sells translated a Clojure implementation of a function that descends into a directory in a "lazy" manner by Craig Andera into C# but his solution is so .NET 2.0 ;-).
Here's my take
static IEnumerable<string> GetDirectoryDescendants(string path) {
return Directory.GetFiles(path)
.Concat(Directory.GetDirectories(path)
.SelectMany<string, string>(GetDirectoryDescendants)
);
}
where I'd hope C# 4.0's compiler will be able to deduce the types
for the SelectMany itself. Interestingly the C# 3.0
compiler does fine when I use a lambda expression instead:
static IEnumerable<string> GetDirectoryDescendants(string path) {
return Directory.GetFiles(path)
.Concat(Directory.GetDirectories(path)
.SelectMany(dir => GetDirectoryDescendants(dir))
);
}
path: /en/dotNet | # | Writebacks
So Apache Ant 1.8.0 is out and I'm supposed to follow a tradition I started with Ant 1.6.2. If you can be sure that you are at least using Ant 1.7.0 then the built-in <antversion> task/condition will do:
<antversion property="Ant-1.8.0-or-later"
atleast="1.8.0"/>
otherwise the trick of checking for a class that has been introduced with Ant 1.8.0 can always be used:
<available property="Ant-1.8.0-or-later"
classname="org.apache.tools.ant.types.resources.MappedResource"/>
path: /en/Apache/Ant | # | Writebacks
Antoine Levy-Lambert has recently built the first release candidate for Ant 1.8.0 and called for a vote, so we should be close to the first Ant release since eighteen months. This release mostly brings enhancements and bug fixes to many tasks and types (this is the real strength of Ant IMHO) but there also are a few core changes, the full list is here.
My personal top five changes (I know there are six items, but the first one doesn't count ;-):
- More than 275 fixed Bugzilla issues.
- Lexically scoped local properties, i.e. properties that are only
defined inside a target, sequential block or similar environment.
This is very useful inside of
<macrodef>s where a macro can now define a temporary property that will disappear once the task has finished. <import>can now import from any file- or URL-providing resource - this includes<javaresource>. This means<import>can read build file snippets from JARs or fixed server URLs. There are several other improvements in the area of import.- Various improvements to the directory scanning code that help with symbolic link cycles (as can be found on MacOS X Java installations for example) and improve scanning performance. For big directory trees the improvement is dramatic.
- The way developers can extend Ant's property expansion algorithm
has been rewritten (breaking the older API) to be easier to use a
be more powerful. The whole local properties mechanism is
implemented using that API and could be implemented in a separate
library without changes in Ant's core. Things like the
yet-to-be-released props
Antlib can now provide often required "scripty" fuctions
without touching Ant itself.
At the same time the if and unless attributes have been rewritten to do the expected thing if applied to a property expansion (i.e.if="${foo}"will mean "yes, do it" if${foo}expands to true, in Ant 1.7.1 it would mean "no" unless a property named "true" existed). This adds "testing conditions" as a new use-case to property expansion. - A new top-level element
<extension-point>assists in writing re-usable build files that are meant to be imported.<extension-point>has a name and a dependency-list like<target>and can be used like a<target>from the command line or a dependy-list but the importing build file can add targets to the<extension-point>'s depends list.
In Ant 1.7.1 one would use something likeimported.xml: <project name="imported"...> ... <target name="setup"> ... </target> <target name="compile" depends="setup"> ... </target> </project> importing.xml <project ...> ... <import file="imported.xml"> <target name="setup" depends="imported.setup"> ... stuff that should happen before compile ... </target> </project>to define a pre-compilation stage by target overriding. With some planning it can be improved toimported.xml: <project name="imported"...> ... <target name="setup"> ... </target> <target name="ready-to-compile" depends="setup"/> <target name="compile" depends="ready-to-compile"> ... </target> </project> importing.xml <project ...> ... <import file="imported.xml"> <target name="ready-to-compile" depends="imported.ready-to-compile"> ... stuff that should happen before compile ... </target> </project>In Ant 1.8.0 one would write this asimported.xml: <project name="imported"...> ... <target name="setup"> ... </target> <extension-point name="ready-to-compile" depends="setup"/> <target name="compile" depends="ready-to-compile"> ... </target> </project> importing.xml <project ...> ... <import file="imported.xml"> <target name="pre-compile" extensionOf="ready-to-compile"> ... stuff that should happen before compile ... </target> </project>and thepre-compiletarget was added toready-to-compiledependeny-list.
extension-point and some changes
in import and its new cousin include have
been inspired by Easyant
which can now use an un-patched version of Ant together with a
custom ProjectHelper to create a build system quite
different from Ant's original ideas. ProjectHelper is the mechanism that allowed
me
to sketch
JavaFront
or Nicolas Lalevée to
write GroovyFront
which lets you write build files in Groovy.
path: /en/Apache/Ant | # | Writebacks
When my Mum called us this morning to tell us that my brother's first daughter was born my kids celebrated "finally I'm a cousin".
Welcome Carina - being born on 11/11 will not always be easy in the rhine area - and congratulations Claudia and Maik.
path: /en/personal/family | # | Writebacks