-
-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathktorm.modularity.gradle.kts
37 lines (32 loc) · 1.05 KB
/
ktorm.modularity.gradle.kts
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
plugins {
id("kotlin")
}
val moditect by tasks.registering {
doLast {
// Generate a multi-release modulized jar, module descriptor position: META-INF/versions/9/module-info.class
val inputJar = tasks.jar.flatMap { it.archiveFile }.map { it.asFile.toPath() }.get()
val outputDir = file("build/moditect").apply { mkdirs() }.toPath()
val moduleInfo = file("src/main/moditect/module-info.java").readText()
val version = project.version.toString()
org.moditect.commands.AddModuleInfo(moduleInfo, null, version, inputJar, outputDir, "9", true).run()
// Replace the original jar with the modulized jar.
copy {
from(outputDir.resolve(inputJar.fileName))
into(inputJar.parent)
}
}
}
tasks {
moditect {
dependsOn(jar)
}
jar {
finalizedBy(moditect)
}
}
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
// Let kotlin compiler know the module descriptor.
sourceSets.main {
kotlin.srcDir("src/main/moditect")
}
}