可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to use the foreach loop in an Ant script but I get the message: Problem: failed to create task or type foreach Cause: The name is undefined.
I don't understand why this doesn't work. It is not a 3rd party library. It is a standard task that would be part of the latest version of Ant (1.8).
回答1:
It is a standard task that would be part of the latest version of Ant (1.8).
No, it's not. At least I can't find it in the list of core and optional tasks in the ant manual. It seems to be part of the ant-contrib project and thus needs to be installed separately.
回答2:
have you ever considered
? in this tag you can use some famous script language like javascript and python. they can also interact with the Project, Task... Object of Ant, which means you can set/get the properties and even excute another task. look at this example which comes from the book "java development with ant"
Use a script task to generate a random number, then print it Random number is ${random}
回答3:
I can't find the foreach task in the Ant 1.8 manual - where is it? I only know the task from ant-contrib, and it requires to specify the 'target' attribute: http://ant-contrib.sourceforge.net/tasks/tasks/foreach.html
回答4:
I had the same issue under eclipse with various versions of ant.
Add this into your code WITHOUT adding parameters under eclipse (do not specify any classpath) :
回答5:
You haven't defined a target to call:
alternatively: