Home > Enterprise >  How to create Scala SBT multi independent project
How to create Scala SBT multi independent project

Time:06-15

I am trying to create sbt multi independent project.

I want my project structure some thing like

My Scala and sbt version is 2.12.2 and 1.5.5 respectively.

sbt-multi-project-example/
    common/
      project
      src/
        main/
        test/
      target/
      build.sbt
    multi1/
      project
      src/
        main/
        test/
      target/
      build.sbt
    multi2/
      project
      src/
        main/
        test/
      target/
      build.sbt
    project/
      build.properties
      plugins.sbt
    build.sbt

so I referred some github repo:

https://github.com/pbassiner/sbt-multi-project-example (project build is success but i want build.sbt in each individual modules.)

how can I create above project structure and basic idea is common project contains common methods and class. multi1(Independent project) uses common methods and it has its own methods and classes.

multi2(Independent project) uses common methods and it has its own methods and classes.

what are the changes I need to change in all build.sbt in order to achieve above scenario.

CodePudding user response:

This is the basic structure. As mentioned in the comments this can create a separate publishable artefact for each project so no need for a separate build.sbt

lazy val all = (project in file("."))
  .aggregate(common, multi1, multi2)

lazy val common =
  project
    .in(file("common"))
    .settings(
      name := "common",
      version := "0.1",
      // other project settings
    )

lazy val multi1 =
  project
    .in(file("multi1"))
    .settings(
      name := "multi1",
      version := "0.1",
    )
    .dependsOn(common)

  • Related