我正在尝试使用Eclipse作为我的IDE,我已经安装了sbt作为Eclipse的构建工具,sbteclipse作为Eclipse的构建工具插件。我遵循了sbteclipse教程http://www.atsnippets.com/development/starting-with-simple-build-tool-sbt-for-scala.html,使我的目录结构看起来如下所示:
HelloWorld
\- src
\-main
\-scala
\-java
\-test
\scala
\java
\target
\-scala-2.9.1
\-streams现在,我想使用Eclipse作为我的编辑器(我喜欢它的检查、自动完成等功能)。但是,我不知道如何让Eclipse理解上面的目录布局(我不能将上面的目录作为我的项目导入,或者我没有找到正确的方法)。有没有人能分享一下经验?
然后,我尝试了另一种方式开始我的玩具项目:我使用Eclipse创建了一个scala项目。然而,目录结构也不是我想要的。这是我的目录通过"New Scala Project","New Package (com.foo.hello)“操作得到的结果
HelloWorld
\-src
\-com
\-foo
\-hello这也不是我想要的,因为我想把main和test分开。有什么推荐的方法吗?
发布于 2012-05-16 22:48:41
通过Right-click -> New... -> Folder在HelloWorld项目下创建您想要的目录结构。然后在main和test文件夹Right-click -> Build Path -> Use as Source Folder上
发布于 2012-05-17 05:01:57
SBT Eclipse应该生成一个项目文件,其中所有内容都已正确设置。在任何构建文件更改之后,您确实需要运行"sbt update“,然后重新生成eclipse项目文件。我怀疑这可能是你的问题。
它应该生成两个文件,.project和.classpath,如下所示:
<projectDescription>
<name>default-0d85ea</name>
<buildSpec>
<buildCommand>
<name>org.scala-ide.sdt.core.scalabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.scala-ide.sdt.core.scalanature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>和
<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 path="org.scala-ide.sdt.launching.SCALA_CONTAINER" kind="con"></classpathentry>
<classpathentry path="/home/dcs/.ivy2/cache/org.scalacheck/scalacheck_2.9.2/jars/scalacheck_2.9.2-1.9.jar" kind="lib"></classpathentry>
<classpathentry path="/home/dcs/.ivy2/cache/org.scala-tools.testing/test-interface/jars/test-interface-0.5.jar" kind="lib"></classpathentry>
<classpathentry path="/home/dcs/.ivy2/cache/org.scala-lang/scala-swing/jars/scala-swing-2.9.2.jar" kind="lib"></classpathentry>
<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"></classpathentry>
<classpathentry path="bin" kind="output"></classpathentry>
</classpath>请注意,在后一个文件中,src/main/scala和src/main/java被添加为src条目。
发布于 2012-05-16 22:50:34
尝试手动创建空项目和添加文件夹(右键单击项目新建->文件夹)。然后在项目属性中设置builder并(可选)创建运行配置。
https://stackoverflow.com/questions/10620732
复制相似问题