diff --git a/build.gradle.kts b/build.gradle.kts index b063c35..fb6563d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,20 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { idea `java-library` kotlin("jvm") } -val javaVersion: String by ext -val javaMajorVersion: String by ext -val kotlinTargetJdk: String by ext +val javaVersion = extra["javaVersion"] as JavaVersion +val kotlinTargetJdk = extra["kotlinTargetJdk"] as JvmTarget java { modularity.inferModulePath.set(true) + toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersion.majorVersion)) } idea { - targetVersion = javaVersion module { inheritOutputDirs = true } @@ -27,23 +28,29 @@ repositories { sourceSets { main { dependencies { - implementation(group="org.jetbrains", name="annotations", version="20.1.0") + implementation("org.jetbrains:annotations:20.1.0") implementation(project(":pswgcommon")) - api(group="me.joshlarson", name="jlcommon-network", version="1.1.2") - implementation(group="me.joshlarson", name="websocket", version="0.9.6") + api("me.joshlarson:jlcommon-network:1.1.2") + implementation("me.joshlarson:websocket:0.9.6") } } test { dependencies { testImplementation(kotlin("stdlib")) - testImplementation(group="junit", name="junit", version="4.12") + testImplementation("junit:junit:4.12") } } } tasks.withType().configureEach { - kotlinOptions { - jvmTarget = kotlinTargetJdk + compilerOptions { + jvmTarget.set(kotlinTargetJdk) } - destinationDirectory.set(File(destinationDirectory.get().asFile.path.replace("kotlin", "java"))) +} + +// Make Kotlin classes visible while javac compiles the JPMS module descriptor. +tasks.named("compileJava") { + options.compilerArgumentProviders.add(CommandLineArgumentProvider { + listOf("--patch-module", "com.projectswg.forwarder=${sourceSets.main.get().output.asPath}") + }) }