diff --git a/build.sbt b/build.sbt index 125974dece..7816596ee5 100644 --- a/build.sbt +++ b/build.sbt @@ -4,6 +4,8 @@ ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value scalaVersion := Dependencies.allScalaVersions.head +ThisBuild / apacheSonatypeProjectProfile := "pekko" + enablePlugins( UnidocRoot, UnidocWithPrValidation, @@ -116,14 +118,12 @@ lazy val actor = pekkoModule("actor") (Compile / scalaSource).value.getParentFile / s"scala-$ver" }) .settings(VersionGenerator.settings) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(serialversionRemoverPluginSettings) .enablePlugins(BoilerplatePlugin) lazy val actorTests = pekkoModule("actor-tests") .dependsOn(testkit % "compile->compile;test->test", actor) .settings(Dependencies.actorTests) - .settings(MetaInfLicenseNoticeCopy.settings) .enablePlugins(NoPublish) .disablePlugins(MimaPlugin) @@ -150,7 +150,6 @@ lazy val cluster = pekkoModule("cluster") jackson % "test->test") .settings(Dependencies.cluster) .settings(AutomaticModuleName.settings("pekko.cluster")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.cluster) .settings(Protobuf.settings) .settings(Test / parallelExecution := false) @@ -165,7 +164,6 @@ lazy val clusterMetrics = pekkoModule("cluster-metrics") .settings(OSGi.clusterMetrics) .settings(Dependencies.clusterMetrics) .settings(AutomaticModuleName.settings("pekko.cluster.metrics")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Protobuf.settings) .settings(SigarLoader.sigarSettings) .settings(Test / parallelExecution := false) @@ -185,7 +183,6 @@ lazy val clusterSharding = pekkoModule("cluster-sharding") jackson % "test->test") .settings(Dependencies.clusterSharding) .settings(AutomaticModuleName.settings("pekko.cluster.sharding")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.clusterSharding) .settings(Protobuf.settings) .configs(MultiJvm) @@ -199,7 +196,6 @@ lazy val clusterTools = pekkoModule("cluster-tools") jackson % "test->test") .settings(Dependencies.clusterTools) .settings(AutomaticModuleName.settings("pekko.cluster.tools")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.clusterTools) .settings(Protobuf.settings) .configs(MultiJvm) @@ -209,7 +205,6 @@ lazy val distributedData = pekkoModule("distributed-data") .dependsOn(cluster % "compile->compile;test->test;multi-jvm->multi-jvm", jackson % "test->test") .settings(Dependencies.distributedData) .settings(AutomaticModuleName.settings("pekko.cluster.ddata")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.distributedData) .settings(Protobuf.settings) .configs(MultiJvm) @@ -269,7 +264,6 @@ lazy val jackson = pekkoModule("serialization-jackson") testkit % "test->test") .settings(Dependencies.jackson) .settings(AutomaticModuleName.settings("pekko.serialization.jackson")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.jackson) .settings(javacOptions += "-parameters") .enablePlugins(ScaladocNoVerificationOfDiagrams) @@ -279,14 +273,12 @@ lazy val multiNodeTestkit = pekkoModule("multi-node-testkit") .settings(Dependencies.multiNodeTestkit) .settings(Protobuf.settings) .settings(AutomaticModuleName.settings("pekko.remote.testkit")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(PekkoBuild.mayChangeSettings) lazy val osgi = pekkoModule("osgi") .dependsOn(actor) .settings(Dependencies.osgi) .settings(AutomaticModuleName.settings("pekko.osgi")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.osgi) .settings(Test / parallelExecution := false, crossScalaVersions -= Dependencies.scala3Version) @@ -294,7 +286,6 @@ lazy val persistence = pekkoModule("persistence") .dependsOn(actor, stream, testkit % "test->test") .settings(Dependencies.persistence) .settings(AutomaticModuleName.settings("pekko.persistence")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.persistence) .settings(Protobuf.settings) .settings(Test / fork := true) @@ -308,7 +299,6 @@ lazy val persistenceQuery = pekkoModule("persistence-query") streamTestkit % "test") .settings(Dependencies.persistenceQuery) .settings(AutomaticModuleName.settings("pekko.persistence.query")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.persistenceQuery) .settings(Protobuf.settings) // To be able to import ContainerFormats.proto @@ -320,7 +310,6 @@ lazy val persistenceShared = pekkoModule("persistence-shared") .dependsOn(persistence % "test->test", testkit % "test->test", remote % "test") .settings(Dependencies.persistenceShared) .settings(AutomaticModuleName.settings("pekko.persistence.shared")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Test / fork := true) .enablePlugins(NoPublish) .disablePlugins(MimaPlugin) @@ -329,7 +318,6 @@ lazy val persistenceTck = pekkoModule("persistence-tck") .dependsOn(persistence % "compile->compile;test->test", testkit % "compile->compile;test->test") .settings(Dependencies.persistenceTck) .settings(AutomaticModuleName.settings("pekko.persistence.tck")) - .settings(MetaInfLicenseNoticeCopy.settings) // .settings(OSGi.persistenceTck) TODO: we do need to export this as OSGi bundle too? .settings(Test / fork := true) .disablePlugins(MimaPlugin) @@ -342,7 +330,6 @@ lazy val persistenceTestkit = pekkoModule("persistence-testkit") persistenceTck % "test") .settings(Dependencies.persistenceTestKit) .settings(AutomaticModuleName.settings("pekko.persistence.testkit")) - .settings(MetaInfLicenseNoticeCopy.settings) .disablePlugins(MimaPlugin) lazy val persistenceTypedTests = pekkoModule("persistence-typed-tests") @@ -361,7 +348,7 @@ lazy val persistenceTypedTests = pekkoModule("persistence-typed-tests") lazy val protobuf = pekkoModule("protobuf") .settings(OSGi.protobuf) .settings(AutomaticModuleName.settings("pekko.protobuf")) - .settings(MetaInfLicenseNoticeCopy.protobufSettings) + .settings(AddMetaInfLicenseFiles.protobufSettings) .enablePlugins(ScaladocNoVerificationOfDiagrams) .disablePlugins(MimaPlugin) .settings(autoScalaLibrary := false) // Pure java project @@ -369,7 +356,7 @@ lazy val protobuf = pekkoModule("protobuf") lazy val protobufV3 = pekkoModule("protobuf-v3") .settings(OSGi.protobufV3) .settings(AutomaticModuleName.settings("pekko.protobuf.v3")) - .settings(MetaInfLicenseNoticeCopy.protobufSettings) + .settings(AddMetaInfLicenseFiles.protobufSettings) .enablePlugins(ScaladocNoVerificationOfDiagrams) .disablePlugins(MimaPlugin) .settings( @@ -400,7 +387,6 @@ lazy val pki = .dependsOn(actor) // this dependency only exists for "@ApiMayChange" .settings(Dependencies.pki) .settings(AutomaticModuleName.settings("pekko.pki")) - .settings(MetaInfLicenseNoticeCopy.settings) .disablePlugins(MimaPlugin) lazy val remote = @@ -416,7 +402,6 @@ lazy val remote = jackson % "test->test") .settings(Dependencies.remote) .settings(AutomaticModuleName.settings("pekko.remote")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.remote) .settings(Protobuf.settings) .settings(Test / parallelExecution := false) @@ -441,14 +426,12 @@ lazy val slf4j = pekkoModule("slf4j") .dependsOn(actor, testkit % "test->test") .settings(Dependencies.slf4j) .settings(AutomaticModuleName.settings("pekko.slf4j")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.slf4j) lazy val stream = pekkoModule("stream") .dependsOn(actor, protobufV3) .settings(Dependencies.stream) .settings(AutomaticModuleName.settings("pekko.stream")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.stream) .settings(Protobuf.settings) .enablePlugins(BoilerplatePlugin, Jdk9) @@ -457,7 +440,6 @@ lazy val streamTestkit = pekkoModule("stream-testkit") .dependsOn(stream, testkit % "compile->compile;test->test") .settings(Dependencies.streamTestkit) .settings(AutomaticModuleName.settings("pekko.stream.testkit")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.streamTestkit) lazy val streamTests = pekkoModule("stream-tests") @@ -483,14 +465,12 @@ lazy val testkit = pekkoModule("testkit") .dependsOn(actor) .settings(Dependencies.testkit) .settings(AutomaticModuleName.settings("pekko.actor.testkit")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.testkit) .settings(initialCommands += "import org.apache.pekko.testkit._") lazy val actorTyped = pekkoModule("actor-typed") .dependsOn(actor, slf4j) .settings(AutomaticModuleName.settings("pekko.actor.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Dependencies.actorTyped) .settings(OSGi.actorTyped) .settings(initialCommands := @@ -523,7 +503,6 @@ lazy val persistenceTyped = pekkoModule("persistence-typed") .settings(javacOptions += "-parameters") // for Jackson .settings(Dependencies.persistenceShared) .settings(AutomaticModuleName.settings("pekko.persistence.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Protobuf.settings) // To be able to import ContainerFormats.proto .settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf")) @@ -543,7 +522,6 @@ lazy val clusterTyped = pekkoModule("cluster-typed") // To be able to import ContainerFormats.proto .settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf")) .settings(AutomaticModuleName.settings("pekko.cluster.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Protobuf.settings) // To be able to import ContainerFormats.proto .settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf")) @@ -565,7 +543,6 @@ lazy val clusterShardingTyped = pekkoModule("cluster-sharding-typed") jackson % "test->test") .settings(javacOptions += "-parameters") // for Jackson .settings(AutomaticModuleName.settings("pekko.cluster.sharding.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) // To be able to import ContainerFormats.proto .settings(Protobuf.settings) .settings(Protobuf.importPath := Some(baseDirectory.value / ".." / "remote" / "src" / "main" / "protobuf")) @@ -580,13 +557,11 @@ lazy val streamTyped = pekkoModule("stream-typed") actorTestkitTyped % "test->test", actorTypedTests % "test->test") .settings(AutomaticModuleName.settings("pekko.stream.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) .enablePlugins(ScaladocNoVerificationOfDiagrams) lazy val actorTestkitTyped = pekkoModule("actor-testkit-typed") .dependsOn(actorTyped, slf4j, testkit % "compile->compile;test->test") .settings(AutomaticModuleName.settings("pekko.actor.testkit.typed")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(Dependencies.actorTestkitTyped) lazy val actorTypedTests = pekkoModule("actor-typed-tests") @@ -599,14 +574,12 @@ lazy val discovery = pekkoModule("discovery") .dependsOn(actor, testkit % "test->test", actorTests % "test->test") .settings(Dependencies.discovery) .settings(AutomaticModuleName.settings("pekko.discovery")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.discovery) lazy val coordination = pekkoModule("coordination") .dependsOn(actor, testkit % "test->test", actorTests % "test->test") .settings(Dependencies.coordination) .settings(AutomaticModuleName.settings("pekko.coordination")) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(OSGi.coordination) lazy val billOfMaterials = Project("bill-of-materials", file("bill-of-materials")) diff --git a/project/AddMetaInfLicenseFiles.scala b/project/AddMetaInfLicenseFiles.scala new file mode 100644 index 0000000000..8f05678b54 --- /dev/null +++ b/project/AddMetaInfLicenseFiles.scala @@ -0,0 +1,42 @@ +/* + * 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. + */ + +import sbt.Keys._ +import sbt._ +import org.mdedetrich.apache.sonatype.SonatypeApachePlugin +import org.mdedetrich.apache.sonatype.SonatypeApachePlugin.autoImport._ + +/** + * Copies LICENSE and NOTICE files into jar META-INF dir + */ +object AddMetaInfLicenseFiles extends AutoPlugin { + + private lazy val baseDir = LocalRootProject / baseDirectory + + override lazy val projectSettings = Seq( + apacheSonatypeLicenseFile := baseDir.value / "legal" / "StandardLicense.txt", + apacheSonatypeDisclaimerFile := Some(baseDir.value / "DISCLAIMER")) + + /** + * Settings specific for Pekko protobuf subprojects which require a different license file + * as well as an additional "COPYING.protobuf" file. + */ + lazy val protobufSettings = Seq( + apacheSonatypeLicenseFile := baseDir.value / "LICENSE") ++ inConfig(Compile)(Seq( + resourceGenerators += { + Def.task { + List( + SonatypeApachePlugin.addFileToMetaInf(resourceManaged.value, baseDir.value / "COPYING.protobuf")) + } + })) + + override def trigger = allRequirements + + override def requires = SonatypeApachePlugin +} diff --git a/project/MetaInfLicenseNoticeCopy.scala b/project/MetaInfLicenseNoticeCopy.scala deleted file mode 100644 index 6e37533375..0000000000 --- a/project/MetaInfLicenseNoticeCopy.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -import sbt.Keys._ -import sbt._ - -/** - * Copies LICENSE and NOTICE files into jar META-INF dir - */ -object MetaInfLicenseNoticeCopy { - - private val baseDir = LocalRootProject / baseDirectory - private val standardLicenseFile = Def.task[File](baseDir.value / "legal" / "StandardLicense.txt") - private val protobufApacheLicenseFile = Def.task[File](baseDir.value / "LICENSE") - private val protobufGoogleLicenseFile = Def.task[File](baseDir.value / "COPYING.protobuf") - private val noticeFile = Def.task[File](baseDir.value / "NOTICE") - private val disclaimerFile = Def.task[File](baseDir.value / "DISCLAIMER") - - val settings: Seq[Setting[_]] = inConfig(Compile)( - Seq( - resourceGenerators += copyFileToMetaInf(resourceManaged, standardLicenseFile, "LICENSE"), - resourceGenerators += copyFileToMetaInf(resourceManaged, noticeFile, "NOTICE"), - resourceGenerators += copyFileToMetaInf(resourceManaged, disclaimerFile, "DISCLAIMER"))) - - val protobufSettings: Seq[Setting[_]] = inConfig(Compile)( - Seq( - resourceGenerators += copyFileToMetaInf(resourceManaged, protobufApacheLicenseFile, "LICENSE"), - resourceGenerators += copyFileToMetaInf(resourceManaged, protobufGoogleLicenseFile, "COPYING.protobuf"), - resourceGenerators += copyFileToMetaInf(resourceManaged, noticeFile, "NOTICE"), - resourceGenerators += copyFileToMetaInf(resourceManaged, disclaimerFile, "DISCLAIMER"))) - - private def copyFileToMetaInf(dir: SettingKey[File], fromFile: Def.Initialize[Task[File]], - fileName: String) = Def.task[Seq[File]] { - val toFile = resourceManaged.value / "META-INF" / fileName - IO.copyFile(fromFile.value, toFile) - Seq(toFile) - } - -} diff --git a/project/Publish.scala b/project/Publish.scala index 8c6029b8d6..5edea1d3d8 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -16,38 +16,23 @@ package org.apache.pekko import sbt._ import sbt.Keys._ import com.lightbend.sbt.publishrsync.PublishRsyncPlugin.autoImport.publishRsyncHost -import xerial.sbt.Sonatype.autoImport._ +import org.mdedetrich.apache.sonatype.SonatypeApachePlugin object Publish extends AutoPlugin { override def trigger = allRequirements - private val apacheBaseRepo = "repository.apache.org" - override lazy val projectSettings = Seq( publishRsyncHost := "akkarepo@gustav.akka.io", - credentials ++= apacheNexusCredentials, - organizationName := "Apache Software Foundation", - organizationHomepage := Some(url("https://www.apache.org")), - sonatypeCredentialHost := apacheBaseRepo, - sonatypeProfileName := "org.apache.pekko", startYear := Some(2022), developers := List( Developer( "pekko-contributors", "Apache Pekko Contributors", "dev@pekko.apache.org", - url("https://github.com/apache/incubator-pekko/graphs/contributors"))), - publishMavenStyle := true, - pomIncludeRepository := (_ => false)) + url("https://github.com/apache/incubator-pekko/graphs/contributors")))) - private def apacheNexusCredentials: Seq[Credentials] = - (sys.env.get("NEXUS_USER"), sys.env.get("NEXUS_PW")) match { - case (Some(user), Some(password)) => - Seq(Credentials("Sonatype Nexus Repository Manager", apacheBaseRepo, user, password)) - case _ => - Seq.empty - } + override def requires = SonatypeApachePlugin } /** diff --git a/project/plugins.sbt b/project/plugins.sbt index eeef79a0af..fd43610df5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -23,6 +23,7 @@ addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.30") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("com.lightbend.sbt" % "sbt-publish-rsync" % "0.2") addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % "0.1.2") +addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.0") addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2") // allow access to snapshots for pekko-sbt-paradox