سؤال

I just want to create a directory layout for my scala project with sbt and sbteclipse. Following is my sbt file.

import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys

name := "BGS"

organization := "com.example"

version := "1.0.0"

scalaVersion := "2.9.2"

scalacOptions ++= Seq("-deprecation")

EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource

EclipseKeys.projectFlavor := EclipseProjectFlavor.Scala

scalaSource in Compile <<= (sourceDirectory in Compile)(_ / "scala")

scalaSource in Test <<= (sourceDirectory in Test)(_ / "scala")

libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"

libraryDependencies += "junit" % "junit" % "4.10" % "test"

unmanagedBase <<= baseDirectory { base => base / "lib" }

unmanagedJars in Compile <<= baseDirectory map { base => (base ** "*.jar").classpath }

In this sbt file, I had to use folling to lines to force creation of Scala directories:

scalaSource in Compile <<= (sourceDirectory in Compile)(_ / "scala")

scalaSource in Test <<= (sourceDirectory in Test)(_ / "scala")

Furthermore, after running "eclipse" from sbt console, I imported the project to Eclipse, but I could not create Scala class. Eclipse project icon has "J" letter attached to it indicating it is a Java project :-?

Why does sbt and sbteclipse default to Java?

I am running sbt version 0.12 (latest version as of Nov 2012), scala 2.9.2

For your information, what I am aiming to do is use sbt to create working project with following directory structure:

├── build.sbt
├── lib
│   ├── biojava3-core-3.0.4.jar
├── project
│   ├── plugins.sbt
│   ├── project
│   │   └── target
│   └── target
│       ├── config-classes
│       ├── scala-2.9.2
│       └── streams
├── src
│   ├── main
│   │   ├── java
│   │   ├── resources
│   │   └── scala
│   └── test
│       ├── java
│       ├── resources
│       └── scala
├── target
│   ├── scala-2.9.2
│   │   ├── cache
│   │   ├── classes
│   │   └── test-classes
│   └── streams
│       └── compile
└── test
هل كانت مفيدة؟

المحلول

Since I haven't got any desirable answers so far, I am trending into Typesafe Stack. I removed manually-installed scala and sbt and I am using everything from Typesafe Stack. I will update more when I am done testing with this way.

Here is the final update as I promised:

I followed instruction in this link and it worked perfectly: http://typesafe.com/resources/typesafe-stack/downloading-installing.html

Detailed information in case somebody want to follow for Mac OSX:

Basically, I first I switched macport to homebrew following instruction here:

http://bitboxer.de/2010/06/03/moving-from-macports-to-homebrew/

Then I did:

brew install scala sbt maven giter8

Then create a Scala project from command line:

g8 typesafehub/scala-sbt

Finally I followed instruction here to add sbteclipse and convert the project to eclipse:

https://github.com/typesafehub/sbteclipse

Everything works as I expect.

نصائح أخرى

Why do you want sbt to create those directors? why not jsut create them yourself. It's a one time event.

You shouldnt need any of the following lines

EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource

EclipseKeys.projectFlavor := EclipseProjectFlavor.Scala

scalaSource in Compile <<= (sourceDirectory in Compile)(_ / "scala")

scalaSource in Test <<= (sourceDirectory in Test)(_ / "scala")

I normally just do mkdir -p src/main/scala whenever I start a new project.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top