Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sbt-modules plugin to simplify build #191

Merged
merged 9 commits into from
Jun 8, 2020

Conversation

alejandrohdezma
Copy link
Collaborator

I came up with an idea of creating an SBT plugin to help us simplify a very common pattern in Scala projects:

  • The different modules of the project live inside modules folder.
  • Only those projects are published.
  • Usually, there are other projects (documentation, microsite...) that depend on all the "modules".

For this, we will usually need to add .in(file("modules/my-module")) to every project, skip in publish := true to others and create a list val allProject = List(projectA, projectB...) that aggregates all the modules.

This pattern is utterly simplified with sbt-modules.

Here is an example of what is achieved:

- skip in publish := true
- 
lazy val docs = project
-  .settings(skip in publish := true)
-  .dependsOn(allProjects: _*)
+  .dependsOn(allModules: _*)
  .in(file("docs"))

+ lazy val `my-library-core` = module
- lazy val core = project
-   .in(file("modules/core"))
-   .settings(name := "my-library-core")

+ lazy val `my-library-plugin` = module 
- lazy val plugin = project
-   .in(file("modules/plugin"))
-   .settings(name := "my-library-plugin")
-   .dependsOn(core)
+   .dependsOn(`my-library-core`)
-
- lazy val allProjects: Seq[ClasspathDep[ProjectReference]] = Seq(
-   core,
-   plugin
- )

Please let me know what do you think about this 😸

This plugin will allow using `module` for creating projects that live inside `modules` easily.
`sbt-modules` sets `skip in publish := true` for all projects except the ones declared with `module`
This list contains all modules declared using `module`
@codecov
Copy link

codecov bot commented Jun 4, 2020

Codecov Report

Merging #191 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #191   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files          11       11           
  Lines          78       78           
  Branches        1        1           
=======================================
  Hits           77       77           
  Misses          1        1           
Impacted Files Coverage Δ
...-cats/src/main/scala/memeid4s/cats/instances.scala 100.00% <ø> (ø)
...d4s-cats/src/main/scala/memeid4s/cats/syntax.scala 100.00% <ø> (ø)
...bie/src/main/scala/memeid4s/doobie/instances.scala 100.00% <ø> (ø)
...p4s/src/main/scala/memeid4s/http4s/instances.scala 100.00% <ø> (ø)
...teral/src/main/scala/memeid4s/literal/Macros.scala 66.66% <ø> (ø)
...cala/memeid4s/scalacheck/arbitrary/instances.scala 100.00% <ø> (ø)
...odules/memeid4s/src/main/scala/memeid4s/UUID.scala 100.00% <ø> (ø)
...4s/src/main/scala/memeid4s/digest/Digestible.scala 100.00% <ø> (ø)
...s/memeid4s/src/main/scala/memeid4s/node/Node.scala 100.00% <ø> (ø)
.../memeid4s/src/main/scala/memeid4s/time/Posix.scala 100.00% <ø> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2df0210...237ed35. Read the comment docs.

Copy link
Member

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+19 -42, I buy it! 🙂

@alejandrohdezma alejandrohdezma merged commit cb81f28 into master Jun 8, 2020
@alejandrohdezma alejandrohdezma deleted the feature/sbt-modules branch June 8, 2020 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants