【问题标题】:Failing to build a liferay project with eclipse (Ant ivy)无法使用 eclipse (Ant ivy) 构建 liferay 项目
【发布时间】:2018-01-10 22:28:11
【问题描述】:

我收到了这个错误

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.

在我定义属性 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>
          ...

我认为是 ${sdk.dir} 没有定义,但我可以在哪里定义它?

【问题讨论】:

  • 您似乎正在尝试使用 ant-contrib 的 &lt;if&gt; 任务,但您尚未在脚本中加载 ant-contrib 的任务。作为记录,我建议不惜一切代价避免使用 ant-contrib。它会导致脚本出现系统性问题,并且绝大多数情况下 vanilla Ant 会更快、更安全、更优雅地完成您需要的工作。

标签: java eclipse ant liferay-6 ivy


【解决方案1】:

正如@CAustin 所解释的,您的问题是“if”任务不是标准的 ANT 功能。它是 ANT 的第 3 方扩展的一部分,称为 ant-contrib,我同意最好避免使用它。

如果您想自动化 ivy 的条件安装,请尝试以下操作:

<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/>

        ..
        ..    

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2012-05-31
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    • 2013-07-12
    • 2015-03-20
    相关资源
    最近更新 更多