-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sc
107 lines (90 loc) · 3.48 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
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
import $file.deps, deps.{Deps, Scala}
import $file.settings, settings.{GenerateHeaders, HasCSources, JniUtilsPublishModule, JniUtilsPublishVersion, WithDllNameJava}
import mill._, scalalib._
import scala.concurrent.duration._
object `windows-jni-utils` extends MavenModule with JniUtilsPublishVersion with HasCSources with JniUtilsPublishModule with WithDllNameJava {
def linkingLibs = Seq("ole32", "shell32", "advapi32", "kernel32")
def compile = T{
headers.`windows-jni-utils`.compile()
headers.`windows-jni-utils-bootstrap`.compile()
headers.`windows-jni-utils-lmcoursier`.compile()
headers.`windows-jni-utils-coursierapi`.compile()
super.compile()
}
def windowsJavaHome = T{
import java.io.File
val value = sys.props("java.home")
val dir = new File(value)
// Seems required with Java 8
if (dir.getName == "jre") dir.getParent
else value
}
def javacOptions = super.javacOptions() ++ Seq(
"--release", "8"
)
}
object `windows-jni-utils-graalvm` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-bootstrap` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-lmcoursier` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-coursierapi` extends WindowsUtils with JniUtilsPublishModule {
def moduleDeps = Seq(`windows-jni-utils`)
}
object `windows-jni-utils-tests` extends ScalaModule with JniUtilsPublishModule {
def scalaVersion = Scala.scala213
def moduleDeps = Seq(`windows-jni-utils`)
object test extends ScalaTests {
def moduleDeps = super.moduleDeps ++ Seq(
`windows-jni-utils-bootstrap`,
`windows-jni-utils-lmcoursier`,
`windows-jni-utils-coursierapi`
)
def ivyDeps = Agg(Deps.utest)
def testFramework = "utest.runner.Framework"
}
}
// compile these projects to generate or update JNI header files
object headers extends Module {
object `windows-jni-utils` extends WindowsUtils with GenerateHeaders with WithDllNameJava
object `windows-jni-utils-bootstrap` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
object `windows-jni-utils-lmcoursier` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
object `windows-jni-utils-coursierapi` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
}
implicit def millModuleBasePath: define.Ctx.BasePath =
define.Ctx.BasePath(super.millModuleBasePath.value / os.up)
}
trait WindowsUtils extends MavenModule with JniUtilsPublishVersion {
def compileIvyDeps = Agg(Deps.svm)
def javacOptions = super.javacOptions() ++ Seq(
"--release", "8"
)
}
def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) =
T.command {
val timeout = 10.minutes
val credentials = sys.env("SONATYPE_USERNAME") + ":" + sys.env("SONATYPE_PASSWORD")
val pgpPassword = sys.env("PGP_PASSWORD")
val data = define.Task.sequence(tasks.value)()
settings.publishSonatype(
credentials = credentials,
pgpPassword = pgpPassword,
data = data,
timeout = timeout,
log = T.ctx().log,
workspace = T.workspace,
env = T.env
)
}