SCHOEPFLIN Markus | 24 May 13:53 2016

How to enable XInclude processing for schemavalidate task

Hello list,

I'm trying to enable XInclude processing in the schemavalidate task:

        noNamespaceFile="${user.input.xsd}" file="${user.input.xml}">
      <attribute name="" value="true"/>

This does not work, as I'm still getting an error when the task is executed: "foo.xsd:8:136:
s4s-elt-schema-ns: The namespace of element 'include' must be from the schema namespace, ''."

The corresponding schema file looks like this:

  <xs:schema xmlns:xs="" xmlns:xi="">
    <xi:include href="..." xpointer="xmlns(xs=*)"/>

When enabling Ant debug mode, I can see that the feature is correctly set on the parser:

[schemavalidate] Using SAX2 reader org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser
[schemavalidate] Setting feature
[schemavalidate] Setting feature
[schemavalidate] Setting feature
[schemavalidate] Setting feature
[schemavalidate] Setting feature
[schemavalidate] Validating foo.xml...

What am I missing? Or is this not supported?

(Continue reading)

Gilles Querret | 13 May 17:58 2016

Regexp mapper + Zip task on Windows


Using this test case, I see a different behavior on Windows and Linux ; I'm
creating two files, then generating a ZIP file (with regexpmapper to rename
files), wait a few seconds (just in case there's  FS timestamp problem) and
re-execute the same Zip task.
On Linux, the second Zip task doesn't do anything (as expected) as the
files are not modified.
On Windows, the Zip file is always updated. With -v, I'm getting :
      [zip] us/xx/xxtest.r added as us/xx/xxtest.r is outdated.
      [zip] us/zz/zztest.r added as us/zz/zztest.r is outdated.
Using Ant 1.9.7, JDK 1.8 on both systems.

Am I doing something wrong, or is there a bug ?

<?xml version="1.0" encoding="utf-8"?>
<project name="test">
 <mkdir dir="src" />
 <touch file="src/xxtest.r" />
 <touch file="src/zztest.r" />
 <zip destFile="">
    <fileset dir="src" includes="*.r" />
    <regexpmapper from="^(([a-z][a-z]).*)\.r" to="us/\2/\1.r" />
 <sleep seconds="5" />
 <zip destFile="">
    <fileset dir="src" includes="*.r" />
(Continue reading)

Dave Glasser | 1 May 06:06 2016

Order of attributes signifificant in zipfileset?

I discovered this in ant 1.6.5, and found that it still behaves this way in 1.9.7.
If you have a <zipfileset> element with both a dir and a file attribute, it will produce different results
depending on the order in which those attributes appear. If the file attribute appears first, it behaves
as you would expect. For example, with this:
<zipfileset file="file1.txt" dir="dir1"/>
It looks for a file named "file1.txt" inside the directory "dir1". However, with this:
<zipfileset dir="dir1" file="file1.txt"/>
It looks for file1.txt inside the current working directory. This can be verified by running the
demonstration target I provide below with the -debug switch, and reading the debug output.
I want to make clear that I'm aware that the docs for fileset say:
"Either dir or file must be specified" and that I might be doing it wrong. You could argue otherwise, but
perhaps that does in fact unambiguously imply that having both is incorrect and hence the behavior is
undefined. Be that as it may, what I would like to know is this:
Is this a known, and expected behavior?  Is it documented anywhere?
Should I assume that the order of attributes is significant in other places throughout my build.xml file?
Here's a self-contained target that demonstrates this behavior:
  <target name="oa">
    <property name="JARCMD" value="jar"/>

    <!-- Delete both zip files if they exist. -->
    <property name="ZIP1" value=""/>
    <property name="ZIP2" value=""/>
    <delete file="${ZIP1}"/>
    <delete file="${ZIP2}"/>

    <property name="DIR1" value="dir1"/>
    <mkdir dir="${DIR1}"/>

    <!-- make sure there are no files named file1.txt or file2.txt in the
         current directory, so we know they're not being read from there. -->
(Continue reading)

Lancelot.MEURILLON | 26 Apr 11:25 2016

Multiple fileset and filelist comparisons

Hi all,

How would you  do to implement this with ANT ?

1- In a project A, there are 2 file trees with same directories and files but not at same revision
-----file1 (version 1.2)
-----file2 (version 2.3)
-----file3 (version 3.0)

-----file1 (version 1.2)
-----file2 (version 2.1)
-----file3 (version 3.0)

I need to compare those 2 file trees to get desynchronized files from 'DirRemote' (in order to synchronize
them with the latest revision further).
I can do this easily with 'different' selector on 'targetdir' DirRemote :
<fileset dir="${DirLocal}" includes="**/*.xml" id="desynchronizedMetadata">
    <different targetdir="${DirRemote}" ignoreFileTimes="true"/>

But this list of desynchronised files will be used by another project B, that's why I convert the fileset
'desynchronizedMetadata into a fileList using a pathconvert and echo file :
<pathconvert pathsep="${line.separator}" property="desynch.files" refid="desynchronizedMetadata">
    <regexpmapper from="^${DirLocal}/(.*)$" to="&lt;file name=&quot;\1&quot;/>" handledirsep="true"/>
(Continue reading)

Al Le | 26 Apr 08:53 2016

How to create a task associated a target


in my ant script, I do the following:

1. there is a target "calledTarget"

2. there is a task "macroTask", defined via "macrodef". This task contains in its body a call to
"calledTarget" (via "antcall").

3. there is a target "mainTarget" which contains a task "script" (javascript). In this script, I create an
instance of macroTask and then execute it.

Here's the picture as an outline:

<project default="mainTarget">

    <target name="mainTarget">
        <script language="javascript">
            var task = project.createTask("macroTask");
            // task.setOwningTarget(project.getTargets().get("mainTarget")); // This must be done to avoid NPE

    <macrodef name="macroTask">
            <antcall target="calledTarget"/>

(Continue reading)

KM | 18 Apr 21:00 2016

Ant 1.9.7, issue with evaluation of double quotes

 All As per the WHATSNEW file I see that one of the issues modified the interpretation/evaluation of quotes
within an ant argument, e.g.:
 * Ant fails to run when arguments contain double-quote character.
   Bugzilla Report 58898
I've requested a bugzilla login account and was planning to add a comment to this bug report, but I figured
I'd just post this here.
Previously with ant 1.9.6 and earlier the line expanded to -Dbr.cmd="co-r ", which is correct.   Now
afterupdating to Ant 1.9.7 the expansion is messed up.  It actually evaluates to '-Dbr.cmd="co'-r ' "
'  including all of thequotes shown.  It’s hard to read so I addedspaces around the one double quote at
the end.  It actuallylooks like ‘”’.  Then ant gives the error -r option invalid.  
I am assuming it's the modifications for 58898 that are causing this.   
Needless to say, that I can modify the scripts we use, so the field itself does not contain the double quotes,
and that the field is only surrounded by them.  But I was surprised that my build failed almost
immediately as ant was kicked off.
Is anyone else seeing issues with double quotes in Ant 1.9.7? Thanks, just wanted to supply the info.KM

Stefan Bodewig | 12 Apr 20:03 2016

[ANN] Apache Ant 1.9.7 Released

The Apache Ant Team is pleased to announce the release of Apache Ant

Version 1.9.7 is mostly a bug fix release but adds a few new features
like support for arbitrary filesyste resources in <scp> and initial
support for Java9 modules.

Apache Ant is a Java library and command-line tool that helps building

Source and binary distributions are available for download from the
Apache Ant download site:

When downloading, please verify signatures using the KEYS file available
at the above location when downloading the release.

Changes in this version include:

Changes that could break older environments:

 * <exec> and <apply> used to ignore the dir attribute if it was the
   same as the current working directory.  They now no longer do,
   which changes the behavior for vmlauncher="false" which would have
   used the project's basedir rather than the current working
   directory in that case.
(Continue reading)

Al Le | 12 Apr 17:45 2016

MacroDef: Setting attribute via API should convert to lowercase


in my ant script, I define a task "MyTask" via "macrodef". The task has a mandatory attribute "nodeName"
(not the camelCase name).

Then I call the task from a javascript snippet:

var myTask = project.createTask('myTask');
myTask.setDynamicAttribute("nodeName", "blah");

This does not work because I use the camleCase name in the call to setDynamicAttribute. Later, when the task
is performed, I get an error that the attribute "nodename" (lowercase!) is not set.

In the source of MacroInstance I see that attribute names are converted to lower case when they are
retrieved. But why are they not converted when they are set?

When I use this (note the lowercase name)

    myTask.setDynamicAttribute("nodename", "blah");

everything works. But here I''m forced to use an attribute name I didn't specify (I specified "nodeName").

Why is it made this way?

I see one reason for converting everything to lower case -- to avoid errors due to a wrong capitalizing. But
then the conversion should be done everywhere, i.e. when getting and when setting the attributes.

(Continue reading)

Al Le | 16 Mar 20:05 2016

How to set content type in "get" task?


in our ant script, we use the "get" task to fetch some data from the server via HTTP GET. The server interprets
the 'Content-Type' header of the request and delivers the response in the appropriate format (html/xml/json).

We'd like to have the result as XML and hence would need to set the content type header of the HTTP request.

Is this possible using the standard get task? If yes, how?

I've only found the 'useragent' attribute in the task but no means to set some other HTTP headers.

Al Le | 7 Mar 07:37 2016

XSL transformation with Ant: sorting a list


I'm facing a weird problem (IMHO) which, in short, is:

a node list passed as a parameter to a template can't be sorted.

The problem occurs only if I do the transformation from within Ant (I use Ant 1.8.4). It does not occur if I
perform it via a Java program or in XmlSpy or through

Here's an example.

The input file (a.xml) is:


The transformation (trans.xml) is:

<xsl:stylesheet version="1.0" 

  <xsl:output method="xml" />

  <xsl:template match="/">
      <xsl:call-template name="processThis">
        <xsl:with-param name="nodeList" select="/*/a"/>
(Continue reading)

Petronius | 4 Mar 18:13 2016

Passing command Line args for a list


We are tyring to automate an ant task, but finding it impossible to pass a 
command line argument to a property inside a list.  

We need to pass Name and Description for each agent specified from the 
command line.  for ex:
ant -f build.xml addNodes -Dagents="d01, d02, d03" -D{node???}='node1' -
D{node_description???}='node1 description'

each agent d01/d02/d03 will need have name and description.

<target name="addNodes" depends="clean">
  <input message="Agents Name Seperated By , :" addproperty="agents" />
  <for list="${agents}" delimiter="," param="agent">
      <input message="Node Name:" addproperty="node" />
      <input message="Node Description:" addproperty="node_description" />
             <!-- external task -->
         <var name="node" unset="true"/>

Any suggestions is greatly appreciated.

(Continue reading)