-
Notifications
You must be signed in to change notification settings - Fork 224
/
build.sbt
247 lines (232 loc) · 7.85 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import Dependencies._
import CrossVersion.partialVersion
val g8version = "0.16.2-SNAPSHOT"
val javaVmArgs: List[String] = {
import scala.collection.JavaConverters._
java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList
}
val coursierBootstrap = taskKey[File]("create bootstrap jar")
val coursierBootstrapBatch = taskKey[File]("create bootstrap jar")
ThisBuild / organization := "org.foundweekends.giter8"
ThisBuild / version := g8version
ThisBuild / scalaVersion := scala212
ThisBuild / organizationName := "foundweekends"
ThisBuild / organizationHomepage := Some(url("https://foundweekends.org/"))
ThisBuild / scalacOptions ++= Seq("-language:_", "-deprecation", "-Xlint", "-Xfuture")
ThisBuild / scalacOptions ++= {
scalaBinaryVersion.value match {
case "3" =>
Nil
case _ =>
Seq("-Xsource:3")
}
}
ThisBuild / Compile / packageBin / publishArtifact := true
ThisBuild / homepage := Some(url("https://www.foundweekends.org/giter8/"))
ThisBuild / publishMavenStyle := true
ThisBuild / publishTo :=
Some(
"releases" at
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
)
ThisBuild / Test / publishArtifact := false
ThisBuild / Test / parallelExecution := false
ThisBuild / licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / developers := List(
Developer("n8han", "Nathan Hamblen", "@n8han", url("https://github.com/n8han")),
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n"))
)
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/foundweekends/giter8"), "[email protected]:foundweekends/giter8.git")
)
ThisBuild / commands += Command.command("SetScala213") {
s"++ ${scala213}! -v" :: _
}
// posterous title needs to be giter8, so both app and root are named giter8
lazy val root = (project in file("."))
.enablePlugins(TravisSitePlugin, NoPublish)
.aggregate(app, lib, scaffold, plugin, gitsupport, launcher)
.settings(
name := "giter8",
crossScalaVersions := Nil,
siteGitHubRepo := "foundweekends/giter8",
siteEmail := { "74864734+foundweekends-bot[bot]@users.noreply.github.com" },
publish / skip := true,
customCommands
)
lazy val app = (project in file("app"))
.enablePlugins(SonatypePublish)
.dependsOn(lib, gitsupport)
.settings(
description := "Command line tool to apply templates defined on GitHub",
name := "giter8",
crossScalaVersions := List(scala212, scala213, scala3),
csRun / sourceDirectory := {
(baseDirectory).value.getParentFile / "src" / "main" / "conscript"
},
libraryDependencies += launcherIntf
)
lazy val crossSbt = Seq(
crossSbtVersions := List(sbt1),
scalaVersion := {
val crossSbtVersion = (pluginCrossBuild / sbtVersion).value
partialVersion(crossSbtVersion) match {
case Some((1, _)) => scala212
case _ =>
throw new Exception(s"unexpected sbt version: $crossSbtVersion (supported: 1.X)")
}
}
)
lazy val scaffold = (project in file("scaffold"))
.enablePlugins(SbtPlugin, SonatypePublish)
.dependsOn(lib)
.settings(crossSbt)
.settings(
name := "sbt-giter8-scaffold",
description := "sbt plugin for scaffolding giter8 templates",
sbtPlugin := true,
crossScalaVersions := List(scala212),
scriptedLaunchOpts ++= javaVmArgs.filter(a => Seq("-Xmx", "-Xms", "-XX").exists(a.startsWith)),
scriptedBufferLog := false,
scriptedLaunchOpts += ("-Dplugin.version=" + version.value),
scripted := scripted
.dependsOn(lib / publishLocal)
.evaluated,
Test / test := {
scripted.toTask("").value
}
)
lazy val plugin = (project in file("plugin"))
.enablePlugins(SbtPlugin, SonatypePublish)
.dependsOn(lib)
.settings(crossSbt)
.settings(
name := "sbt-giter8",
description := "sbt plugin for testing giter8 templates",
sbtPlugin := true,
crossScalaVersions := List(scala212),
scriptedLaunchOpts ++= javaVmArgs.filter(a => Seq("-Xmx", "-Xms", "-XX").exists(a.startsWith)),
scriptedBufferLog := false,
scriptedLaunchOpts += ("-Dplugin.version=" + version.value),
scripted := scripted
.dependsOn(lib / publishLocal)
.evaluated,
Test / test := {
scripted.toTask("").value
}
)
lazy val gitsupport = (project in file("cli-git"))
.enablePlugins(BuildInfoPlugin, SonatypePublish)
.settings(
description := "cli and git support library for Giter8",
name := "giter8-cli-git",
crossScalaVersions := List(scala212, scala213, scala3),
libraryDependencies ++= Seq(
scopt,
jgit,
jgitSshApache,
commonsIo,
scalamock % Test
),
libraryDependencies ++= scalatest,
run / fork := true,
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion, scalaBinaryVersion),
buildInfoPackage := "giter8"
)
lazy val lib = (project in file("library"))
.enablePlugins(SonatypePublish)
.dependsOn(gitsupport)
.settings(crossSbt)
.settings(
name := "giter8-lib",
description := "shared library for app and plugin",
crossScalaVersions := List(scala212, scala213, scala3),
libraryDependencies ++= scalatest,
libraryDependencies ++= Seq(
stringTemplate,
jgit,
commonsIo,
plexusArchiver,
scalaXml,
parserCombinator(scalaVersion.value),
scalacheck % Test,
sbtIo % Test,
scalamock % Test,
"org.slf4j" % "slf4j-simple" % "1.7.36" % Test
),
Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000", "-workers", "10")
)
lazy val launcher = (project in file("launcher"))
.enablePlugins(SonatypePublish)
.enablePlugins(ConscriptPlugin)
.dependsOn(gitsupport)
.settings(
description := "Command line tool to apply templates defined on GitHub",
name := "giter8-launcher",
crossScalaVersions := List(scala212, scala213, scala3),
libraryDependencies ++= Seq(
coursier,
verify % Test,
sbtIo % Test
),
testFrameworks += new TestFramework("verify.runner.Framework"),
run / fork := true,
Test / fork := true,
Test / javaOptions ++= Seq(s"""-DG8_HOME=${target.value / "home"}""")
// assemblyMergeStrategy in assembly := {
// case "plugin.properties" => MergeStrategy.concat
// case "module-info.class" => MergeStrategy.discard
// case x =>
// val oldStrategy = (assemblyMergeStrategy in assembly).value
// oldStrategy(x)
// },
)
lazy val bootstrap = (project in file("bootstrap"))
.enablePlugins(SonatypePublish)
.settings(
description := "Bootstrap script for Giter8 launcher",
name := "giter8-bootstrap",
coursierBootstrap := {
val t = target.value / "g8"
val v = version.value
sys.process
.Process(
s"""coursier bootstrap org.foundweekends.giter8:giter8-launcher_2.12:$v --main giter8.LauncherMain -o $t --bat -f"""
)
.!
t
},
coursierBootstrapBatch := {
val _ = coursierBootstrap.value
target.value / "g8.bat"
},
coursierBootstrap / artifact := {
val o = (coursierBootstrap / artifact).value
o.withExtension("sh")
},
coursierBootstrapBatch / artifact := {
val o = (coursierBootstrapBatch / artifact).value
o.withExtension("bat")
},
addArtifact(coursierBootstrap / artifact, coursierBootstrap),
addArtifact(coursierBootstrapBatch / artifact, coursierBootstrapBatch)
)
def customCommands: Seq[Setting[?]] = Seq(
commands += Command.command("release") { state =>
"clean" ::
s"++${scala213}" ::
"lib/publishSigned" ::
"gitsupport/publishSigned" ::
"app/publishSigned" ::
s"++${scala212}" ::
s"^^${sbt1}" ::
"lib/publishSigned" ::
"gitsupport/publishSigned" ::
"launcher/publishSigned" ::
"app/publishSigned" ::
"plugin/publishSigned" ::
"scaffold/publishSigned" ::
"reload" ::
state
}
)