-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
186 lines (174 loc) · 4.98 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 sbtrelease._
import ReleaseStateTransformations._
val Scala212 = "2.12.20"
val Scala213 = "2.13.16"
val Scala3 = "3.3.5"
val isScala3 = Def.setting(
CrossVersion.partialVersion(scalaVersion.value).exists(_._1 == 3)
)
def gitHash(): String = sys.process.Process("git rev-parse HEAD").lineStream_!.head
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
}
val runAll = TaskKey[Unit]("runAll")
def runAllIn(config: Configuration): Setting[Task[Unit]] = {
(config / runAll) := {
val classes = (config / discoveredMainClasses).value
val runner0 = (run / runner).value
val cp = (config / fullClasspath).value
val s = streams.value
classes.foreach(c => runner0.run(c, Attributed.data(cp), Seq(), s.log))
}
}
val commonSettings = Def.settings(
scalapropsCoreSettings,
scalapropsVersion := "0.9.1",
organization := "com.github.xuwei-k",
description := "optparse-applicative is a Scala library for parsing options on the command line, providing a powerful applicative interface for composing these options",
homepage := Some(url("https://github.com/xuwei-k/optparse-applicative")),
licenses := Seq(
"BSD-3-Clause" -> url(s"https://raw.githubusercontent.com/xuwei-k/optparse-applicative/${tagOrHash.value}/LICENSE")
),
pomExtra := {
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
</developers>
<scm>
<url>[email protected]:xuwei-k/optparse-applicative.git</url>
<connection>scm:git:[email protected]:xuwei-k/optparse-applicative.git</connection>
<tag>{tagOrHash.value}</tag>
</scm>
},
publishTo := sonatypePublishToBundle.value,
releaseTagName := tagName.value,
releaseCrossBuild := true,
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("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
UpdateReadme.updateReadmeProcess,
pushChanges
),
scalaVersion := Scala212,
crossScalaVersions := List(Scala212, Scala213, Scala3),
scalacOptions ++= List(
"-feature",
"-deprecation",
"-unchecked",
"-language:existentials,higherKinds,implicitConversions"
),
scalacOptions ++= {
if (isScala3.value) {
Seq(
"-Ykind-projector"
)
} else {
Seq(
"-Xsource:3",
"-Wconf:msg=package object inheritance is deprecated:warning", // TODO
"-Xlint"
)
}
},
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq("-Xfuture", "-Ypartial-unification")
case _ =>
Nil
}
},
(Compile / doc / scalacOptions) ++= {
val tag = tagOrHash.value
if (isScala3.value) {
Nil
} else {
Seq(
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url",
s"https://github.com/xuwei-k/optparse-applicative/tree/${tag}€{FILE_PATH}.scala"
)
}
},
libraryDependencies ++= List(
"com.github.scalaprops" %%% "scalaprops" % scalapropsVersion.value % "test",
"org.scalaz" %%% "scalaz-core" % "7.3.8"
),
libraryDependencies ++= {
if (isScala3.value) {
Nil
} else {
Seq(
compilerPlugin("org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full)
)
}
}
)
lazy val optparseApplicative = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("core"))
.settings(
commonSettings,
name := UpdateReadme.optparseApplicativeName
)
.nativeSettings(
scalapropsNativeSettings
)
.jsSettings(
scalacOptions ++= {
val a = (LocalRootProject / baseDirectory).value.toURI.toString
val g = "https://raw.githubusercontent.com/xuwei-k/optparse-applicative/" + tagOrHash.value
val key = CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
"-scalajs-mapSourceURI"
case _ =>
"-P:scalajs:mapSourceURI"
}
Seq(s"${key}:$a->$g/")
}
)
val jvm = optparseApplicative.jvm
val js = optparseApplicative.js
val native = optparseApplicative.native
val noPublish = Seq(
publish := {},
publishLocal := {},
PgpKeys.publishSigned := {},
PgpKeys.publishLocalSigned := {},
publishArtifact := false
)
val example = project
.in(file("example"))
.settings(
commonSettings,
runAllIn(Compile),
noPublish
)
.dependsOn(
jvm
)
commonSettings
noPublish