Build: Add modularJar helper
This commit is contained in:
@@ -176,6 +176,28 @@ fun Project.javadocJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
|
|||||||
return javadocTask
|
return javadocTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Project.modularJar(body: Jar.() -> Unit): TaskProvider<Jar> {
|
||||||
|
val modularJar = configurations.maybeCreate("modularJar").apply {
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val modularJarTask = getOrCreateTask<Jar>("modularJar") {
|
||||||
|
archiveClassifier.set("modular")
|
||||||
|
|
||||||
|
body()
|
||||||
|
}
|
||||||
|
|
||||||
|
addArtifact("modularJar", modularJarTask)
|
||||||
|
addArtifact("archives", modularJarTask)
|
||||||
|
|
||||||
|
val javaComponent = components.findByName("java") as AdhocComponentWithVariants
|
||||||
|
javaComponent.addVariantsFromConfiguration(modularJar) { }
|
||||||
|
|
||||||
|
return modularJarTask
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun Project.standardPublicJars() {
|
fun Project.standardPublicJars() {
|
||||||
runtimeJar()
|
runtimeJar()
|
||||||
|
|||||||
@@ -39,12 +39,6 @@ embedded.isTransitive = false
|
|||||||
configurations.getByName("compileOnly").extendsFrom(embedded)
|
configurations.getByName("compileOnly").extendsFrom(embedded)
|
||||||
val mainJar by configurations.creating
|
val mainJar by configurations.creating
|
||||||
|
|
||||||
val modularJar by configurations.creating {
|
|
||||||
attributes {
|
|
||||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(kotlinStdlib())
|
compile(kotlinStdlib())
|
||||||
|
|
||||||
@@ -220,9 +214,10 @@ val result by task<Jar> {
|
|||||||
callGroovy("manifestAttributes", manifest, project, "Main", true)
|
callGroovy("manifestAttributes", manifest, project, "Main", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val modularJarTask by task<Jar> {
|
javadocJar()
|
||||||
|
|
||||||
|
modularJar {
|
||||||
dependsOn(intermediate)
|
dependsOn(intermediate)
|
||||||
archiveClassifier.set("modular")
|
|
||||||
from {
|
from {
|
||||||
zipTree(intermediate.get().singleOutputFile())
|
zipTree(intermediate.get().singleOutputFile())
|
||||||
}
|
}
|
||||||
@@ -244,12 +239,4 @@ artifacts {
|
|||||||
builtBy(result)
|
builtBy(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add("archives", modularJarTask)
|
|
||||||
add(modularJar.name, modularJarTask)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val javaComponent = components.findByName("java") as AdhocComponentWithVariants
|
|
||||||
javaComponent.addVariantsFromConfiguration(modularJar) { }
|
|
||||||
|
|
||||||
javadocJar()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user