-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.sbt
186 lines (175 loc) · 9.16 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import com.typesafe.tools.mima.plugin.MimaKeys.mimaPreviousArtifacts
import com.typesafe.tools.mima.plugin.MimaKeys.mimaReportSignatureProblems
import sbt.Keys.parallelExecution
import com.geirsson.CiReleasePlugin
GlobalScope / parallelExecution := false
Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)
inThisBuild(
Seq(
organization := "com.lightbend.akka",
organizationName := "Lightbend Inc.",
homepage := Some(url("https://doc.akka.io/libraries/akka-persistence-r2dbc/current")),
scmInfo := Some(
ScmInfo(
url("https://github.com/akka/akka-persistence-r2dbc"),
"https://github.com/akka/akka-persistence-r2dbc.git")),
startYear := Some(2021),
developers += Developer(
"contributors",
"Contributors",
url("https://github.com/akka/akka-persistence-r2dbc/graphs/contributors")),
releaseNotesURL := (
if (isSnapshot.value) None
else Some(url(s"https://github.com/akka/akka-persistence-r2dbc/releases/tag/v${version.value}"))
),
licenses := Seq(("BUSL-1.1", url("https://raw.githubusercontent.com/akka/akka-persistence-r2dbc/main/LICENSE"))),
description := "An Akka Persistence backed by SQL database with R2DBC",
// append -SNAPSHOT to version when isSnapshot
dynverSonatypeSnapshots := true,
resolvers += "Akka library repository".at("https://repo.akka.io/maven"),
// add snapshot repo when Akka version overriden
resolvers ++=
(if (Dependencies.AkkaVersion.endsWith("-SNAPSHOT"))
Seq("Akka library snapshot repository".at("https://repo.akka.io/snapshots"))
else Seq.empty)))
def common: Seq[Setting[_]] =
Seq(
crossScalaVersions := Dependencies.ScalaVersions,
scalaVersion := Dependencies.Scala213,
crossVersion := CrossVersion.binary,
scalafmtOnCompile := true,
// Setting javac options in common allows IntelliJ IDEA to import them automatically
Compile / javacOptions ++= Seq("-encoding", "UTF-8", "--release", "11"),
Compile / scalacOptions ++= Seq("-release", "11"),
headerLicense := Some(
HeaderLicense.Custom("""Copyright (C) 2022 - 2024 Lightbend Inc. <https://www.lightbend.com>""")),
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 -Dakka. properties to the javaOptions for forked tests
// useful to switch DB dialects for example
val akkaProperties = System.getProperties.stringPropertyNames.asScala.toList.collect {
case key: String if key.startsWith("akka.") || key.startsWith("conf") =>
"-D" + key + "=" + System.getProperty(key)
}
"-Xms1G" :: "-Xmx1G" :: "-XX:MaxDirectMemorySize=256M" :: akkaProperties
},
projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value),
Compile / doc / scalacOptions := scalacOptions.value ++ Seq(
"-doc-title",
"Akka Persistence R2DBC",
"-doc-version",
version.value) ++ {
// make use of https://github.com/scala/scala/pull/8663
if (scalaBinaryVersion.value.startsWith("3")) {
Seq(s"-external-mappings:https://docs.oracle.com/en/java/javase/${Dependencies.JavaDocLinkVersion}/docs/api")
} else {
Seq("-jdk-api-doc-base", s"https://docs.oracle.com/en/java/javase/${Dependencies.JavaDocLinkVersion}/docs/api")
}
},
Global / excludeLintKeys += projectInfoVersion,
Global / excludeLintKeys += mimaReportSignatureProblems,
Global / excludeLintKeys += mimaPreviousArtifacts,
mimaReportSignatureProblems := true,
mimaPreviousArtifacts :=
Set(
organization.value %% moduleName.value % previousStableVersion.value
.getOrElse(throw new Error("Unable to determine previous version"))))
lazy val dontPublish = Seq(publish / skip := true, Compile / publishArtifact := false)
lazy val root = (project in file("."))
.settings(common)
.settings(dontPublish)
.settings(
name := "akka-persistence-r2dbc-root",
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo"))))
.enablePlugins(ScalaUnidocPlugin)
.disablePlugins(SitePlugin, MimaPlugin, CiReleasePlugin)
.aggregate(core, migration, migrationTests, docs)
def suffixFileFilter(suffix: String): FileFilter = new SimpleFileFilter(f => f.getAbsolutePath.endsWith(suffix))
lazy val core = (project in file("core"))
.settings(common)
.settings(name := "akka-persistence-r2dbc", libraryDependencies ++= Dependencies.core)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(CiReleasePlugin)
lazy val migration = (project in file("migration"))
.settings(common)
.settings(
name := "akka-persistence-r2dbc-migration",
Test / mainClass := Some("akka.persistence.r2dbc.migration.MigrationTool"),
Test / run / fork := true,
Test / run / javaOptions ++= {
import scala.collection.JavaConverters._
// include all passed -Dakka. properties to the javaOptions for forked tests
// useful to switch DB dialects for example
val akkaProperties = System.getProperties.stringPropertyNames.asScala.toList.collect {
case key: String if key.startsWith("akka.") => "-D" + key + "=" + System.getProperty(key)
}
"-Dlogback.configurationFile=logback-main.xml" :: "-Xms1G" :: "-Xmx1G" :: "-XX:MaxDirectMemorySize=256M" :: akkaProperties
})
.dependsOn(core)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin, CiReleasePlugin)
lazy val migrationTests = (project in file("migration-tests"))
.settings(common)
.settings(name := "akka-persistence-r2dbc-migration-tests", libraryDependencies ++= Dependencies.migrationTests)
.dependsOn(migration)
.dependsOn(core % "compile->compile;test->test")
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin, CiReleasePlugin)
.settings(dontPublish)
lazy val docs = project
.in(file("docs"))
.enablePlugins(AkkaParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, PublishRsyncPlugin)
.disablePlugins(MimaPlugin, CiReleasePlugin)
.dependsOn(core, migration)
.settings(common)
.settings(dontPublish)
.settings(
name := "Akka Persistence plugin for R2DBC",
libraryDependencies ++= Dependencies.docs,
makeSite := makeSite.dependsOn(LocalRootProject / ScalaUnidoc / doc).value,
previewPath := (Paradox / siteSubdirName).value,
Preprocess / siteSubdirName := s"api/akka-persistence-r2dbc/${projectInfoVersion.value}",
Preprocess / sourceDirectory := (LocalRootProject / ScalaUnidoc / unidoc / target).value,
Paradox / siteSubdirName := s"libraries/akka-persistence-r2dbc/${projectInfoVersion.value}",
paradoxGroups := Map(
"Language" -> Seq("Java", "Scala"),
"Dialect" -> Seq("Postgres", "Yugabyte", "H2", "SQLServer")),
Compile / paradoxProperties ++= Map(
"project.url" -> "https://doc.akka.io/libraries/akka-persistence-r2dbc/current/",
"canonical.base_url" -> "https://doc.akka.io/libraries/akka-persistence-r2dbc/current",
"akka.version" -> Dependencies.AkkaVersion,
"h2.version" -> Dependencies.H2Version,
"r2dbc-h2.version" -> Dependencies.R2dbcH2Version,
"scala.version" -> scalaVersion.value,
"scala.binary.version" -> scalaBinaryVersion.value,
"extref.akka.base_url" -> s"https://doc.akka.io/libraries/akka-core/${Dependencies.AkkaVersionInDocs}/%s",
"extref.akka-docs.base_url" -> s"https://doc.akka.io/libraries/akka-core/${Dependencies.AkkaVersionInDocs}/%s",
"extref.akka-projection.base_url" -> s"https://doc.akka.io/libraries/akka-projection/${Dependencies.AkkaProjectionVersionInDocs}/%s",
"extref.java-docs.base_url" -> s"https://docs.oracle.com/en/java/javase/${Dependencies.JavaDocLinkVersion}/%s",
"scaladoc.scala.base_url" -> s"https://www.scala-lang.org/api/current/",
"scaladoc.akka.persistence.r2dbc.base_url" -> s"/${(Preprocess / siteSubdirName).value}/",
"javadoc.akka.persistence.r2dbc.base_url" -> "", // no Javadoc is published
"scaladoc.akka.base_url" -> s"https://doc.akka.io/api/akka/${Dependencies.AkkaVersionInDocs}/",
"javadoc.akka.base_url" -> s"https://doc.akka.io/japi/akka/${Dependencies.AkkaVersionInDocs}/",
"scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/",
"sqlserver.version" -> Dependencies.SqlServerR2dbcVersion),
ApidocPlugin.autoImport.apidocRootPackage := "akka",
apidocRootPackage := "akka",
resolvers += Resolver.jcenterRepo,
publishRsyncArtifacts += makeSite.value -> "www/",
publishRsyncHost := "[email protected]")
val isJdk11orHigher: Boolean = {
val result = VersionNumber(sys.props("java.specification.version")).matchesSemVer(SemanticSelector(">=11"))
if (!result)
throw new IllegalArgumentException("JDK 11 or higher is required")
result
}