Search code examples
scalasbtscalajs-react

how to create a scala sbt project model which represents a model to other sbt projects?


i have a scala js sbt project, i developped in this project new user interface components.

the person p1 has a project with the same structure (same build.properties & plugins.sbt), how can he access to my user interface components.

Should i add some specification in build.sbt ?


Solution

  • If you want to share some project settings, you can create a sbt plugin - it will allow you to have some common settings, add dependencies to other sbt plugins and even override their configuration. See for example sbt-softwaremill as a example of plugin that is used to share some commons between projects.

    It won't magically update all configs, because:

    • build.properties is evaluated before the sbt code is run
    • you have to add this plugin to plugins.sbt
    • you have to create project structure in each project

    Any more config sharing than that is theoretically possible by e.g. using git submodules and commiting symlinks to repo, but that would be pretty wrong - any change to one project would result in a change in another project, and you have them separated for a reason - if both projects were the same you would have one project in the first place.

    And if you are need to share the code itself, you can build the code, publish it to an artifactory and add dependency in another project.

    But that's only if you really have two projects, and it's entirely possible that you just need to have one git project with different branches, where ever developer would work on their own branch and then merge changes to common branch, bacause that's the point of using git.