配置蚂蚁scala
发布时间:2020-12-16 09:37:13 所属栏目:安全 来源:网络整理
导读:如何为scala安装antlib.xml以蚂蚁工作? 现在我在包含Scala任务的build.xml文件上运行ant时遇到以下错误。 [taskdef] Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found./scalala/scalala-read-only/scalala/bui
如何为scala安装antlib.xml以蚂蚁工作?
现在我在包含Scala任务的build.xml文件上运行ant时遇到以下错误。 [taskdef] Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found. /scalala/scalala-read-only/scalala/build.xml:36: Problem: failed to create task or type scalac 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. 我已经解散了scala-2.8.1.final/lib/scala-compiler.jar,但是我不知道放置内容的位置。 以下是build.xml中相应的ant代码段: <target name="compile" depends=""> <mkdir dir="${build.dir}"/> <scalac srcdir="${src.dir}" destdir="${build.dir}" classpathref="project.classpath" force="changed"> <!-- addparams="-Yclosure-elim -optimise" --> <include name="**/*.scala"/> </scalac> </target> 回答 以下代码在build.xml文件中很重要: <!-- Define project CLASSPATH. --> <path id="project.classpath"> <pathelement location="${build.dir}" /> <fileset dir="${env.SCALA_HOME}/lib/"> <include name="*.jar" /> </fileset> <fileset dir="${lib.dir}"> <include name="*.jar" /> </fileset> </path> <!-- Define scala compiler,scaladoc,etc command --> <taskdef resource="scala/tools/ant/antlib.xml"> <classpath> <pathelement location="${env.SCALA_HOME}/lib/scala-compiler.jar" /> <pathelement location="${env.SCALA_HOME}/lib/scala-library.jar" /> </classpath> </taskdef> 我的问题是$ SCALA_HOME环境变量($ {env.SCALA_HOME})指向错误的地方(一级太深:/usr/local/scala-2.8.1.final/bin/而不仅仅是/usr/local/scala-2.8.1.final /,因此找不到lib目录。 解决方法
antlib.xml包含在scala-compiler.jar中。你必须把它放入你的类路径。要定义scalacant任务,请将以下定义放入您的ant构建文件(从
http://www.scala-lang.org/node/98开始):
<target name="init"> <property name="scala-library.jar" value="${scala.home}/lib/scala-library.jar" /> <path id="build.classpath"> <pathelement location="${scala-library.jar}" /> <!--<pathelement location="${your.path}" />--> <pathelement location="${build.dir}" /> </path> <taskdef resource="scala/tools/ant/antlib.xml"> <classpath> <pathelement location="${scala.home}/lib/scala-compiler.jar" /> <!-- NEW: For scala 2.10.2 you need scala-reflect: --> <pathelement location="${scala.home}/lib/scala-reflect.jar" /> <pathelement location="${scala-library.jar}" /> </classpath> </taskdef> </target> 要使用scalac任务,请将属性depends =“init”添加到您的任务中,例如 <target name="compile" depends="init"> <mkdir dir="${build.dir}"/> <scalac srcdir="${src.dir}" destdir="${build.dir}" classpathref="project.classpath" force="changed"> <!-- addparams="-Yclosure-elim -optimise" --> <include name="**/*.scala"/> </scalac> </target> 我希望,这有帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |