scalive/build.mill

98 lines
2.8 KiB
Text
Raw Permalink Normal View History

2025-11-07 05:10:10 +01:00
//| mvnDeps:
//| - com.raquo::domtypes:18.1.0
//| - com.goyeau::mill-scalafix::0.6.0
2025-08-03 19:51:02 +02:00
package build
2025-11-07 23:45:41 +01:00
import mill.*, scalalib.*, javascriptlib.TypeScriptModule, publish.*
2025-11-07 05:10:10 +01:00
import mill.scalalib.scalafmt.ScalafmtModule
import mill.api.Task.Simple
import java.net.URI
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes
import java.util
2025-11-07 05:10:10 +01:00
import com.goyeau.mill.scalafix.ScalafixModule
2025-08-03 19:51:02 +02:00
2025-11-07 05:10:10 +01:00
trait ScalaCommon extends ScalaModule with ScalafmtModule with ScalafixModule:
2025-11-07 23:45:41 +01:00
def scalaVersion = "3.7.3"
def scalacOptions = Seq(
"-Wunused:all",
"-preview",
"-feature",
"-language:implicitConversions",
2025-09-03 18:08:17 +02:00
"-Wvalue-discard",
2025-12-08 05:19:21 +01:00
"-Wnonunit-statement",
"-deprecation"
)
2025-08-15 22:51:27 +02:00
2025-11-07 23:45:41 +01:00
trait PublishCommon extends PublishModule:
def publishVersion = "0.0.1"
def pomSettings = PomSettings(
description = artifactName(),
organization = "phfroidmont",
url = "https://github.com/phfroidmont/scalive",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("phfroidmont", "scalive"),
developers =
Seq(Developer("phfroidmont", "Paul-Henri Froidmont", "https://github.com/phfroidmont"))
)
object scalive extends Module:
object core extends ScalaCommon with PublishCommon:
def mvnDeps = Seq(mvn"dev.zio::zio-json:0.7.44")
2025-08-09 01:31:43 +02:00
2025-11-07 23:45:41 +01:00
def generatedSources = Task {
new DomDefsGenerator((Task.dest / "core/src/scalive").toString).generate()
super.generatedSources() ++ Seq(PathRef(Task.dest))
}
2025-11-07 23:45:41 +01:00
object test extends ScalaTests with scalalib.TestModule.Utest:
def utestVersion = "0.9.0"
2025-08-09 01:31:43 +02:00
2025-11-07 23:45:41 +01:00
object zio extends ScalaCommon with PublishCommon:
def mvnDeps = Seq(mvn"dev.zio::zio-http:3.4.0")
def moduleDeps = Seq(core)
2025-12-23 03:24:59 +01:00
object test extends ScalaTests with scalalib.TestModule.ZioTest:
def zioTestVersion = "2.1.23"
object example extends ScalaCommon:
2025-11-07 23:45:41 +01:00
def moduleDeps = Seq(scalive.zio)
2025-09-12 17:35:11 +02:00
def mvnDeps = Seq(mvn"dev.optics::monocle-core:3.1.0", mvn"dev.zio::zio-logging:2.5.1")
2025-09-11 19:45:46 +02:00
def tailwindConfig = Task.Source(moduleDir / "tailwind.css")
def generateCss = Task {
sources()
os.proc(
"tailwindcss",
"--minify",
"--input",
tailwindConfig().path
).call().out.text()
}
2025-12-23 23:06:16 +01:00
def customResources = Task {
2025-09-11 19:45:46 +02:00
os.write(
target = Task.dest / "public" / "app.css",
data = generateCss(),
createFolders = true
)
2025-12-23 23:06:16 +01:00
os.copy(
from = example.js.bundle().path,
to = Task.dest / "public" / "app.js",
createFolders = true
)
2025-09-11 19:45:46 +02:00
PathRef(Task.dest)
}
def resources = Task {
2025-12-23 23:06:16 +01:00
super.resources() :+ customResources()
}
object js extends TypeScriptModule:
2025-08-25 01:17:02 +02:00
def mainFileName = "app.js"
2025-09-17 02:29:38 +02:00
def npmDeps = Seq("phoenix@1.7.21", "phoenix_live_view@1.1.8", "topbar@3.0.0", "daisyui@5.1.12")
def bundleFlags = super.bundleFlags() ++ Map("minify" -> ujson.Bool(false))
2025-09-11 19:45:46 +02:00
end example