Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build.scala:1: not found: object sbt

I am using sbt version 1.0

$ sbt version
[info] Loading project definition from /Users/harit/code/learningScala/project
[info] Set current project to learningScala (in build file:/Users/harit/code/learningScala/)
[info] 1.0

I am using IntelliJ IDEA v14.1.3 for my project and the structure looks like

enter image description here

As you may see that project was not able to resolve Build. When I try command-line to run sbt, I see

$ sbt 
[info] Loading project definition from /Users/harit/code/learningScala/project
[info] Set current project to learningScala (in build file:/Users/harit/code/learningScala/)
> compile
[info] Updating {file:/Users/harit/code/learningScala/}learningscala...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/harit/code/learningScala/target/scala-2.11/classes...
[error] /Users/harit/code/learningScala/Build.scala:1: not found: object sbt
[error] import sbt.Build
[error]        ^
[error] /Users/harit/code/learningScala/Build.scala:3: not found: type Build
[error] object MyBuild extends Build {
[error]                        ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 2 s, completed May 28, 2015 8:10:37 PM
> 

I am very new to Scala, sbt so no idea what is going wrong with it

like image 244
daydreamer Avatar asked May 29 '15 03:05

daydreamer


2 Answers

The MyBuild.scala was at root. It should be inside project folder. I made that change and now it works. Thanks to tpolecat on IRC who helped me with this

enter image description hereenter image description here

> compile
[success] Total time: 0 s, completed May 28, 2015 8:20:57 PM
> compile
[info] Updating {file:/Users/harit/code/learningScala/}learningscala...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[success] Total time: 0 s, completed May 28, 2015 8:21:22 PM
> 
like image 134
daydreamer Avatar answered Nov 07 '22 19:11

daydreamer


I have a multi-project sbt build, and two of the projects were declaring two of the same val in their build.sbt files. I moved the duplicated val (s) to the Build.scala in the root project as def, and error stopped. Found the answer here: https://github.com/sbt/sbt/issues/1465

example: val samza_gid = "org.apache.samza" in build.sbt file became def samza_gid = "org.apache.samza" in the Build.scala file.

like image 24
Jenn Avatar answered Nov 07 '22 18:11

Jenn