Files
envelope/launcher/build.gradle
2022-07-01 04:36:02 +08:00

71 lines
1.7 KiB
Groovy

import java.util.jar.Attributes
plugins {
id 'net.woggioni.gradle.multi-release-jar'
}
ext {
setProperty('jpms.module.name', 'net.woggioni.envelope')
}
configurations {
embedded {
visible = false
canBeConsumed = false
}
compileOnly.extendsFrom(embedded)
tar {
visible = true
canBeConsumed = true
transitive = false
}
}
dependencies {
embedded project(path: ":common", configuration: 'archives')
embedded project(path: ":loader", configuration: 'archives')
}
java {
modularity.inferModulePath = true
}
jar {
manifest {
attributes([
(Attributes.Name.SPECIFICATION_TITLE) : "envelope-launcher",
(Attributes.Name.SEALED) : true
].collectEntries {
[it.key.toString(), it.value.toString()]
})
}
}
Provider<Tar> tarTaskProvider = tasks.register("tar", Tar) {
archiveFileName = "${project.name}.tar"
from(project.tasks.named(JavaPlugin.JAR_TASK_NAME)
.flatMap(Jar.&getArchiveFile)
.map(RegularFile.&getAsFile)
.map(project.&zipTree))
from(configurations.named('embedded').map {
it.collect {
it.isDirectory() ? it : zipTree(it)
}
}) {
exclude("**/module-info.class")
exclude("META-INF/MANIFEST.MF")
}
}
artifacts {
tar tarTaskProvider
}
compileJava11 {
options.javaModuleMainClass = 'net.woggioni.envelope.Launcher'
options.compilerArgs += ['--add-reads', 'net.woggioni.envelope=ALL-UNNAMED']
}
multiReleaseJar {
patchModule('net.woggioni.envelope', project(':common').jar.archiveFile
.map(RegularFile.&getAsFile).map(File.&toString))
}