Skip to content

Commit

Permalink
Adds a variants from configuration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yannicklamprecht committed Feb 15, 2022
1 parent c1bd340 commit 0e576c9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions paperweight-userdev/src/main/kotlin/PaperweightUser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,6 +159,19 @@ abstract class PaperweightUser : Plugin<Project> {
outputJar.convention(archivesName.flatMap { layout.buildDirectory.file("libs/$it-${project.version}.jar") })
}

if (tasks.findByName("publishToMavenLocal") != null) {
fun addReobfTo(target: NamedDomainObjectProvider<Configuration>) {
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) }
Expand Down

0 comments on commit 0e576c9

Please sign in to comment.