2017-08-03 276 views
1

我得到這個錯誤未能建立與日食(螞蟻常春藤)一個Liferay的項目

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. 

似乎在那裏我定義屬性名=「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},但我可以在哪裏定義它?

+0

它看起來就像你試圖用螞蟻的contrib的''任務,但是您尚未在腳本中加載ant-contrib的任務。爲了記錄,我建議不惜一切代價避免使用ant-contrib。它會導致腳本中出現系統性問題,絕大多數時候,vanilla Ant會更加快速,安全和優雅地滿足您的需求。 – CAustin

回答

0

正如@CAustin所解釋的,您的問題是「if」任務不是標準的ANT功能。它是ANT的第三方擴展的一部分,名爲ant-contrib,我同意這最好避免。

如果要自動常春藤的條件安裝,你可以試試下面的:

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

     .. 
     ..  

希望這有助於

+0

謝謝,它爲我工作! –