-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
74 lines (58 loc) · 1.7 KB
/
build.sc
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
import mill._, scalalib._
import mill.modules.Jvm
import mill.define.Task
import ammonite.ops._
object root extends Cross[Root]("2.11.12", "2.12.4")
class Root(val crossScalaVersion: String) extends CrossScalaModule {
def scalaVersion = crossScalaVersion
def millSourcePath = pwd
def moduleDeps = Seq(models(crossScalaVersion))
def ivyDeps = Agg(
ivy"com.typesafe.akka::akka-http:10.0.13",
ivy"de.heikoseeberger::akka-http-circe:1.20.0"
)
def packageIt = T {
val dest = T.ctx().dest
val libDir = dest / 'lib
val binDir = dest / 'bin
mkdir(libDir)
mkdir(binDir)
val allJars = packageSelfModules() ++ runClasspath()
.map(_.path)
.filter(path => exists(path) && !path.isDir)
.toSeq
allJars.foreach { file =>
cp.into(file, libDir)
}
val runnerFile = Jvm.createLauncher(
finalMainClass(),
Agg.from(ls(libDir)),
forkArgs()
)
mv.into(runnerFile.path, binDir)
PathRef(dest)
}
// package root and dependent modules with meaningfull names
def packageSelfModules = T {
Task.traverse(moduleDeps :+ this) { module =>
module.jar
.zip(module.artifactName)
.zip(module.artifactSuffix)
.map {
case ((jar, name), suffix) =>
val namedJar = jar.path / up / s"${name}${suffix}.jar"
cp(jar.path, namedJar)
namedJar
}
}
}
}
object models extends Cross[Models]("2.11.12", "2.12.4")
class Models(val crossScalaVersion: String) extends CrossScalaModule {
def scalaVersion = crossScalaVersion
def ivyDeps = Agg(
ivy"io.circe::circe-core:0.9.3",
ivy"io.circe::circe-generic:0.9.3",
ivy"io.circe::circe-parser:0.9.3"
)
}