-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
170 lines (142 loc) · 4.12 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
import sbtrelease._
import ReleaseStateTransformations._
scriptedBatchExecution := false
publishTo := sonatypePublishToBundle.value
val tagName = Def.setting {
s"v${if (releaseUseGlobalVersion.value) (ThisBuild / version).value else version.value}"
}
val tagOrHash = Def.setting {
if (isSnapshot.value) sys.process.Process("git rev-parse HEAD").lineStream_!.head
else tagName.value
}
scalapropsSettings
crossScalaVersions += "3.6.3"
libraryDependencies ++= {
scalaBinaryVersion.value match {
case "3" =>
Nil
case _ =>
Seq(
Defaults.sbtPluginExtra(
m = "org.scala-native" % "sbt-scala-native" % nativeVersion % "provided",
sbtV = (pluginCrossBuild / sbtBinaryVersion).value,
scalaV = (pluginCrossBuild / scalaBinaryVersion).value
)
)
}
}
scalapropsVersion := "0.9.1"
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.12" =>
(pluginCrossBuild / sbtVersion).value
case _ =>
"2.0.0-M3"
}
}
TaskKey[Unit]("scriptedTestSbt2") := Def.taskDyn {
val values = sbtTestDirectory.value
.listFiles(_.isDirectory)
.flatMap { dir1 =>
dir1.listFiles(_.isDirectory).map { dir2 =>
dir1.getName -> dir2.getName
}
}
.toList
val args = values.filter {
case ("native", _) => false
case _ => true
}.collect { case (x1, x2) =>
s"${x1}/${x2}"
}
val arg = args.mkString(" ", " ", "")
streams.value.log.info("scripted" + arg)
scripted.toTask(arg)
}.value
enablePlugins(SbtPlugin)
scriptedBufferLog := false
scriptedLaunchOpts ++= {
val javaVmArgs = {
import scala.collection.JavaConverters._
java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList
}
javaVmArgs.filter(a => Seq("-Xmx", "-Xms", "-XX", "-Dsbt.log.noformat").exists(a.startsWith))
}
scriptedLaunchOpts ++= Seq(
"-Dscala-native.version=" + nativeVersion,
"-Dplugin.version=" + version.value,
"-Dscala-native.version=" + nativeVersion,
"-Dscalaprops.version=" + scalapropsVersion.value
)
startYear := Some(2015)
organization := "com.github.scalaprops"
name := "sbt-scalaprops"
description := "sbt plugin for scalaprops"
homepage := Some(url("https://github.com/scalaprops/sbt-scalaprops"))
licenses := Seq("MIT License" -> url("https://www.opensource.org/licenses/mit-license"))
commands += Command.command("updateReadme")(UpdateReadme.updateReadmeTask)
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)
}
(Compile / doc / scalacOptions) ++= {
Seq(
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url",
s"https://github.com/scalaprops/sbt-scalaprops/tree/${tagOrHash.value}€{FILE_PATH}.scala"
)
}
pomExtra :=
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
</developers>
<scm>
<url>[email protected]:scalaprops/sbt-scalaprops.git</url>
<connection>scm:git:[email protected]:scalaprops/sbt-scalaprops.git</connection>
<tag>{tagOrHash.value}</tag>
</scm>
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-language:existentials",
"-language:implicitConversions",
)
scalacOptions ++= {
scalaBinaryVersion.value match {
case "3" =>
Nil
case _ =>
Seq(
"-language:higherKinds",
"-Xlint",
)
}
}
releaseTagName := tagName.value
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
releaseStepCommandAndRemaining("+ test"),
setReleaseVersion,
commitReleaseVersion,
UpdateReadme.updateReadmeProcess,
tagRelease,
releaseStepCommandAndRemaining("+ publishSigned"),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
UpdateReadme.updateReadmeProcess,
pushChanges
)