Làm cách nào để cài đặt antlib.xml cho scala để nhận kiến hoạt động?định cấu hình kiến cho scala
Ngay bây giờ tôi gặp phải lỗi sau khi tôi chạy ant
trên tệp build.xml chứa các tác vụ scala.
[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.
Tôi chưa hủy scala-2.8.1.final/lib/scala-compiler.jar
nhưng tôi không biết đặt nội dung ở đâu.
Dưới đây là đoạn mã ant tương ứng từ build.xml:
<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>
trả lời
Các mã sau đây là rất quan trọng để có trong file build.xml của bạn:
<!-- 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>
Vấn đề của tôi là biến môi trường $SCALA_HOME
(${env.SCALA_HOME}
) đã trỏ đến sai địa điểm (một cấp quá sâu: /usr/local/scala-2.8.1.final/bin/
thay vì chỉ /usr/local/scala-2.8.1.final/
và do đó không thể tìm thấy thư mục lib
.
Có lẽ bạn nên đăng đoạn mã ant có liên quan. Có lẽ bạn không có một typedef cho scalac trong build.xml của bạn – Raghuram