Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a variants from configuration #137

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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