commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Lynch" <>
Subject [Jelly] Ant <filterset> in jelly script issues
Date Wed, 20 Nov 2002 06:33:25 GMT

I tried to write a Jelly Unit test case for Ant filtersets. Thanks James
Strachan for the pointers.

Here is my test case I used:

<!-- test case to show how filtersets are broken -->
<test:case name="antFilterset">

  <ant:filterset id="maven.webserver.filterset.default">
      <ant:filter token="maven.webserver.home" value="some dir" />
  <ant:copy file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
    <ant:filterset refid="maven.webserver.filterset.default" />

[java] [ERROR] AntTag - -Class org.apache.commons.jelly.tags.junit.CaseTag
doesn't support the nested "filterset" element.
    [java]      [echo]
    [java]      [echo]
    [java]      [copy] Copying 1 file to

Before the copy AntFilterset.txt file contains simply:


After the copy, u guessed it:


Needless to say the filter token was not replaced in the copied file. Something
needs to be done in order for the filterset to be nested in the case tag for

To assert if the filter succeeds, I was going to read in the copied property
file and then test the property in the for it's value.

Please note...

This failed case has been around in Maven for a long time. To reproduce in
Maven, define a goal similar to this one, assuming all properties are set in a

<goal name="testFilterset">

    <ant:filterset id="maven.webserver.filterset.default">
      <ant:filter token="maven.webserver.home" value="${maven.webserver.home}"
      <ant:filter token="" value="${}"
      <ant:filter token="maven.webserver.version"
value="${maven.webserver.version}" />
      <ant:filter token="maven.webserver.port.http"
value="${maven.webserver.port.http}" />
      <ant:filter token="maven.webserver.port.https"
value="${maven.webserver.port.https}" />
      <ant:filter token=""
value="${}" />
      <ant:filter token="maven.webserver.port.two"
value="${maven.webserver.port.two}" />
      <ant:filter token="maven.webserver.port.three"
value="${maven.webserver.port.three}" />
      <ant:filter token="maven.webserver.conf.dir"
value="${maven.webserver.conf.dir}" />
      <ant:filter token="" value="${}"

    <!-- copy any user configuration files w/ filtering by forcing copy -->
    <!-- expecting at least a httpd.conf -->
    <ant:copy todir="${maven.webserver.dir}" overwrite="true">
          <ant:fileset dir="${maven.webserver.conf.dir}" />
          <ant:filterset refid="maven.webserver.filterset.default" />
          <ant:filterset refid="maven.webserver.filterset" />

Any files copied that contain any tokens do not get filtered with their property

The only case I have found filtersets to work is demonstrated by Maven Cactus
plugin. Here is an example from Maven's Cactus plugin:

<copy todir="${}"
      file="${maven.cactus.configFile}" filtering="on">
        <filter token="maven.cactus.port" value="${maven.cactus.port}"/>

Poor Vincent ( Cactus plugin developer ) seems to be fooling himself that
filtersets are playing happily, and by rights he does get the token replaced in
his copied file. ( Hi Vincent :)

In this case the port number from gets replaced, but only
because the attribute filtering="on" is there and the nested filterset is not
using a refid. Not to mention that the nested filterset should work without
filtering="on" as per the Ant docs re that attribute of the copy task:

>From Ant documentation:
" Indicates whether token filtering using the global build-file filters should
take place during the copy. Note: Nested <filterset> elements will always be
used, even if this attribute is not specified, or its value is false (no, or
off). "

I looked at Jelly's off and on over the past month trying to figure
how to fix this, but no luck so far. This one haunts me.

( Attention Maven users: Any proposed fix should also consider what happens when
the filterset is defined in a prereq goal and referenced inside a goal inside an
jelly script imported into the script which defines the filterset. :) )

Any Jelly gurus know what is up?


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

View raw message