forked from xuwei-k/optparse-applicative
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
166 lines (155 loc) · 4.61 KB
/
Copy pathbuild.sbt
File metadata and controls
166 lines (155 loc) · 4.61 KB
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
import sbtrelease._
import ReleaseStateTransformations._
import sbtcrossproject.{crossProject, CrossType}
val Scala211 = "2.11.12"
val Scala212 = "2.12.8"
val Scala213 = "2.13.0"
def gitHash(): String = sys.process.Process("git rev-parse HEAD").lineStream_!.head
val tagName = Def.setting {
s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).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]] = {
runAll in config := {
val classes = (discoveredMainClasses in config).value
val runner0 = (runner in run).value
val cp = (fullClasspath in config).value
val s = streams.value
classes.foreach(c => runner0.run(c, Attributed.data(cp), Seq(), s.log))
}
}
val commonSettings = Def.settings(
scalapropsCoreSettings,
scalapropsVersion := "0.6.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>git@github.com:xuwei-k/optparse-applicative.git</url>
<connection>scm:git:git@github.com:xuwei-k/optparse-applicative.git</connection>
<tag>{tagOrHash.value}</tag>
</scm>
},
publishTo := sonatypePublishTo.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(PgpKeys.publishSigned in Global in extracted.get(thisProjectRef), state)
},
enableCrossBuild = true
),
releaseStepCommandAndRemaining(s"; ++ ${Scala211} ; native/publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
UpdateReadme.updateReadmeProcess,
pushChanges
),
scalaVersion := Scala211,
crossScalaVersions := List(Scala211, Scala212, Scala213),
scalacOptions ++= List(
"-feature",
"-deprecation",
"-unchecked",
"-Xlint",
"-language:existentials",
"-language:higherKinds"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq("-Xfuture")
case _ =>
Nil
}
},
scalacOptions in (Compile, doc) ++= {
val tag = tagOrHash.value
Seq(
"-sourcepath",
(baseDirectory in LocalRootProject).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.2.28"
),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.10.3" cross CrossVersion.binary)
)
lazy val optparseApplicative = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("core"))
.settings(
commonSettings,
name := UpdateReadme.optparseApplicativeName
)
.nativeSettings(
scalapropsNativeSettings,
crossScalaVersions := Seq(Scala211)
)
.jsSettings(
scalacOptions += {
val a = (baseDirectory in LocalRootProject).value.toURI.toString
val g = "https://raw.githubusercontent.com/xuwei-k/optparse-applicative/" + tagOrHash.value
s"-P:scalajs:mapSourceURI:$a->$g/"
}
)
val jvm = optparseApplicative.jvm.withId("jvm")
val js = optparseApplicative.js.withId("js")
val native = optparseApplicative.native.withId("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
)
lazy val root = project
.in(file("."))
.settings(
commonSettings,
noPublish
)
.aggregate(
// ignore native on purpose
jvm,
js,
example
)