今天用Ant编译Lucene时抛出错误:
ivy is not available
原来是缺少一个ivy插件,ivy插件是用来智能管理dependency的。项目主页是http://ant.apache.org/ivy/ ,只需将ivy-version.jar放入下列目录即可:
代码如下 | 复制代码 |
/usr/share/ant/lib ${HOME}/.ant/lib |
不过既然在用ant,那么不妨用ant自动将ivy放入它该去的地方。新建一个编译脚本:
代码如下 | 复制代码 |
<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant"> <target name="bootstrap" description="Install ivy"> <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.3.0/ivy-2.3.0.jar"/> </target> <target name="resolve" description="Use ivy to resolve classpaths"> <ivy:resolve/> <ivy:report todir='build/ivy-reports' graph='false' xml='false'/> <ivy:cachepath pathid="compile.path" conf="compile"/> <ivy:cachepath pathid="test.path" conf="test"/> </target> <target name="clean" description="Cleanup build files"> <delete dir="build"/> </target> <target name="clean-all" depends="clean" description="Additionally purge ivy cache"> <ivy:cleancache/> </target> </project> |
然后一句ant bootstrap就完工了
时间: 2024-09-23 05:24:41