-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
186 lines (172 loc) · 5.44 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 build._
import sbtrelease._
import ReleaseStateTransformations._
Global / onChangedBuildSource := ReloadOnSourceChanges
val tagName = Def.setting {
s"v${if (releaseUseGlobalVersion.value) (ThisBuild / version).value else version.value}"
}
val tagOrHash = Def.setting {
if (isSnapshot.value) gitHash() else tagName.value
}
def gitHash(): String = sys.process.Process("git rev-parse HEAD").lineStream_!.head
val unusedWarnings = Seq(
"-Ywarn-unused",
)
val Scala212 = "2.12.20"
val Scala3 = "3.3.4"
lazy val commonSettings = Def.settings(
ReleasePlugin.extraReleaseCommands,
name := msgpack4zNativeName,
crossScalaVersions := Scala212 :: "2.13.16" :: Scala3 :: Nil,
commands += Command.command("updateReadme")(UpdateReadme.updateReadmeTask),
publishTo := sonatypePublishToBundle.value,
fullResolvers ~= { _.filterNot(_.name == "jcenter") },
compile / javacOptions ++= Seq("-target", "6", "-source", "6"),
releaseTagName := tagName.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
UpdateReadme.updateReadmeProcess,
tagRelease,
ReleaseStep(
action = { state =>
val extracted = Project extract state
extracted.runAggregated(extracted.get(thisProjectRef) / (Global / PgpKeys.publishSigned), state)
},
enableCrossBuild = true
),
releaseStepCommandAndRemaining("+ msgpack4zNativeNative/publishSigned"),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
UpdateReadme.updateReadmeProcess,
pushChanges
),
credentials ++= PartialFunction
.condOpt(sys.env.get("SONATYPE_USER") -> sys.env.get("SONATYPE_PASS")) { case (Some(user), Some(pass)) =>
Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, pass)
}
.toList,
organization := "com.github.xuwei-k",
homepage := Some(url("https://github.com/msgpack4z")),
licenses := Seq("MIT License" -> url("http://www.opensource.org/licenses/mit-license.php")),
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-Xlint",
"-language:existentials,higherKinds,implicitConversions",
) ++ unusedWarnings,
scalacOptions ++= PartialFunction
.condOpt(CrossVersion.partialVersion(scalaVersion.value)) {
case Some((2, v)) if v <= 12 =>
Seq(
"-Yno-adapted-args",
"-Xfuture"
)
}
.toList
.flatten,
(Compile / doc / scalacOptions) ++= {
val tag = tagOrHash.value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Nil
case _ =>
Seq(
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url",
s"https://github.com/msgpack4z/msgpack4z-native/tree/${tag}€{FILE_PATH}.scala"
)
}
},
scalaVersion := Scala212,
pomExtra :=
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
</developers>
<scm>
<url>git@github.com:msgpack4z/msgpack4z-native.git</url>
<connection>scm:git:git@github.com:msgpack4z/msgpack4z-native.git</connection>
<tag>{tagOrHash.value}</tag>
</scm>,
description := "msgpack4z",
pomPostProcess := { node =>
import scala.xml._
import scala.xml.transform._
def stripIf(f: Node => Boolean) =
new RewriteRule {
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf { n => n.label == "dependency" && (n \ "scope").text == "test" }
new RuleTransformer(stripTestScope).transform(node)(0)
}
) ++ Seq(Compile, Test).flatMap(c => c / console / scalacOptions ~= { _.filterNot(unusedWarnings.toSet) })
lazy val msgpack4zNative = crossProject(
JSPlatform,
JVMPlatform,
NativePlatform
).crossType(CustomCrossType)
.in(file("."))
.settings(
commonSettings,
scalapropsCoreSettings,
libraryDependencies ++= Seq(
"com.github.scalaprops" %%% "scalaprops" % "0.9.1" % "test",
)
)
.jvmSettings(
libraryDependencies ++= Seq(
"com.github.xuwei-k" % "msgpack4z-api" % "0.2.0",
)
)
.platformsSettings(NativePlatform, JSPlatform)(
(Compile / unmanagedSourceDirectories) += {
baseDirectory.value.getParentFile / "js_native/src/main/scala/"
}
)
.jsSettings(
scalacOptions ++= {
val a = (LocalRootProject / baseDirectory).value.toURI.toString
val g = "https://raw.githubusercontent.com/msgpack4z/msgpack4z-native/" + tagOrHash.value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq(s"-scalajs-mapSourceURI:$a->$g/")
case _ =>
Seq(s"-P:scalajs:mapSourceURI:$a->$g/")
}
}
)
lazy val msgpack4zNativeJVM = msgpack4zNative.jvm
lazy val msgpack4zNativeJS = msgpack4zNative.js
lazy val msgpack4zNativeNative = msgpack4zNative.native.settings(
scalapropsNativeSettings,
)
lazy val noPublish = Seq(
PgpKeys.publishSigned := {},
PgpKeys.publishLocalSigned := {},
publishLocal := {},
Compile / publishArtifact := false,
publish := {}
)
lazy val root = Project(
"root",
file(".")
).settings(
commonSettings,
Compile / scalaSource := baseDirectory.value / "dummy",
Test / scalaSource := baseDirectory.value / "dummy",
noPublish
).aggregate(
msgpack4zNativeJVM,
msgpack4zNativeJS
)