-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.sbt
260 lines (224 loc) · 9.81 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import sbt.Keys.{publishMavenStyle, scalaVersion}
import scala.util.Try
name := "ergo-appkit"
lazy val sonatypePublic = "Sonatype Public" at "https://oss.sonatype.org/content/groups/public/"
lazy val sonatypeReleases = "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
lazy val sonatypeSnapshots = "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
lazy val scala213 = "2.13.8"
lazy val scala212 = "2.12.10"
lazy val scala211 = "2.11.12"
//javacOptions ++=
// "-source" :: "1.7" ::
// "-target" :: "1.7" ::
// Nil
lazy val commonSettings = Seq(
organization := "org.ergoplatform",
crossScalaVersions := Seq(scala213, scala212, scala211),
scalaVersion := scala213,
resolvers ++= Seq(sonatypeReleases,
"SonaType" at "https://oss.sonatype.org/content/groups/public",
"Typesafe maven releases" at "https://dl.bintray.com/typesafe/maven-releases/",
sonatypeSnapshots,
Resolver.mavenCentral),
homepage := Some(url("https://github.com/ergoplatform/ergo-appkit")),
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode")),
description := "A Library for Polyglot Development of Ergo Applications",
pomExtra :=
<developers>
<developer>
<id>aslesarenko</id>
<name>Alexander Slesarenko</name>
<url>https://github.com/aslesarenko/</url>
</developer>
</developers>,
publishArtifact in (Compile, packageSrc) := true,
publishArtifact in (Compile, packageDoc) := true,
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value,
scmInfo := Some(
ScmInfo(url("https://github.com/ergoplatform/ergo-appkit"), "scm:[email protected]:ergoplatform/ergo-appkit.git")
),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
)
)
enablePlugins(GitVersioning)
version in ThisBuild := {
if (git.gitCurrentTags.value.nonEmpty) {
git.gitDescribedVersion.value.get
} else {
if (git.gitHeadCommit.value.contains(git.gitCurrentBranch.value)) {
// see https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
if (Try(sys.env("TRAVIS")).getOrElse("false") == "true") {
// pull request number, "false" if not a pull request
if (Try(sys.env("TRAVIS_PULL_REQUEST")).getOrElse("false") != "false") {
// build is triggered by a pull request
val prBranchName = Try(sys.env("TRAVIS_PULL_REQUEST_BRANCH")).get
val prHeadCommitSha = Try(sys.env("TRAVIS_PULL_REQUEST_SHA")).get
prBranchName + "-" + prHeadCommitSha.take(8) + "-SNAPSHOT"
} else {
// build is triggered by a push
val branchName = Try(sys.env("TRAVIS_BRANCH")).get
branchName + "-" + git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
} else {
git.gitCurrentBranch.value + "-" + git.gitHeadCommit.value.get.take(8) + "-SNAPSHOT"
}
}
}
git.gitUncommittedChanges in ThisBuild := true
val mockitoScalaVerstion = "1.11.4"
lazy val testingDependencies = Seq(
"org.scalatest" %% "scalatest" % "3.2.14" % "test",
"org.scalactic" %% "scalactic" % "3.2.14" % "test",
"org.scalacheck" %% "scalacheck" % "1.15.2" % "test", // last supporting Scala 2.11
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % Test, // last supporting Scala 2.11
"com.lihaoyi" %% "pprint" % "0.6.3" % "test", // the last version with Scala 2.11 support
(sigmaState % Test).classifier("tests")
)
lazy val testSettings = Seq(
libraryDependencies ++= testingDependencies,
parallelExecution in Test := false,
baseDirectory in Test := file("."),
publishArtifact in Test := true,
publishArtifact in(Test, packageSrc) := true,
publishArtifact in(Test, packageDoc) := false,
test in assembly := {})
lazy val allResolvers = Seq(
sonatypePublic,
sonatypeReleases,
sonatypeSnapshots,
Resolver.mavenCentral
)
publishArtifact in Compile := true
publishArtifact in Test := true
credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
// set bytecode version to 8 to fix NoSuchMethodError for various ByteBuffer methods
// see https://github.com/eclipse/jetty.project/issues/3244
// these options applied only in "compile" task since scalac crashes on scaladoc compilation with "-release 8"
// see https://github.com/scala/community-builds/issues/796#issuecomment-423395500
//scalacOptions in(Compile, compile) ++= Seq("-release", "8")
test in assembly := {}
assemblyJarName in assembly := s"ergo-appkit-${version.value}.jar"
assemblyMergeStrategy in assembly := {
case "logback.xml" => MergeStrategy.first
case "module-info.class" => MergeStrategy.discard
case other => (assemblyMergeStrategy in assembly).value(other)
}
lazy val allConfigDependency = "compile->compile;test->test"
val sigmaStateVersion = "5.0.12"
val ergoWalletVersion = "5.0.15"
lazy val sigmaState = ("org.scorexfoundation" %% "sigma-state" % sigmaStateVersion).force()
.exclude("ch.qos.logback", "logback-classic")
.exclude("org.scorexfoundation", "scrypto")
.exclude("org.typelevel", "machinist")
.exclude("org.typelevel", "cats-kernel")
lazy val ergoWallet = "org.ergoplatform" %% "ergo-wallet" % ergoWalletVersion
lazy val mockWebServer = "com.squareup.okhttp3" % "mockwebserver" % "3.12.0" % "test"
libraryDependencies ++= Seq(
sigmaState,
(sigmaState % Test).classifier("tests"),
ergoWallet,
"org.scalatest" %% "scalatest" % "3.2.14" % "test",
"org.scalacheck" %% "scalacheck" % "1.15.2" % "test", // last supporting Scala 2.11
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % Test, // last supporting Scala 2.11
"com.squareup.retrofit2" % "retrofit" % "2.6.2",
"com.squareup.retrofit2" % "converter-scalars" % "2.6.2",
"com.squareup.retrofit2" % "converter-gson" % "2.6.2"
)
val apiClientDeps = Seq(
"com.squareup.okhttp3" % "okhttp" % "3.12.0",
"com.google.code.findbugs" % "jsr305" % "3.0.2",
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
"io.swagger.core.v3" % "swagger-annotations" % "2.0.0",
"com.squareup.retrofit2" % "retrofit" % "2.6.2",
"com.squareup.retrofit2" % "converter-scalars" % "2.6.2",
"com.squareup.retrofit2" % "converter-gson" % "2.6.2",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.11" % Test
)
lazy val javaClientGenerated = (project in file("java-client-generated"))
.settings(
commonSettings,
name := "java-client-generated",
crossPaths := false,
libraryDependencies ++= apiClientDeps,
testOptions += Tests.Argument(TestFrameworks.JUnit),
publishArtifact in (Compile, packageDoc) := false,
publish / skip := true
)
lazy val common = (project in file("common"))
.settings(
commonSettings ++ testSettings,
name := "common",
resolvers ++= allResolvers,
libraryDependencies ++= Seq(
sigmaState,
ergoWallet,
"com.google.code.findbugs" % "jsr305" % "1.3.9"
),
publish / skip := true
)
lazy val libApi = (project in file("lib-api"))
.dependsOn(common % allConfigDependency)
.settings(
commonSettings ++ testSettings,
resolvers ++= allResolvers,
name := "lib-api",
libraryDependencies ++= Seq(
),
publish / skip := true
)
lazy val libImpl = (project in file("lib-impl"))
.dependsOn(javaClientGenerated % allConfigDependency, libApi % allConfigDependency)
.settings(
commonSettings ++ testSettings,
name := "lib-impl",
resolvers ++= allResolvers,
libraryDependencies ++= Seq(
),
publish / skip := true
)
lazy val appkit = (project in file("appkit"))
.dependsOn(
common % allConfigDependency,
javaClientGenerated % allConfigDependency,
libApi % allConfigDependency,
libImpl % allConfigDependency)
.settings(commonSettings ++ testSettings,
libraryDependencies ++= Seq(
mockWebServer//,
// "org.mockito" %% "mockito-scala" % mockitoScalaVerstion % "test",
// "org.mockito" %% "mockito-scala-scalatest" % mockitoScalaVerstion % "test"
))
.settings(publish / skip := true)
lazy val aggregateCompile = ScopeFilter(
inProjects(common, javaClientGenerated, libApi, libImpl, appkit),
inConfigurations(Compile))
lazy val rootSettings = Seq(
sources in Compile := sources.all(aggregateCompile).value.flatten,
sources in (Compile, doc) := Seq(), // generate empty javadoc (required by sonatype)
libraryDependencies := libraryDependencies.all(aggregateCompile).value.flatten,
mappings in (Compile, packageSrc) ++= (mappings in(Compile, packageSrc)).all(aggregateCompile).value.flatten,
mappings in (Test, packageBin) ++= (mappings in(Test, packageBin)).all(aggregateCompile).value.flatten,
mappings in(Test, packageSrc) ++= (mappings in(Test, packageSrc)).all(aggregateCompile).value.flatten
)
lazy val root = (project in file("."))
.aggregate(appkit, common, javaClientGenerated, libApi, libImpl)
.settings(commonSettings ++ testSettings, rootSettings)
.settings(publish / aggregate := false)
.settings(publishLocal / aggregate := false)
// PGP key for signing a release build published to sonatype
// signing is done by sbt-pgp plugin
// how to generate a key - https://central.sonatype.org/pages/working-with-pgp-signatures.html
// how to export a key and use it with Travis - https://docs.scala-lang.org/overviews/contributors/index.html#export-your-pgp-key-pair
pgpPublicRing := file("ci/pubring.asc")
pgpSecretRing := file("ci/secring.asc")
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toArray)
usePgpKeyHex("C56E488A4B3A9E370275612F55B67E9C7DF9FACE")