SBT: how to make subprojects dependent on each other during dev, as well as when publishing as maven artefacts?

During dev, I use the following syntax:

lazy val root = project.in(file(".")).dependsOn(runner)

But for publication I need this:

libraryDependencies += ... % ... % ... 

But I do not want the creature to libraryDependenciesexist during dev, otherwise I would have to publish a local compiler, which is annoying. Is there a good solution without commenting on it and putting it back during publication?

+3
source share
1 answer

Do not add subprojects like libraryDependencies, not even at the time publish.

Now for publishing modules you can create a simple variable publishSettings:

val publishSettings : Seq[Setting[_]] = Seq(
    publishTo := Some("your company releases" at "http://yourrepository"),
    credentials += Credentials(
      "Repository",
      "repositoryUrl",
      "username",
      "password!"
    ),
    publishMavenStyle := true,
    publishArtifact in Test := false,
    pomIncludeRepository := { _ => true }
  )

lazy val main = Project(..).aggregate(subproject1, subproject2, // etc)

lazy val subproject1 = Project(
  settings = Project.defaultSettings ++ publishSettings
);
lazy val subproject2 = Project(
  settings = Project.defaultSettings ++ publishSettings
).dependsOn(subproject1)

SBT . libraryDependencies, dependsOn.

+4

All Articles