Reputation: 91999
I am new to SBT
and trying to build a project. My Build.scala
looks like
lazy val ec = project.in(file("."))
.settings(commonSettings: _*)
.settings(name := "ec")
.aggregate(ahka, currentLogProcessor, main)
lazy val currentLogProcessor = project.in(file("currentLogProcessor"))
.settings(commonSettings: _*)
.settings(name := "currentlogprocessor")
.settings(
libraryDependencies += "com.myorg.util" % "LP" % "0.18.0-SNAPSHOT" % "provided"
)
lazy val main = project
.settings(commonSettings: _*)
.settings(name := "main")
When SBT
refreshes in IntelliJ
, I see following
As you could see, even if the settings looks same for currentLogProcessor
and main
, the project structure is very very different.
project
inside currentLogProcessor
looks good but project
under main
is layer with project
and src
What is the issue here? How can I remove the layers of project inside project?
Thanks
Upvotes: 0
Views: 107
Reputation: 74679
The answer by @ka4eli is correct, but I'd like to point out few issues with the build definition that can make understanding it so much painful.
lazy val ec = project.in(file("."))
.settings(commonSettings: _*)
.settings(name := "ec")
.aggregate(ahka, currentLogProcessor, main)
You don't need it whatsoever as it's defined automatically anyway - you're just repeating what sbt does implicitly. Just remove it from the build and add build.sbt
with the following:
commonSettings
lazy val currentLogProcessor = project.in(file("currentLogProcessor"))
.settings(commonSettings: _*)
.settings(name := "currentlogprocessor")
.settings(
libraryDependencies += "com.myorg.util" % "LP" % "0.18.0-SNAPSHOT" % "provided"
)
By default, lazy val
's name is used to call a project project
macro should point to, i.e. no need for in(file("currentLogProcessor"))
. The same applies to the name
setting - you're using all-lowercase name that may or may not be needed.
Use build.sbt
under currentLogProcessor
directory to have the same effect:
name := "currentlogprocessor"
commonSettings
libraryDependencies += "com.myorg.util" % "LP" % "0.18.0-SNAPSHOT" % "provided"
It's that simple.
Apply the rules to the main
project.
Have fun with sbt = it's so simple that people hardly accept it and mess up build definitions on purpose to claim otherwise :)
Upvotes: 0
Reputation: 5424
Your projects ec and main share the same folder. Remove main or ec, or change "in file" for one of them.
lazy val main = project in file("another_path") ...
Upvotes: 1