From a8cb8a90c8fb57cfa0310c1eeda2801349e55024 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:57:05 -0700 Subject: [PATCH] Fix javax annotations missing from compile classpath --- .../io/papermc/sculptor/shared/MacheExtension.kt | 9 +++++++++ .../sculptor/version/ConfigureVersionProject.kt | 13 ++++++++++++- .../io/papermc/sculptor/version/SculptorVersion.kt | 11 ++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sculptor-shared/src/main/kotlin/io/papermc/sculptor/shared/MacheExtension.kt b/sculptor-shared/src/main/kotlin/io/papermc/sculptor/shared/MacheExtension.kt index bf82ce7..4d54b0b 100644 --- a/sculptor-shared/src/main/kotlin/io/papermc/sculptor/shared/MacheExtension.kt +++ b/sculptor-shared/src/main/kotlin/io/papermc/sculptor/shared/MacheExtension.kt @@ -37,6 +37,15 @@ abstract class MacheExtension(objects: ObjectFactory) { */ val remapperArgs: ListProperty = objects.listProperty() + /** + * Extra compile-time dependencies to inject to Minecraft. + * + * Mojang only provides the flattened runtime classpath. + */ + val extraCompileDependencies: ListProperty = objects.listProperty().convention( + listOf("com.google.code.findbugs:jsr305:3.0.2") + ) + val runs: PolymorphicDomainObjectContainer = objects.polymorphicDomainObjectContainer(MinecraftRunConfiguration::class) fun runServer(op: Action) { diff --git a/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/ConfigureVersionProject.kt b/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/ConfigureVersionProject.kt index 75cffcf..db2109e 100644 --- a/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/ConfigureVersionProject.kt +++ b/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/ConfigureVersionProject.kt @@ -76,7 +76,18 @@ object ConfigureVersionProject { "minecraft"(library) { isTransitive = false } - "serverDependencies"(library) { + "serverRuntimeDependencies"(library) { + isTransitive = false + } + "serverCompileDependencies"(library) { + isTransitive = false + } + } + for (library in mache.extraCompileDependencies.get()) { + "minecraft"(library) { + isTransitive = false + } + "serverCompileDependencies"(library) { isTransitive = false } } diff --git a/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/SculptorVersion.kt b/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/SculptorVersion.kt index efef688..22fe8e4 100644 --- a/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/SculptorVersion.kt +++ b/sculptor-version/src/main/kotlin/io/papermc/sculptor/version/SculptorVersion.kt @@ -352,17 +352,18 @@ abstract class SculptorVersion : Plugin { macheComponent.addVariantsFromConfiguration(macheZip.get()) {} if (mache.minecraftJarType.get() == MinecraftJarType.SERVER) { - val serverDependencies = target.configurations.register("serverDependencies") - val serverCompile = target.configurations.consumable("serverCompileDependencies") { - extendsFrom(serverDependencies.get()) + val serverCompileDependencies = target.configurations.register("serverCompileDependencies") + val serverRuntimeDependencies = target.configurations.register("serverRuntimeDependencies") + val serverCompile = target.configurations.consumable("serverCompileClasspath") { + extendsFrom(serverCompileDependencies.get()) attributes { attribute(Usage.USAGE_ATTRIBUTE, target.objects.named(Usage.JAVA_API)) attribute(MacheOutput.ATTRIBUTE, target.objects.named(MacheOutput.SERVER_DEPENDENCIES)) } } macheComponent.addVariantsFromConfiguration(serverCompile.get()) {} - val serverRuntime = target.configurations.consumable("serverRuntimeDependencies") { - extendsFrom(serverDependencies.get()) + val serverRuntime = target.configurations.consumable("serverRuntimeClasspath") { + extendsFrom(serverRuntimeDependencies.get()) attributes { attribute(Usage.USAGE_ATTRIBUTE, target.objects.named(Usage.JAVA_RUNTIME)) attribute(MacheOutput.ATTRIBUTE, target.objects.named(MacheOutput.SERVER_DEPENDENCIES))