From 0e576c9bb4c3af9a5bad366f2835e3450cca7c07 Mon Sep 17 00:00:00 2001 From: Yannick Lamprecht Date: Wed, 16 Feb 2022 00:21:02 +0100 Subject: [PATCH] Adds a variants from configuration When maven publish plugin is present on userdev projects a normal publish results into a wrong module file in maven repository. This commit adds the missing reobfuscated jars to this module file. --- .../src/main/kotlin/PaperweightUser.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/paperweight-userdev/src/main/kotlin/PaperweightUser.kt b/paperweight-userdev/src/main/kotlin/PaperweightUser.kt index d889cc42..1b6b7000 100644 --- a/paperweight-userdev/src/main/kotlin/PaperweightUser.kt +++ b/paperweight-userdev/src/main/kotlin/PaperweightUser.kt @@ -32,12 +32,15 @@ import io.papermc.paperweight.userdev.internal.setup.util.genSources import io.papermc.paperweight.util.* import io.papermc.paperweight.util.constants.* import javax.inject.Inject +import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration import org.gradle.api.attributes.Bundling import org.gradle.api.attributes.Category import org.gradle.api.attributes.LibraryElements import org.gradle.api.attributes.Usage +import org.gradle.api.component.AdhocComponentWithVariants import org.gradle.api.plugins.BasePluginExtension import org.gradle.api.plugins.JavaPlugin import org.gradle.api.provider.Provider @@ -156,6 +159,19 @@ abstract class PaperweightUser : Plugin { outputJar.convention(archivesName.flatMap { layout.buildDirectory.file("libs/$it-${project.version}.jar") }) } + if (tasks.findByName("publishToMavenLocal") != null) { + fun addReobfTo(target: NamedDomainObjectProvider) { + target.get().let { + it.outgoing.artifact(reobfJar.get().outputJar) { + classifier = "reobf" + } + (components["java"] as AdhocComponentWithVariants).addVariantsFromConfiguration(it) {} + } + } + addReobfTo(configurations.named("apiElements")) + addReobfTo(configurations.named("runtimeElements")) + } + if (userdev.injectPaperRepository.get()) { target.repositories.maven(PAPER_MAVEN_REPO_URL) { content { onlyForConfigurations(DEV_BUNDLE_CONFIG) }