Skip to content

Commit

Permalink
Simplify and cleanup MultiJvm, MultiNode, Copyright in sbt build
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Jan 22, 2024
1 parent b273c06 commit 9b00480
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 61 deletions.
17 changes: 3 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ enablePlugins(
UnidocRoot,
UnidocWithPrValidation,
NoPublish,
CopyrightHeader,
CopyrightHeaderInPr,
ScalafixIgnoreFilePlugin,
JavaFormatterPlugin)
disablePlugins(MimaPlugin)
Expand All @@ -51,7 +49,6 @@ addCommandAlias(
addCommandAlias(name = "sortImports", value = ";scalafixEnable; scalafixAll SortImports; scalafmtAll")

import PekkoBuild._
import MultiJvmPlugin.MultiJvmKeys.MultiJvm
import com.typesafe.tools.mima.plugin.MimaPlugin
import sbt.Keys.{ initialCommands, parallelExecution }
import spray.boilerplate.BoilerplatePlugin
Expand Down Expand Up @@ -147,16 +144,16 @@ lazy val actorTests = pekkoModule("actor-tests")
lazy val pekkoScalaNightly = pekkoModule("scala-nightly")
.aggregate(aggregatedProjects: _*)
.disablePlugins(MimaPlugin)
.disablePlugins(ValidatePullRequest, MimaPlugin, CopyrightHeaderInPr)
.disablePlugins(ValidatePullRequest, MimaPlugin)

lazy val benchJmh = pekkoModule("bench-jmh")
.enablePlugins(Jdk9)
.dependsOn(Seq(actor, actorTyped, stream, streamTestkit, persistence, distributedData, jackson, testkit).map(
_ % "compile->compile;compile->test"): _*)
.settings(Dependencies.benchJmh)
.settings(javacOptions += "-parameters") // for Jackson
.enablePlugins(JmhPlugin, ScaladocNoVerificationOfDiagrams, NoPublish, CopyrightHeader)
.disablePlugins(MimaPlugin, ValidatePullRequest, CopyrightHeaderInPr)
.enablePlugins(JmhPlugin, ScaladocNoVerificationOfDiagrams, NoPublish)
.disablePlugins(MimaPlugin, ValidatePullRequest)

lazy val cluster = pekkoModule("cluster")
.dependsOn(
Expand All @@ -171,7 +168,6 @@ lazy val cluster = pekkoModule("cluster")
.settings(OSGi.cluster)
.settings(Protobuf.settings)
.settings(Test / parallelExecution := false)
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest)

lazy val clusterMetrics = pekkoModule("cluster-metrics")
Expand All @@ -185,7 +181,6 @@ lazy val clusterMetrics = pekkoModule("cluster-metrics")
.settings(Protobuf.settings)
.settings(SigarLoader.sigarSettings)
.settings(Test / parallelExecution := false)
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest)

lazy val clusterSharding = pekkoModule("cluster-sharding")
Expand All @@ -203,7 +198,6 @@ lazy val clusterSharding = pekkoModule("cluster-sharding")
.settings(AutomaticModuleName.settings("pekko.cluster.sharding"))
.settings(OSGi.clusterSharding)
.settings(Protobuf.settings)
.configs(MultiJvm)
.enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams)
.enablePlugins(Jdk9)

Expand All @@ -216,7 +210,6 @@ lazy val clusterTools = pekkoModule("cluster-tools")
.settings(AutomaticModuleName.settings("pekko.cluster.tools"))
.settings(OSGi.clusterTools)
.settings(Protobuf.settings)
.configs(MultiJvm)
.enablePlugins(MultiNode, ScaladocNoVerificationOfDiagrams)

lazy val distributedData = pekkoModule("distributed-data")
Expand All @@ -226,7 +219,6 @@ lazy val distributedData = pekkoModule("distributed-data")
.settings(AddMetaInfLicenseFiles.distributedDataSettings)
.settings(OSGi.distributedData)
.settings(Protobuf.settings)
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest)

lazy val docs = pekkoModule("docs")
Expand Down Expand Up @@ -427,7 +419,6 @@ lazy val remoteTests = pekkoModule("remote-tests")
.settings(Dependencies.remoteTests)
.settings(Protobuf.settings)
.settings(Test / parallelExecution := false)
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest, NoPublish)
.disablePlugins(MimaPlugin)

Expand Down Expand Up @@ -535,7 +526,6 @@ lazy val clusterTyped = pekkoModule("cluster-typed")
.settings(Protobuf.settings)
// To be able to import ContainerFormats.proto
.settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf"))
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest)

lazy val clusterShardingTyped = pekkoModule("cluster-sharding-typed")
Expand All @@ -556,7 +546,6 @@ lazy val clusterShardingTyped = pekkoModule("cluster-sharding-typed")
// To be able to import ContainerFormats.proto
.settings(Protobuf.settings)
.settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf"))
.configs(MultiJvm)
.enablePlugins(MultiNodeScalaTest)

lazy val streamTyped = pekkoModule("stream-typed")
Expand Down
40 changes: 9 additions & 31 deletions project/CopyrightHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com>
*/

import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import de.heikoseeberger.sbtheader.{ CommentCreator, HeaderPlugin, NewLine }
import org.apache.commons.lang3.StringUtils
import sbt.Keys._
import sbt._

import MultiJvmPlugin.MultiJvmKeys._
object CopyrightHeader extends AutoPlugin {
import HeaderPlugin.autoImport._

trait CopyrightHeader extends AutoPlugin {
override def requires = HeaderPlugin
override def trigger = allRequirements

override def requires: Plugins = HeaderPlugin

override def trigger: PluginTrigger = allRequirements

protected def headerMappingSettings: Seq[Def.Setting[_]] =
Seq(Compile, Test, MultiJvm).flatMap { config =>
override def projectSettings = Def.settings(
Seq(Compile, Test).flatMap { config =>
inConfig(config)(
Seq(
headerLicense := Some(HeaderLicense.Custom(apacheHeader)),
Expand All @@ -36,20 +32,7 @@ trait CopyrightHeader extends AutoPlugin {
HeaderFileType.conf -> hashLineComment,
HeaderFileType("template") -> cStyleComment,
HeaderFileType("sbt") -> cStyleComment)))
}

override def projectSettings: Seq[Def.Setting[_]] =
Def.settings(headerMappingSettings, additional)

def additional: Seq[Def.Setting[_]] =
Def.settings(Compile / compile := {
(Compile / headerCreate).value
(Compile / compile).value
},
Test / compile := {
(Test / headerCreate).value
(Test / compile).value
})
})

val apacheFromAkkaSourceHeader: String =
"""Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -89,7 +72,7 @@ trait CopyrightHeader extends AutoPlugin {
HeaderCommentStyle.cStyleBlockComment.commentCreator(apacheFromAkkaSourceHeader,
existingText) + NewLine * 2 + currentText
case Some(currentText) =>
throw new IllegalStateException(s"Unable to detect copyright for header:[$currentText]")
throw new IllegalStateException(s"Unable to detect copyright for header: [$currentText]")
case None =>
HeaderCommentStyle.cStyleBlockComment.commentCreator(text, existingText)
}
Expand Down Expand Up @@ -127,11 +110,6 @@ trait CopyrightHeader extends AutoPlugin {
private def isValidCopyrightAnnotated(text: String): Boolean =
isApacheCopyrighted(text)

private def isOnlyLightbendOrEpflCopyrightAnnotated(text: String): Boolean = {
private def isOnlyLightbendOrEpflCopyrightAnnotated(text: String): Boolean =
(isLightbendCopyrighted(text) || isLAMPCopyrighted(text)) && !isApacheCopyrighted(text)
}
}

object CopyrightHeader extends CopyrightHeader

object CopyrightHeaderInPr extends CopyrightHeader
10 changes: 5 additions & 5 deletions project/CopyrightHeaderForBoilerplate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
* Copyright (C) 2019-2022 Lightbend Inc. <https://www.lightbend.com>
*/

import de.heikoseeberger.sbtheader.HeaderPlugin
import CopyrightHeader.cStyleComment
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import sbt.Keys.sourceDirectory
import sbt.{ inConfig, Compile, Def, Plugins, Test, _ }
import spray.boilerplate.BoilerplatePlugin

object CopyrightHeaderForBoilerplate extends CopyrightHeader {
override def requires: Plugins = BoilerplatePlugin && HeaderPlugin
object CopyrightHeaderForBoilerplate extends AutoPlugin {
override def requires: Plugins = BoilerplatePlugin && CopyrightHeader
override def trigger: PluginTrigger = allRequirements

override protected def headerMappingSettings: Seq[Def.Setting[_]] = {
super.headerMappingSettings
override def projectSettings: Seq[Def.Setting[_]] = {
Seq(Compile, Test).flatMap { config =>
inConfig(config) {
Seq(
Expand Down
4 changes: 3 additions & 1 deletion project/CopyrightHeaderForBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
* Copyright (C) 2019-2022 Lightbend Inc. <https://www.lightbend.com>
*/

import CopyrightHeader.cStyleComment
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.{ headerMappings, headerSources, HeaderFileType }
import sbt.Keys.baseDirectory
import sbt.{ inConfig, Compile, Def, PluginTrigger, Test, _ }

object CopyrightHeaderForBuild extends CopyrightHeader {
object CopyrightHeaderForBuild extends AutoPlugin {
override def requires: Plugins = CopyrightHeader
override def trigger: PluginTrigger = noTrigger

override def projectSettings: Seq[Def.Setting[_]] = {
Expand Down
8 changes: 5 additions & 3 deletions project/CopyrightHeaderForJdk9.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.headerSources
import sbt.Keys.sourceDirectory
import sbt.{ Compile, Def, Test, _ }

object CopyrightHeaderForJdk9 extends CopyrightHeader {
object CopyrightHeaderForJdk9 extends AutoPlugin {

override protected def headerMappingSettings: Seq[Def.Setting[_]] = {
super.headerMappingSettings
override def requires = CopyrightHeader && Jdk9
override def trigger = allRequirements

override def projectSettings: Seq[Def.Setting[_]] = {
import Jdk9._
Seq(
Compile / headerSources ++=
Expand Down
10 changes: 7 additions & 3 deletions project/CopyrightHeaderForProtobuf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
* Copyright (C) 2019-2022 Lightbend Inc. <https://www.lightbend.com>
*/

import CopyrightHeader.cStyleComment
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport.{ headerMappings, headerSources, HeaderFileType }
import sbt.Keys.sourceDirectory
import sbt.{ inConfig, Compile, Def, Test, _ }

object CopyrightHeaderForProtobuf extends CopyrightHeader {
override protected def headerMappingSettings: Seq[Def.Setting[_]] = {
super.headerMappingSettings
object CopyrightHeaderForProtobuf extends AutoPlugin {

override def requires = CopyrightHeader
override def trigger = allRequirements

override def projectSettings: Seq[Def.Setting[_]] = {
Seq(Compile, Test).flatMap { config =>
inConfig(config) {
Seq(
Expand Down
6 changes: 3 additions & 3 deletions project/MultiNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/

import TestExtras.Filter.Keys._
import MultiJvmPlugin.MultiJvmKeys.multiJvmCreateLogger
import MultiJvmPlugin.MultiJvmKeys._
import MultiJvmPlugin.autoImport.multiJvmCreateLogger
import MultiJvmPlugin.autoImport._

import sbt.{ Def, _ }
import sbt.Keys._
Expand Down Expand Up @@ -47,7 +47,7 @@ object MultiNode extends AutoPlugin {
val multiTest = CliOptions.multiNode.ifTrue(MultiJvm / multiNodeTest).getOrElse(MultiJvm / test)

override def trigger = noTrigger
override def requires = plugins.JvmPlugin
override def requires = plugins.JvmPlugin && MultiJvmPlugin

override lazy val projectSettings: Seq[Def.Setting[_]] = multiJvmSettings

Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion project/ValidatePullRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ object PekkoValidatePullRequest extends AutoPlugin {
*/
object MultiNodeWithPrValidation extends AutoPlugin {
import PekkoValidatePullRequest._
import MultiJvmPlugin.MultiJvmKeys.MultiJvm

override def trigger = allRequirements
override def requires = PekkoValidatePullRequest && MultiNode
Expand Down

0 comments on commit 9b00480

Please sign in to comment.