Getting an error “Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.”

后端 未结 6 1777
無奈伤痛
無奈伤痛 2020-12-17 09:54

I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found. when I am trying to ant build on

相关标签:
6条回答
  • 2020-12-17 10:24

    One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)

    However I receive this error without eclipse, in the pure ant.

    0 讨论(0)
  • 2020-12-17 10:31

    I fixed that this way:

    Add the JAR to the Ant runtime classpath entries.

    Window>Preferences>Ant>Runtime>Classpath

    Add the JAR to either Ant Home Entries or Global Entries.

    0 讨论(0)
  • 2020-12-17 10:36

    Check you have read permissions for the ant-contrib jar file.

    In our case after copying the file with another user it did not, giving the same error message.

    0 讨论(0)
  • 2020-12-17 10:39

    Use the below mentioned code in your build xml:

    <path id="ant.classpath">
    <pathelement location="${ant.jarPath}/ant.jar" />
    <pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
    </path>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
     <classpath refid="ant.classpath" />
    </taskdef>
    

    And in your build property file:

    ant.jarPath=D:/antjars

    And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars

    0 讨论(0)
  • 2020-12-17 10:40

    You can provide full path to the ant-contrib JAR explicitly using "classpath" element:

    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
      </classpath>
    </taskdef>
    
    0 讨论(0)
  • 2020-12-17 10:48

    It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.

    My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:

    <project name="ant-contrib-tasks" default="all">
    
        <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    
        <target name="bootstrap">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
        </target>
    
        <target name="all">
            <for param="file">
                <fileset dir="." includes="*.txt"/>
                <sequential>
                    <echo message="Found file @{file}"/>
                </sequential>
            </for>
        </target>
    
    </project>
    
    0 讨论(0)
提交回复
热议问题