1

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
biocyberman
  • 5,675
  • 8
  • 38
  • 50

2 Answers2

1

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.

biocyberman
  • 5,675
  • 8
  • 38
  • 50
0

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.

Ivan Meredith
  • 2,222
  • 14
  • 13
  • Without those lines,"src/main/scala" and "src/test/scala" won't be created in my machine (Mac OSX). I want to do this to learn more about sbt and eventually do more advanced stuffs with one sbt configuration. Googling shows that previous sbt versions let users create project structures by questions and answers. This is not the case in 0.12 version. It seems to do more things automatically but fails to offer the first basic step to get users started :-( – biocyberman Nov 25 '12 at 11:46
  • I don't understand whats so hard about creating those directories yourself. Once they are created they dont go away. – Ivan Meredith Nov 26 '12 at 04:55
  • 1. Let's say I am trying to test sbt functionality. I am so keen to see how a sbt configuration file works. – biocyberman Nov 27 '12 at 21:54