The java build world is perverse. Maven and Ant are imperative, highly limited, domain specific languages using XML for syntax.
Maven is declarative, not imperative.
Ant is broken in many respects, but your provided example is not true. Ant only attempts re-encoding of a file if you specify text filters (aka variable/string replacement). It shouldn't be a surprise to anyone that string replacement breaks on binary files.