简体   繁体   中英

Failing to build a liferay project with eclipse (Ant ivy)

I'm getting this error

BUILD FAILED
C:\---\---\---\build-common-ivy.xml:7: Problem: failed to create task or type if
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

It seems to fail at the line where i define the property name="ivy.home":

<project name="build-common-ivy" xmlns:antelope="antlib:ise.antelope.tasks" xmlns:ivy="antlib:org.apache.ivy.ant">
    <property name="ivy.home" value="${sdk.dir}/.ivy" />

<if>
        <not>
            <available file="${ivy.home}/ivy-${ivy.version}.jar" />
        </not>
        <then>
          ...

I think it's the ${sdk.dir} that isn't defined, but where I can define it?

As explained by @CAustin your issue is that the "if" task is not a standard ANT feature. It's part of the 3rd party extension to ANT, called ant-contrib , and I would agree it's best avoided.

If you want to automate the conditional installation of ivy, try something like the following:

<project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">

    <available classname="org.apache.ivy.Main" property="ivy.installed"/> 

    <target name="install-ivy" unless="ivy.installed">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
        <fail message="Ivy has been installed. Run the build again"/>
    </target>

    <target name="resolve" depends="install-ivy">
        <ivy:resolve/>

        ..
        ..    

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM