forked from SteamWar/SteamWar
Extract widener definition into a widener.gradle.kts plugin
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
plugins {
|
||||
steamwar.java
|
||||
widener
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
@@ -30,45 +31,6 @@ java {
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
// ─── Collect all .accesswidener files from this plugin's resources ────────────
|
||||
val accessWidenerFiles: FileCollection = fileTree("src/") {
|
||||
include("**/*.accesswidener")
|
||||
}
|
||||
|
||||
val paperJarProvider: Provider<File> = provider {
|
||||
val dep = libs.nms.get()
|
||||
configurations["compileClasspath"].resolvedConfiguration.resolvedArtifacts.first { artifact ->
|
||||
artifact.moduleVersion.id.module.group == dep.module.group && artifact.moduleVersion.id.module.name == dep.module.name
|
||||
}.file
|
||||
}
|
||||
|
||||
// ─── Widen the Paper dev JAR so the IDE / javac see the patched access ────────
|
||||
val widenedJar by tasks.registering(JavaExec::class) {
|
||||
description = "Produces a widened copy of the Paper dev JAR for compile-time use."
|
||||
group = "widener"
|
||||
|
||||
// Re-run whenever the .accesswidener files change
|
||||
inputs.file(paperJarProvider)
|
||||
inputs.files(accessWidenerFiles)
|
||||
|
||||
val output = layout.buildDirectory.file("widened/paper-widened.jar")
|
||||
outputs.file(output)
|
||||
|
||||
classpath = project(":AccessWidener").tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar").get().outputs.files
|
||||
|
||||
mainClass.set("de.steamwar.Main")
|
||||
|
||||
doFirst {
|
||||
args = buildList {
|
||||
add(paperJarProvider.get().absolutePath)
|
||||
add(output.get().asFile.absolutePath)
|
||||
addAll(accessWidenerFiles.map { it.absolutePath })
|
||||
}
|
||||
}
|
||||
|
||||
dependsOn(":AccessWidener:shadowJar")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.classindex)
|
||||
annotationProcessor(libs.classindex)
|
||||
@@ -79,7 +41,6 @@ dependencies {
|
||||
|
||||
compileOnly(libs.paperapi)
|
||||
compileOnly(libs.nms)
|
||||
compileOnly(files(widenedJar))
|
||||
|
||||
compileOnly(libs.fawe)
|
||||
compileOnly(libs.netty)
|
||||
@@ -88,6 +49,6 @@ dependencies {
|
||||
implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
dependsOn(widenedJar)
|
||||
widener {
|
||||
fromCatalog(libs.nms)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user