我创建了一个sbt项目。在命令行上调用sbt编译运行良好:
$:[...]/Scala-Parser$ sbt compile
[info] Loading global plugins from /home/[...]/.sbt/plugins
[info] Loading project definition from [...]/Scala-Parser/project
[info] Set current project to MyProject (in build file:[...]/Scala-Parser/)
[info] Updating {file:/home/heinzi/ftanml/Scala-Parser/}default-d86d09...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Done updating.
[info] Compiling 19 Scala sources to [...]/Scala-Parser/target/scala-2.9.2/classes...
[warn] there were 3 unchecked warnings; re-run with -unchecked for details
[warn] one warning found
[success] Total time: 7 s, completed 26.09.2012 11:01:18
外部库不是添加到lib_managed目录中,而是添加到~/. but 2中。不过,编译和使用我的类中的依赖项很好。创建eclipse项目也很好:
$:[...]/Scala-Parser$ sbt eclipse
[info] Loading global plugins from /home/[...]/.sbt/plugins
[info] Loading project definition from [...]/Scala-Parser/project
[info] Set current project to MyProject (in build file:[...]/Scala-Parser/)
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] MyProject
但是eclipse无法编译这个项目,因为它缺少了一个应该由托管库提供的包(即没有找到scalatest )。为什么这个托管依赖没有添加到eclipse中?
在这里,我的项目定义文件:
我使用的是SBT0.11.3和Eclipse。
编辑:
eclipse创建的.classpath如下所示:
<classpath>
<classpathentry output="target/scala-2.9.2/classes" path="src/main/scala" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.2/classes" path="src/main/java" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.2/test-classes" path="src/test/scala" kind="src"></classpathentry>
<classpathentry output="target/scala-2.9.2/test-classes" path="src/test/java" kind="src"></classpathentry>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"></classpathentry>
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"></classpathentry>
<classpathentry path="bin" kind="output"></classpathentry>
</classpath>
edit2:
现在我发现控制台上的"sbt测试“也不起作用。因此,我认为这不是sbteclipse的问题,而是如何处理测试用例的依赖关系。我据此提出了一个新问题,因为我提出这个问题的假设是错误的:sbt: Add dependency on scalatest library. Where?
发布于 2012-09-26 05:59:11
你应该加上
libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"
到根目录中的build.sbt,以将其识别为依赖项。
https://stackoverflow.com/questions/12598303
复制