Skip to content

Commit 2ed23c9

Browse files
committed
chore: java-module-info plugin config
1 parent f6be64b commit 2ed23c9

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

build.gradle.kts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.jetbrains.dokka.gradle.*
55
import org.jetbrains.kotlin.config.*
66
import org.jetbrains.kotlin.gradle.tasks.*
77
import java.net.*
8-
import java.nio.file.Path
8+
import java.nio.file.*
99

1010
plugins {
1111
idea
@@ -33,6 +33,7 @@ plugins {
3333
gradleRelease
3434
binCompatValidator
3535
dependencyAnalyze
36+
extraJavaModuleInfo
3637
plugins.common
3738
// kotlinxAtomicfu
3839
}
@@ -61,6 +62,7 @@ application {
6162
"-Djdk.attach.allowAttachSelf=true",
6263
"-Djdk.tracePinnedThreads=full",
6364
"-Djava.security.egd=file:/dev/./urandom",
65+
"-Djdk.includeInExceptions=hostInfo,jar",
6466
"-XX:+UnlockDiagnosticVMOptions",
6567
"-XX:+ShowHiddenFrames",
6668
"-ea",
@@ -99,7 +101,8 @@ java {
99101
languageVersion.set(JavaLanguageVersion.of(javaVersion))
100102
vendor.set(JvmVendorSpec.ORACLE)
101103
}
102-
// modularity.inferModulePath.set(false)
104+
105+
// modularity.inferModulePath.set(true)
103106
}
104107

105108
// Add the generated templates to source set.
@@ -226,14 +229,24 @@ release {
226229
revertOnFail = true
227230
}
228231

229-
// For dependencies that are needed for development only.
230-
val devOnly: Configuration by configurations.creating {
231-
// extendsFrom(configurations["testImplementation"])
232-
// or val testImplementation by configurations
232+
// Create ShadowJar specific runtimeClasspath.
233+
val shadowRuntime: Configuration by configurations.creating {
234+
val runtimeClasspath by configurations.getting
235+
extendsFrom(runtimeClasspath)
236+
attributes { attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) }
233237
}
234238

239+
// For dependencies that are needed for development only.
240+
val devOnly: Configuration by configurations.creating
241+
242+
// Deactivate java-module-info plugin for all configs
235243
configurations {
236-
devOnly
244+
// runtimeClasspath...etc
245+
all {
246+
attributes {
247+
attribute(Attribute.of("javaModule", Boolean::class.javaObjectType), false)
248+
}
249+
}
237250
}
238251

239252
// After the project configure
@@ -298,7 +311,7 @@ tasks {
298311

299312
// Jte templates
300313
generateJte {
301-
sourceDirectory = Path.of("src", "main", "templates", "jte")
314+
sourceDirectory = Paths.get(project.projectDir.absolutePath, "src", "main", "templates", "jte")
302315
contentType = ContentType.Plain
303316
}
304317

@@ -311,6 +324,7 @@ tasks {
311324
useJUnitPlatform()
312325
jvmArgs("--enable-preview")
313326
classpath += devOnly
327+
314328
testLogging {
315329
events = setOf(
316330
TestLogEvent.PASSED,
@@ -386,6 +400,7 @@ tasks {
386400
// Don't create modular shadow jar
387401
exclude("module-info.class")
388402
// relocate("okio", "shaded.okio")
403+
configurations = listOf(shadowRuntime)
389404
doLast {
390405
val fatJar = archiveFile.get().asFile
391406
println("FatJar: ${fatJar.path} (${fatJar.length().toDouble() / (1_000 * 1_000)} MB)")

0 commit comments

Comments
 (0)