-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mill
More file actions
210 lines (189 loc) · 6.45 KB
/
build.mill
File metadata and controls
210 lines (189 loc) · 6.45 KB
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
package build
import mill._
import mill.api.JarManifest
import mill.scalalib._
object cli extends Module {
object jvm extends CliCommonModule {
object test extends ScalaTests with TestModule.Munit {
def ivyDeps = Agg(
ivy"org.scalameta::munit::1.1.0"
)
}
}
object ubuntu extends CliCommonModule with CustomJpackageModule {
def jpackageName = "flatmark"
def jpackageType = "deb"
def jpackageOptions = Seq(
"--app-version",
Task.env.getOrElse("VERSION", "0.0.0"),
"--resource-dir",
(cli.moduleDir / "resources" / "jpackage" / "ubuntu").wrapped.toString,
"--linux-package-name",
"flatmark",
"--linux-deb-maintainer",
"sakib@sake.ba"
)
}
object macos extends CliCommonModule with CustomJpackageModule {
def jpackageName = "flatmark"
def jpackageType = "pkg"
def jpackageOptions = Seq(
"--app-version",
"1.0.0", // macos has to be 1.x.y+ ,will bump to 1.10.0 for example when stable release
"--resource-dir",
(cli.moduleDir / "resources" / "jpackage" / "macos").wrapped.toString
)
}
object windows extends CliCommonModule with CustomJpackageModule {
def jpackageName = "flatmark"
def jpackageType = "msi"
def jpackageOptions = Seq(
"--app-version",
s"${Task.env.getOrElse("VERSION", "0.0.0")}.0",
"--resource-dir",
(cli.moduleDir / "resources" / "jpackage" / "windows").wrapped.toString,
"--win-console",
"--win-dir-chooser",
"--win-upgrade-uuid",
"1e8c20e9-f7d8-45da-ba93-22110813ad93"
)
}
trait CliCommonModule extends PlatformScalaModule {
def scalaVersion = "3.7.0"
def mainClass = Some("ba.sake.flatmark.cli.Main")
def moduleDeps = Seq(core, swebserver)
def manifest: T[JarManifest] =
super
.manifest()
.add(
"Implementation-Title" -> "Flatmark CLI",
"Implementation-Version" -> Task.env.getOrElse("VERSION", "0.0.0"),
"Implementation-Vendor" -> "Sake92"
)
def forkArgs = Seq[String](
"-Dfile.encoding=UTF-8",
"-Dorg.jboss.logging.provider=jdk"
// https://github.com/scala/scala3/issues/9013
// "--sun-misc-unsafe-memory-access=allow"
)
}
}
object core extends ScalaModule {
def scalaVersion = "3.7.0"
def moduleDeps = Seq(ssr)
def ivyDeps = Agg(
ivy"com.lihaoyi::os-lib:0.11.4",
ivy"org.commonmark:commonmark:0.24.0",
ivy"org.commonmark:commonmark-ext-gfm-tables:0.24.0",
ivy"org.commonmark:commonmark-ext-gfm-strikethrough:0.24.0",
ivy"org.commonmark:commonmark-ext-autolink:0.24.0",
ivy"org.commonmark:commonmark-ext-heading-anchor:0.24.0",
ivy"org.commonmark:commonmark-ext-footnotes:0.24.0",
ivy"org.commonmark:commonmark-ext-ins:0.24.0",
ivy"org.commonmark:commonmark-ext-image-attributes:0.24.0",
ivy"org.commonmark:commonmark-ext-task-list-items:0.24.0",
ivy"com.hubspot.jinjava:jinjava:2.8.0",
ivy"org.virtuslab::scala-yaml:0.3.0",
ivy"org.jsoup:jsoup:1.21.1",
ivy"org.slf4j:slf4j-jdk14:2.0.17"
)
/* def repositoriesTask = Task.Anon {
super.repositoriesTask() ++ Seq(coursier.MavenRepository("https://jitpack.io"))
}*/
}
// TODO undertow is enough?
object swebserver extends ScalaModule {
def scalaVersion = "3.7.0"
def ivyDeps = Agg(
ivy"ba.sake::sharaf-undertow:0.13.0",
// https://github.com/wildfly/wildfly-common/issues/74
ivy"org.wildfly.common:wildfly-common:1.7.0.Final",
ivy"com.lihaoyi::mainargs:0.7.6",
ivy"com.lihaoyi::os-lib-watch:0.11.4",
ivy"org.slf4j:slf4j-api:2.0.17"
)
}
object ssr extends ScalaModule {
def scalaVersion = "3.7.0"
def ivyDeps = Agg(
ivy"ba.sake::sharaf-undertow:0.13.0",
// https://github.com/wildfly/wildfly-common/issues/74
ivy"org.wildfly.common:wildfly-common:1.7.0.Final",
ivy"org.seleniumhq.selenium:selenium-chrome-driver:4.34.0",
ivy"org.seleniumhq.selenium:selenium-support:4.34.0",
ivy"org.slf4j:slf4j-api:2.0.17"
)
object test extends ScalaTests with TestModule.Munit {
def ivyDeps = Agg(
ivy"org.scalameta::munit::1.1.0",
ivy"org.jsoup:jsoup:1.21.1",
ivy"org.slf4j:slf4j-simple:2.0.17"
)
}
}
trait CustomJpackageModule extends JpackageModule {
def jpackageOptions: T[Seq[String]] = Seq.empty[String]
def jpackageAppImage2: T[PathRef] = Task {
// materialize all jars into a "lib" dir
val libs = Task.dest / "lib"
val temp = Task.dest / "temp"
val cp = jpackageRunClasspath().map(_.path)
val jars = cp.filter(os.exists).zipWithIndex.map { case (p, idx) =>
val dest = libs / s"${idx + 1}-${p.last}"
os.copy(p, dest, createFolders = true)
dest
}
val appName = jpackageName()
val appType = jpackageType()
val mainClass = jpackageMainClass()
val mainJarName = jars.head.last
val args: Seq[String] = Seq(
mill.util.Jvm.jdkTool("jpackage", this.jvmWorker().javaHome().map(_.path)),
"--type",
appType,
"--name",
appName,
"--input",
libs.toString(),
"--main-jar",
mainJarName,
"--main-class",
mainClass,
"--temp",
temp.toString()
) ++ jpackageOptions()
// run jpackage tool
val outDest = Task.dest / "image"
os.makeDir.all(outDest)
os.proc(args).call(cwd = outDest)
PathRef(outDest)
}
}
// GraalVM kinda works, but it is pain to set up dynamic classpath
// for language bundles etc
/*
object ZincWorkerGraalvm extends JvmWorkerModule {
def jvmId = "graalvm-community:24.0.1"
def jvmIndexVersion = "latest.release"
}
trait CustomNativeImageModule extends NativeImageModule {
def nativeImageOptions = Seq("--no-fallback", "--enable-url-protocols=http", "--initialize-at-build-time=org.wildfly.common.Substitutions")
def zincWorker = mill.define.ModuleRef(ZincWorkerGraalvm)
def nativeImage2: T[PathRef] = Task {
val dest = Task.dest
val executableName = "native-executable"
val args = nativeImageOptions() ++ Seq(
"-cp",
nativeImageClasspath().iterator.map(_.path).mkString(java.io.File.pathSeparator),
finalMainClass(),
(dest / executableName).toString()
)
os.write(dest / "native-executable-args.txt", args.mkString("\n"))
os.proc(Seq(nativeImageTool().path.toString, "@native-executable-args.txt")).call(cwd = dest, stdout = os.Inherit)
val ext = if (mill.main.client.Util.isWindows) ".exe" else ""
val executable = dest / s"${executableName}${ext}"
assert(os.exists(executable))
PathRef(executable)
}
}
*/