Ant: Problem: failed to create task or type propertyregex

怎甘沉沦 提交于 2019-12-09 16:12:34

问题


I'm using Ant 1.8.1. I have downloaded ant-contrib-1.0b3.jar and placed it in my $ANT_HOME/lib directory. However, when I include this in my build.xml file ...

<propertyregex property="selenium.email.success.subject"
          input="package.ABC.name"
          regexp="(.*)__ENV__(.*)"
          replace="\1${buildtarget}\2"
          override="true"
          casesensitive="false" />

I get the error "Problem: failed to create task or type propertyregex. Cause: The name is undefined." upon running my Ant build file. What else do I need to do to get this task recognized?


回答1:


The propertyregex ant task is part of ant-contrib, and not included by default in any apache-ant installation.

You have to properly install ant-contrib. From the ant-contrib page, you have two choices:

  1. Copy ant-contrib-0.3.jar to the lib directory of your Ant installation. If you want to use one of the tasks in your own project, add the line <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> to your build file.

  2. Keep ant-contrib-0.3.jar in a separate location. You now have to tell Ant explicitly where to find it (say in /usr/share/java/lib):

    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="/usr/share/java/lib/ant-contrib-0.3.jar"/>
    </classpath>
    </taskdef>




回答2:


I leave it here. I've experienced the similar error some time ago while I tried to compile my python project in IntelliJ IDEA. In my case it was required to specify custom Ant (check Use custom Ant radio button) instead of the default one. After I made those updates everything worked fine. Please find the screenshot below.

That worked for me, hope it'll be helpful.



来源:https://stackoverflow.com/questions/6510691/ant-problem-failed-to-create-task-or-type-propertyregex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!