Search code examples
scalasbtmulti-project

Use deployed artifacts instead of local project in sbt multi project build


I have an sbt multi-project build

lazy val a = project

lazy val b = project.dependsOn(a)

I continuously work on a and b. Sometimes I want to release a new version of b without releasing a new version of a. Of course this requires that b is still compatible to the last released a. How do I easily test this? When I compile and run tests in b it will use my local source code of a, but that often has changed. Instead I would like to compile and test b against the last released artifact of a. I would basically need to be able to temporarily override the behavior. Any ideas :)?


Solution

  • Here's a mechanism to break ALL inter-project dependencies:

    val useExternalDeps = settingKey[Boolean]("If true, we don't use inter-project dependencies")
    
    lazy val a = project
    lazy val b = project.dependsOn(a).settings(
       useExternalDeps := false,
       fullResolvers := {
          if(!useExternalDeps.value) fullResolvers.value
          else fullResolvers.value.filterNot(_.name == "inter-project")
       }
    )
    

    Simply call set useExternalDeps := true in the sbt shell and then Ivy/sbt will stop looking between projects for artifacts.