This is an automated email from the ASF dual-hosted git repository. mdedetrich pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-pekko-persistence-r2dbc.git
commit 9aae41baeb406cd2c4de1cc006ed509d5df51c7c Author: Matthew de Detrich <[email protected]> AuthorDate: Wed Apr 12 09:47:47 2023 +0200 Setup sbt-apache-sonatype plus refactor sbt settings --- build.sbt | 56 ++-------------------------------- project/CommonSettings.scala | 53 ++++++++++++++++++++++++++++++++ project/MetaInfLicenseNoticeCopy.scala | 20 ++++++------ project/plugins.sbt | 3 +- 4 files changed, 67 insertions(+), 65 deletions(-) diff --git a/build.sbt b/build.sbt index a4adfe5..c08628a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,16 +1,13 @@ ThisBuild / resolvers += "Apache Nexus Snapshots".at("https://repository.apache.org/content/repositories/snapshots/") +ThisBuild / apacheSonatypeProjectProfile := "pekko" import sbt.Keys.parallelExecution -import xerial.sbt.Sonatype.autoImport.sonatypeProfileName GlobalScope / parallelExecution := false Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) inThisBuild( Seq( - organization := "org.apache.pekko", - organizationName := "Apache Software Foundation", - homepage := Some(url("https://pekko.apache.org/")), scmInfo := Some( ScmInfo( url("https://github.com/apache/incubator-pekko-persistence-r2dbc"), @@ -21,7 +18,6 @@ inThisBuild( "Contributors", "[email protected]", url("https://github.com/apache/incubator-pekko-persistence-r2dbc/graphs/contributors")), - licenses := Seq(("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))), description := "An Apache Pekko Persistence backed by SQL database with R2DBC", // add snapshot repo when Pekko version overridden resolvers ++= @@ -29,82 +25,36 @@ inThisBuild( Seq("Apache Nexus Snapshots".at("https://repository.apache.org/content/repositories/snapshots/")) else Seq.empty))) -def common: Seq[Setting[_]] = - Seq( - crossScalaVersions := Seq(Dependencies.Scala212, Dependencies.Scala213), - scalaVersion := Dependencies.Scala213, - crossVersion := CrossVersion.binary, - sonatypeProfileName := "org.apache.pekko", - // Setting javac options in common allows IntelliJ IDEA to import them automatically - Compile / javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"), - Test / logBuffered := false, - Test / parallelExecution := false, - // show full stack traces and test case durations - Test / testOptions += Tests.Argument("-oDF"), - // -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug". - // -a Show stack traces and exception class name for AssertionErrors. - testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a"), - Test / fork := true, // some non-heap memory is leaking - Test / javaOptions ++= { - import scala.collection.JavaConverters._ - // include all passed -Dpekko. properties to the javaOptions for forked tests - // useful to switch DB dialects for example - val pekkoProperties = System.getProperties.stringPropertyNames.asScala.toList.collect { - case key: String if key.startsWith("pekko.") => "-D" + key + "=" + System.getProperty(key) - } - "-Xms1G" :: "-Xmx1G" :: "-XX:MaxDirectMemorySize=256M" :: pekkoProperties - }, - projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value), - Global / excludeLintKeys += projectInfoVersion) - lazy val dontPublish = Seq(publish / skip := true, Compile / publishArtifact := false) lazy val root = (project in file(".")) - .settings(common) .settings(dontPublish) .settings( - name := "pekko-persistence-r2dbc-root", - publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))) + name := "pekko-persistence-r2dbc-root") .aggregate(core, projection, migration, docs) def suffixFileFilter(suffix: String): FileFilter = new SimpleFileFilter(f => f.getAbsolutePath.endsWith(suffix)) lazy val core = (project in file("core")) - .settings(common) .settings(name := "pekko-persistence-r2dbc", libraryDependencies ++= Dependencies.core) - .settings(MetaInfLicenseNoticeCopy.settings) lazy val projection = (project in file("projection")) .dependsOn(core) - .settings(common) .settings(name := "pekko-projection-r2dbc", libraryDependencies ++= Dependencies.projection) - .settings(MetaInfLicenseNoticeCopy.settings) lazy val migration = (project in file("migration")) - .settings(common) - .settings(MetaInfLicenseNoticeCopy.settings) .settings( name := "pekko-persistence-r2dbc-migration", libraryDependencies ++= Dependencies.migration, Test / mainClass := Some("org.apache.pekko.persistence.r2dbc.migration.MigrationTool"), Test / run / fork := true, - Test / run / javaOptions ++= { - import scala.collection.JavaConverters._ - // include all passed -Dpekko. properties to the javaOptions for forked tests - // useful to switch DB dialects for example - val pekkoProperties = System.getProperties.stringPropertyNames.asScala.toList.collect { - case key: String if key.startsWith("pekko.") => "-D" + key + "=" + System.getProperty(key) - } - "-Dlogback.configurationFile=logback-main.xml" :: "-Xms1G" :: "-Xmx1G" :: "-XX:MaxDirectMemorySize=256M" :: pekkoProperties - }) + Test / run / javaOptions += "-Dlogback.configurationFile=logback-main.xml") .dependsOn(core % "compile->compile;test->test") lazy val docs = project .in(file("docs")) .enablePlugins(PekkoParadoxPlugin, ParadoxSitePlugin, PublishRsyncPlugin) .dependsOn(core, projection, migration) - .settings(common) - .settings(MetaInfLicenseNoticeCopy.settings) .settings(dontPublish) .settings( name := "Apache Pekko Persistence R2DBC", diff --git a/project/CommonSettings.scala b/project/CommonSettings.scala new file mode 100644 index 0000000..f84885f --- /dev/null +++ b/project/CommonSettings.scala @@ -0,0 +1,53 @@ +/* + * 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 com.lightbend.paradox.projectinfo.ParadoxProjectInfoPlugin.autoImport.projectInfoVersion +import org.mdedetrich.apache.sonatype.SonatypeApachePlugin +import sbt.Keys._ +import sbt.{ AutoPlugin, Compile, CrossVersion, Global, Test, TestFrameworks, Tests } +import sbt.plugins.JvmPlugin +import sbtdynver.DynVerPlugin +import sbtdynver.DynVerPlugin.autoImport.dynverSonatypeSnapshots + +object CommonSettings extends AutoPlugin { + override def trigger = allRequirements + + override def requires = JvmPlugin && SonatypeApachePlugin && DynVerPlugin + + override lazy val projectSettings = Seq( + crossScalaVersions := Seq(Dependencies.Scala212, Dependencies.Scala213), + scalaVersion := Dependencies.Scala213, + crossVersion := CrossVersion.binary, + // Setting javac options in common allows IntelliJ IDEA to import them automatically + Compile / javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"), + Test / logBuffered := false, + Test / parallelExecution := false, + // show full stack traces and test case durations + Test / testOptions += Tests.Argument("-oDF"), + // -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug". + // -a Show stack traces and exception class name for AssertionErrors. + testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a"), + Test / fork := true, // some non-heap memory is leaking + Test / javaOptions ++= { + import scala.collection.JavaConverters._ + // include all passed -Dpekko. properties to the javaOptions for forked tests + // useful to switch DB dialects for example + val pekkoProperties = System.getProperties.stringPropertyNames.asScala.toList.collect { + case key: String if key.startsWith("pekko.") => "-D" + key + "=" + System.getProperty(key) + } + "-Xms1G" :: "-Xmx1G" :: "-XX:MaxDirectMemorySize=256M" :: pekkoProperties + }, + projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value)) + + override lazy val globalSettings = Seq( + Global / excludeLintKeys += projectInfoVersion) + + override lazy val buildSettings = Seq( + dynverSonatypeSnapshots := true) +} diff --git a/project/MetaInfLicenseNoticeCopy.scala b/project/MetaInfLicenseNoticeCopy.scala index 1965dc5..8f987aa 100644 --- a/project/MetaInfLicenseNoticeCopy.scala +++ b/project/MetaInfLicenseNoticeCopy.scala @@ -9,22 +9,20 @@ 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 MetaInfLicenseNoticeCopy { +object MetaInfLicenseNoticeCopy extends AutoPlugin { - val settings: Seq[Setting[_]] = inConfig(Compile)( - Seq( - resourceGenerators += copyFileToMetaInf(resourceManaged, "LICENSE"), - resourceGenerators += copyFileToMetaInf(resourceManaged, "NOTICE"))) + private lazy val baseDir = LocalRootProject / baseDirectory - def copyFileToMetaInf(dir: SettingKey[File], fileName: String) = Def.task[Seq[File]] { - val fromFile = (LocalRootProject / baseDirectory).value / fileName - val toFile = resourceManaged.value / "META-INF" / fileName - IO.copyFile(fromFile, toFile) - Seq(toFile) - } + override lazy val projectSettings = Seq( + apacheSonatypeDisclaimerFile := Some(baseDir.value / "DISCLAIMER")) + override def trigger = allRequirements + + override def requires = SonatypeApachePlugin } diff --git a/project/plugins.sbt b/project/plugins.sbt index 7dabfe2..442d34e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,8 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0") // for releasing -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.6") +addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") //// docs // allow access to snapshots for pekko-sbt-paradox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
