Skip to content

Commit

Permalink
set module name to match what we have in our docs (#88)
Browse files Browse the repository at this point in the history
* set module name to match what we have in our docs

refactor

* scalafmt
  • Loading branch information
pjfanning authored Oct 12, 2023
1 parent 8705d6e commit 5432db1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
34 changes: 16 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ lazy val core =
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.core)
.settings(
name := "pekko-projection-core",
Compile / packageBin / packageOptions += Package.ManifestAttributes(
"Automatic-Module-Name" -> "pekko.projection.core"))
.settings(AutomaticModuleName.settings("pekko.projection.core"))
.settings(name := "pekko-projection-core")
.settings(Protobuf.settings)

lazy val coreTest =
Expand All @@ -59,8 +57,8 @@ lazy val testkit =
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.testKit)
.settings(
name := "pekko-projection-testkit")
.settings(AutomaticModuleName.settings("pekko.projection.testkit"))
.settings(name := "pekko-projection-testkit")
.dependsOn(core)

// provides offset storage backed by a JDBC table
Expand All @@ -72,8 +70,8 @@ lazy val jdbc =
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.jdbc)
.settings(
name := "pekko-projection-jdbc")
.settings(AutomaticModuleName.settings("pekko.projection.jdbc"))
.settings(name := "pekko-projection-jdbc")
.dependsOn(core)
.dependsOn(coreTest % "test->test")
.dependsOn(testkit % Test)
Expand All @@ -87,8 +85,8 @@ lazy val slick =
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.slick)
.settings(
name := "pekko-projection-slick")
.settings(AutomaticModuleName.settings("pekko.projection.slick"))
.settings(name := "pekko-projection-slick")
.dependsOn(jdbc)
.dependsOn(core)
.dependsOn(coreTest % "test->test")
Expand All @@ -103,8 +101,8 @@ lazy val cassandra =
.settings(headerSettings(IntegrationTest))
.settings(Defaults.itSettings)
.settings(Dependencies.cassandra)
.settings(
name := "pekko-projection-cassandra")
.settings(AutomaticModuleName.settings("pekko.projection.cassandra"))
.settings(name := "pekko-projection-cassandra")
.dependsOn(core)
// strictly speaking it is not needed to have test->test here.
// Cassandra module doesn't have tests, only integration tests
Expand All @@ -118,8 +116,8 @@ lazy val eventsourced =
.enablePlugins(ReproducibleBuildsPlugin)
.settings(crossScalaVersions := Dependencies.Scala2And3Versions)
.settings(Dependencies.eventsourced)
.settings(
name := "pekko-projection-eventsourced")
.settings(AutomaticModuleName.settings("pekko.projection.eventsourced"))
.settings(name := "pekko-projection-eventsourced")
.dependsOn(core)
.dependsOn(testkit % Test)

Expand All @@ -129,8 +127,8 @@ lazy val kafka =
.enablePlugins(ReproducibleBuildsPlugin)
.settings(crossScalaVersions := Dependencies.Scala2And3Versions)
.settings(Dependencies.kafka)
.settings(
name := "pekko-projection-kafka")
.settings(AutomaticModuleName.settings("pekko.projection.kafka"))
.settings(name := "pekko-projection-kafka")
.dependsOn(core)

lazy val kafkaTest =
Expand All @@ -155,8 +153,8 @@ lazy val `durable-state` =
.enablePlugins(ReproducibleBuildsPlugin)
.settings(crossScalaVersions := Dependencies.Scala2And3Versions)
.settings(Dependencies.state)
.settings(
name := "pekko-projection-durable-state")
.settings(AutomaticModuleName.settings("pekko.projection.durable-state"))
.settings(name := "pekko-projection-durable-state")
.dependsOn(core)
.dependsOn(testkit % Test)

Expand Down
30 changes: 30 additions & 0 deletions project/AutomaticModuleName.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* license agreements; and to You under the Apache License, version 2.0:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* This file is part of the Apache Pekko project, which was derived from Akka.
*/

/*
* Copyright (C) 2016-2022 Lightbend Inc. <https://www.lightbend.com>
*/

import sbt.Keys._
import sbt._

/**
* Helper to set Automatic-Module-Name in projects.
*
* !! DO NOT BE TEMPTED INTO AUTOMATICALLY DERIVING THE NAMES FROM PROJECT NAMES !!
*
* The names carry a lot of implications and DO NOT have to always align 1:1 with the group ids or package names,
* though there should be of course a strong relationship between them.
*/
object AutomaticModuleName {
private val AutomaticModuleName = "Automatic-Module-Name"

def settings(name: String): Seq[Def.Setting[Task[Seq[PackageOption]]]] =
Seq(Compile / packageBin / packageOptions += Package.ManifestAttributes(AutomaticModuleName -> name))
}

0 comments on commit 5432db1

Please sign in to comment.