-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
128 lines (109 loc) · 3.41 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
name := "sonatype"
enablePlugins(BuildInfoPlugin)
buildInfoKeys := Seq[BuildInfoKey](sbtVersion)
buildInfoPackage := "sonatype"
buildInfoObject := "SonatypeBuildInfo"
Global / onChangedBuildSource := ReloadOnSourceChanges
publishTo := sonatypePublishToBundle.value
scalaVersion := "2.13.15"
organization := "com.github.xuwei-k"
licenses := Seq("MIT" -> url("https://opensource.org/licenses/mit-license"))
homepage := Some(url("https://github.com/xuwei-k/sonatype"))
libraryDependencies += "org.scala-sbt" %% "io" % "1.10.1"
pomExtra :=
<scm>
<url>git@github.com:xuwei-k/sonatype.git</url>
<connection>scm:git:git@github.com:xuwei-k/sonatype.git</connection>
</scm>
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
</developers>
enablePlugins(ConscriptPlugin)
val updateLaunchconfig = TaskKey[File]("updateLaunchconfig")
val launchconfigFile = file("src/main/conscript/sonatype/launchconfig")
val testConscript = TaskKey[Int]("testConscript")
testConscript := Def
.sequential(
updateLaunchconfigTask(false),
csRun.toTask(" sonatype com.github.xuwei-k sonatypeRepository"),
Def.task {
sys.process.Process(s"git checkout ${launchconfigFile}").!
}
)
.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
}
(Compile / doc / scalacOptions) ++= {
val tag = tagOrHash.value
Seq(
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url",
s"https://github.com/xuwei-k/sonatype/tree/${tag}€{FILE_PATH}.scala"
)
}
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-Xlint",
"-Xfuture",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-Ywarn-unused"
)
releaseTagName := tagName.value
import ReleaseTransformations._
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
releaseStepCommandAndRemaining(";scalafmtCheckAll;scalafmtSbtCheck"),
releaseStepTask(testConscript),
runTest,
setReleaseVersion,
releaseStepTask(updateLaunchconfig),
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("publishSigned"),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
updateLaunchconfig := updateLaunchconfigTask(true).value
def updateLaunchconfigTask(commit: Boolean) =
Def.task {
val mainClassName = (Compile / discoveredMainClasses).value match {
case Seq(m) => m
case zeroOrMulti => sys.error(s"could not found main class. $zeroOrMulti")
}
val launchconfig = s"""[app]
| version: ${version.value}
| org: ${organization.value}
| name: ${normalizedName.value}
| class: ${mainClassName}
|[scala]
| version: ${scalaVersion.value}
|[repositories]
| local
| maven-central
|""".stripMargin
IO.write(launchconfigFile, launchconfig)
val s = streams.value.log
if (commit) {
val git = new sbtrelease.Git((LocalRootProject / baseDirectory).value)
git.add(launchconfigFile.getCanonicalPath) ! s
git.commit(message = "update launchconfig", sign = false, signOff = false) ! s
}
launchconfigFile
}