I created an sbt project. Calling sbt compile on the command line works well:
$:[...]/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
The external libraries aren't added to a lib_managed directory, but to ~/.ivy2. Nevertheless compiling and using the dependencies in my classes works fine. Creating an eclipse project also works fine:
$:[...]/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
But eclipse then can't compile the project, because it's missing a package that should be offered by a managed library (namely scalatest isn't found). Why is this managed dependency not added to eclipse?
Here my project definition files:
- Sources are in src/main/scala respective src/test/scala
build.sbt
name := "MyProject"
version := "0.1"
scalaVersion := "2.9.2"
project/plugins.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
project/build.sbt
libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"
I'm using SBT 0.11.3 and Eclipse Indigo.
edit:
The created .classpath from eclipse looks like:
<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:
I now found out that "sbt test" on the console also isn't working. So I think it isn't a problem of sbteclipse, but of how to handle dependencies for test cases. I asked a new question according to this, because my assumptions for asking this question were wrong: sbt: Add dependency on scalatest library. Where?
sbt eclipse
create a.classpath
file in your project directory? If so, does that file contain an entry for scalatest? – dhg