Exception when using ant.replace - org.apache.tools.ant.UnknownElement


I got a very simple doLast action inside an Exec task that looks like this

 ant.replace("dir": destinationDir, "value": tokenValue, token: "@@MYTOKEN")

Running the first time (after clean) I get an error

org.apache.tools.ant.taskdefs.ExecTask cannot be cast to org.apache.tools.ant.UnknownElement

Subsequent runs (also when not up-to-date) run fine.

Does anyone know where this error comes from (or why it only happens on the very first run) ?

Its gradle 2.4 on win7 64bit, jdk 7 64bit.

Problem seems to be the use of ant.exec in a thread pool (one of the task that is executed before). When this task is not run (up-to-date) I don’t see this exception…

I’ve noticed a similar issue. I tried to wrap ant calls in a loop around Gpars using withPool, but it would error with pool sizes greater than 1. I’m thinking perhaps its a classloader issue related to the threads created with Gpars.