1
votes

I am just starting to learn sbt to build scala projects.

Here is my build.sbt file

lazy val commonSettings = Seq(
  organization := "com.example",
  version := "0.1.0",
  scalaVersion := "2.11.7"
)

lazy val task = taskKey[Unit]("An example task")


lazy val root = project.in(file(".")).
  aggregate(core).
  settings(commonSettings: _*).
  settings(
    task := { println("Hello!") },
    name := "hello",
    version := "1.0"
  )

  lazy val core = project.in( file("SbtScalaProjectFoo") )

My project structure is as follows

  SbtScalaProject
  |--SbtScalaProjectFoo
     |--build.sbt
  |--build.sbt

When I try to run "sbt" inside SbtScalaProject I get the following

No project 'core' in 'file:/Users/asattar/Dev/work/SbtScalaProject/'

What am I missing?

1
This works just fine for me. What version of sbt are you using? What OS? - mfirry
Mac Os X. The thing is it works fine if I don't have a build.sbt file in the SbtScalaProjectFoo, otherwise sbt compile fails with an error. I gave up on sbt after this and I will stick to maven for the time being for dependency management and build. I do want to get familiar with sbt eventually though, since its code its more fun than maven's xml syntax :) - Abdul Rahman
How does the build.sbt file in the SbtScalaProjectFoo look like? What do you need it for? - mfirry

1 Answers

0
votes

Having multiple build.sbt's has proven to make problems for me, too. I would recommend aggregating all project data into one build.sbt. If you want to modularize the build, consider moving parts into .scala-Files in (the root project's) project/ directory.