-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I've been using ant for ... ever. And I just got caught by something
that I didn't expect.

I've come to expect that property values cannot be changed after they
have been set; that is, they are write-once and then they are constants.

Due to a mistake in a somewhat complicated build file, I discovered
that pattern sets can be redefined in a way that is fairly surprising
to this seasoned ant user.

For example:

  <target name="foo">
    <echo>${toString:property.file.pattern}</echo>
    <patternset id="property.file.pattern" includes="**/*.properties" />
    <echo>${toString:property.file.pattern}</echo>
    <patternset id="property.file.pattern" includes="**/*.xml" />
    <echo>${toString:property.file.pattern}</echo>
  </target>

Running this target will produce the following output:

foo:
     [echo] ${toString:property.file.pattern}
     [echo] patternSet{ includes: [**/*.properties] excludes: [] }
     [echo] patternSet{ includes: [**/*.xml] excludes: [] }

Surprised? I definitely was.

My problem was that I had a target somewhere with something similar to:

  <copy toDir="{dir}">
    <fileset dir="${properties.dir}">
      <patternset id="property.file.pattern" />
    </fileset>
  </copy>

Without realizing it, the above lines will redefine the patternset
called "property.file.pattern" to contain *nothing*. Oops. Definitely
my mistake, but ... I didn't really expect that ant would allow me to
override the previous definition of the patternset.

Is this intentional? Or should patternset definitions also be
immutable similar to property values?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5ISnEACgkQHPApP6U8
pFhKIg/+Lz9O0+CziqHFQ1+3cV9BAaMGiSRE2iDTRlxEPW9bDYie1cVwbrs6/NPm
UZZguCBKyna/qUoym+nGf3DqCoop79DFGacajIde35K2bCClZx2p3m6VCDvrFB8j
LCYcT2AgJrZYxvMIVVMMY5h1B9hzXCJol5VnjHLCakrwJtG4pLWxbkJ1ZlOUh7wM
qO39f6prH+4hpRdBKpFEG8UEg66Ywm33o9TNDy07qPpIyIJu8Zn/Fs3ttY6TVhfW
e4oav1aG+15nLi8QYpNQiMwoOzyWwb8rhJr2yLfTwBoynYfZMvbb4UsWDHaAIrjF
5LelZuOCVAyo/GMTkyrKddTZ4irBqa5X0Oxma2Lh7TJyzZtU3zpKak+aYhsfJ9/e
cvr11srZxpyj66CTOUEM16FAzujEqrRiV5kxs/oFisEMYgESm2qgib5+JBxeBQ6D
AI3K2JoscF958fGqphFCaYrk4KhOVoCFV4twz19xdJWyMvTjo01mxXKivrh3Aptm
9mS/PGt7VRIr8XSVhkRPvZq7adJxvfKinB1Y4NT2bGb1RmWHcVACwVVqRTbLRoAM
Z/NmMHDCf3YjA4+PwgbrrD5eG53rF0JBLBvOlQQ3sAJF16+pc+CKm4ZahWuO4Nii
cv42PVm2bhrAfXDC54ACHZqVs/EPrKCsppLy2FwSsqa5xk3UAPE=
=Zkat
-----END PGP SIGNATURE-----

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

Reply via email to