-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sbt
174 lines (160 loc) · 5.73 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
import scala.sys.process._
import scala.language.postfixOps
import sbtwelcome._
import indigoplugin._
val scala3Version = "3.5.0"
val indigoVersion = "0.17.0"
val roguelikeStarterKitVersion = "0.5.1-SNAPSHOT"
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / scalaVersion := scala3Version
lazy val commonSettings: Seq[sbt.Def.Setting[_]] = Seq(
version := roguelikeStarterKitVersion,
scalaVersion := scala3Version,
organization := "io.indigoengine",
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % "0.7.29" % Test
),
testFrameworks += new TestFramework("munit.Framework"),
Test / scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) },
scalafixOnCompile := true,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
lazy val publishSettings = {
import xerial.sbt.Sonatype._
Seq(
publishTo := sonatypePublishToBundle.value,
publishMavenStyle := true,
sonatypeProfileName := "io.indigoengine",
licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")),
sonatypeProjectHosting := Some(
GitHubHosting("PurpleKingdomGames", "roguelike-starterkit", "[email protected]")
),
developers := List(
Developer(
id = "davesmith00000",
name = "David Smith",
email = "[email protected]",
url = url("https://github.com/davesmith00000")
)
)
)
}
lazy val roguelike =
(project in file("roguelike-starterkit"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(publishSettings: _*)
.settings(
name := "roguelike-starterkit",
libraryDependencies ++= Seq(
"io.indigoengine" %%% "indigo" % indigoVersion,
"io.indigoengine" %%% "indigo-extras" % indigoVersion
)
)
.settings(
Compile / sourceGenerators += Def.task {
TileCharGen
.gen(
"RoguelikeTiles", // Class/module name.
"roguelikestarterkit.tiles", // fully qualified package name
(Compile / sourceManaged).value // Managed sources (output) directory for the generated classes
)
}.taskValue
)
lazy val demoOptions: IndigoOptions =
IndigoOptions.defaults
.withTitle("Indigo Roguelike!")
.withBackgroundColor("black")
.withAssetDirectory("demo/assets")
.withWindowSize(800, 600)
.useElectronExecutable("npx electron")
lazy val demo =
(project in file("demo"))
.enablePlugins(ScalaJSPlugin, SbtIndigo)
.settings(commonSettings: _*)
.settings(
name := "roguelike-demo",
indigoOptions := demoOptions,
libraryDependencies ++= Seq(
"io.indigoengine" %%% "indigo-json-circe" % indigoVersion,
"io.indigoengine" %%% "indigo" % indigoVersion,
"io.indigoengine" %%% "indigo-extras" % indigoVersion
)
// scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) } // required for parcel, but will break indigoRun & indigoBuild
)
.settings(
publish / skip := true,
publishLocal / skip := true
)
.settings(
Compile / sourceGenerators += Def.task {
IndigoGenerators("demo")
.listAssets("Assets", demoOptions.assets)
.generateConfig("Config", demoOptions)
.toSourceFiles((Compile / sourceManaged).value)
}
)
.dependsOn(roguelike)
lazy val benchmarks =
project
.in(file("benchmarks"))
.enablePlugins(ScalaJSPlugin, JSDependenciesPlugin)
.dependsOn(roguelike)
.settings(
name := "benchmarks",
version := roguelikeStarterKitVersion,
organization := "io.indigoengine",
Test / test := {},
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-benchmark" %%% "benchmark" % "0.10.0"
),
jsDependencies ++= Seq(
"org.webjars" % "chartjs" % "1.0.2" / "Chart.js" minified "Chart.min.js"
),
packageJSDependencies / skip := false
)
.settings(
publish / skip := true,
publishLocal / skip := true
)
lazy val roguelikeStarterKit =
(project in file("."))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(
code := { "code ." ! }
)
.settings(
publish / skip := true,
publishLocal / skip := true
)
.aggregate(roguelike, demo, benchmarks)
.settings(
logo := rawLogo + "(v" + version.value.toString + ")",
usefulTasks := Seq(
UsefulTask("runGame", "Run the game").noAlias,
UsefulTask("publishLocal", "Local publish").noAlias,
UsefulTask("code", "Launch VSCode").noAlias
),
logoColor := scala.Console.YELLOW,
aliasColor := scala.Console.BLUE,
commandColor := scala.Console.CYAN,
descriptionColor := scala.Console.WHITE
)
// To use indigoBuild or indigoRun, first comment out the line above that says: `scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }`
addCommandAlias("runGame", ";demo/compile;demo/fastLinkJS;demo/indigoRun")
addCommandAlias("buildGame", ";demo/compile;demo/fastLinkJS;demo/indigoBuild")
lazy val code =
taskKey[Unit]("Launch VSCode in the current directory")
// format: off
lazy val rawLogo: String =
"""
___ __
_______ ___ ___ _____ / (_) /_____
/ __/ _ \/ _ `/ // / -_) / / '_/ -_)
/_/ \___/\_, /\_,_/\__/_/_/_/\_\\__/_ _ __
___ / //___/_____/ /____ ________/ /__ (_) /_
(_-</ __/ _ `/ __/ __/ -_) __/___/ '_// / __/
/___/\__/\_,_/_/ \__/\__/_/ /_/\_\/_/\__/
"""