forked from tristanjuricek/knockoff
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
156 lines (146 loc) · 4.36 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
import sbtrelease.ReleaseStateTransformations._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
val tagName = Def.setting{
s"v${if (releaseUseGlobalVersion.value) (ThisBuild / version).value else version.value}"
}
val Scala212 = "2.12.20"
val tagOrHash = Def.setting {
if(isSnapshot.value) sys.process.Process("git rev-parse HEAD").lineStream_!.head
else tagName.value
}
val unusedWarnings = Def.setting(
Seq("-Ywarn-unused:imports")
)
val commonSettings = Def.settings(
releaseTagName := tagName.value,
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(
action = { state =>
val extracted = Project extract state
extracted.runAggregated(extracted.get(thisProjectRef) / (Global / PgpKeys.publishSigned), state)
},
enableCrossBuild = true
),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
),
scalaVersion := Scala212,
crossScalaVersions := Seq(Scala212, "2.13.15", "3.3.4"),
organization := "org.foundweekends",
(Compile / doc / scalacOptions) ++= {
val base = (LocalRootProject / baseDirectory).value.getAbsolutePath
Seq(
"-sourcepath",
base,
"-doc-source-url",
"https://github.com/foundweekends/knockoff/tree/" + tagOrHash.value + "€{FILE_PATH}.scala"
)
},
scalacOptions ++= unusedWarnings.value,
scalacOptions ++= Seq("-language:_", "-deprecation", "-Xlint"),
scalacOptions ++= {
scalaBinaryVersion.value match {
case "3" =>
Nil
case "2.13" =>
Seq("-Xsource:3-cross")
case _ =>
Seq("-Xsource:3")
}
},
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq("-Xfuture")
case _ =>
Nil
}
},
Seq(Compile, Test).flatMap(c =>
(c / console / scalacOptions) --= unusedWarnings.value
),
)
commonSettings
val knockoff = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("."))
.enablePlugins(BuildInfoPlugin)
.settings(
commonSettings,
buildInfoPackage := "knockoff",
buildInfoObject := "KnockoffBuildInfo",
name := "knockoff",
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest-funspec" % "3.2.19" % "test",
"org.scalatest" %%% "scalatest-shouldmatchers" % "3.2.19" % "test",
),
libraryDependencies ++= Seq(
"net.sf.jtidy" % "jtidy" % "r938" % "test"
),
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value,
Test / publishArtifact := false,
pomIncludeRepository := { _ => false },
pomExtra := (
<url>https://github.com/foundweekends/knockoff</url>
<licenses>
<license>
<name>BSD-style</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>[email protected]:foundweekends/knockoff.git</url>
<connection>scm:git:[email protected]:foundweekends/knockoff.git</connection>
</scm>
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
<developer>
<id>tjuricek</id>
<name>Tristan Juricek</name>
<url>https://tristanjuricek.com</url>
</developer>
</developers>
),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %%% "scala-xml" % "2.3.0",
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.4.0"
)
)
.jsSettings(
scalacOptions += {
val a = (LocalRootProject / baseDirectory).value.toURI.toString
val g = "https://raw.githubusercontent.com/foundweekends/knockoff/" + tagOrHash.value
val key = CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
"-scalajs-mapSourceURI"
case _ =>
"-P:scalajs:mapSourceURI"
}
s"${key}:$a->$g/"
},
)
val jvm = knockoff.jvm
val js = knockoff.js
lazy val notPublish = Seq(
publish / skip := true,
publishArtifact := false,
publish := {},
publishLocal := {},
PgpKeys.publishSigned := {},
PgpKeys.publishLocalSigned := {}
)
notPublish