Move dev bundle configuration to extension

This commit is contained in:
Jason Penilla 2022-09-22 22:11:09 -07:00
parent c5fe6cff3b
commit 86bd144725
6 changed files with 80 additions and 17 deletions

View file

@ -162,7 +162,8 @@ class PaperweightCore : Plugin<Project> {
tasks.extractFromBundler.map { it.serverLibrariesList.path },
tasks.downloadServerJar.map { it.outputJar.path },
tasks.mergeAdditionalAts.map { it.outputFile.path },
tasks.extractFromBundler.map { it.versionJson.path }.convertToFileProvider(layout, providers)
tasks.extractFromBundler.map { it.versionJson.path }.convertToFileProvider(layout, providers),
ext.devBundle,
) {
vanillaJarIncludes.set(ext.vanillaJarIncludes)
reobfMappingsFile.set(tasks.patchReobfMappings.flatMap { it.outputMappings })

View file

@ -22,6 +22,7 @@
package io.papermc.paperweight.core.extension
import io.papermc.paperweight.extension.DevBundleExtension
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.*
import java.util.Locale
@ -74,4 +75,12 @@ open class PaperweightCoreExtension(project: Project, objects: ObjectFactory, la
fun paper(action: Action<in PaperExtension>) {
action.execute(paper)
}
@Suppress("MemberVisibilityCanBePrivate")
val devBundle = DevBundleExtension(project, objects)
@Suppress("unused")
fun devBundle(action: Action<in DevBundleExtension>) {
action.execute(devBundle)
}
}

View file

@ -0,0 +1,56 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2021 Kyle Wood (DenWav)
* Contributors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 only, no later versions.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package io.papermc.paperweight.extension
import io.papermc.paperweight.tasks.*
import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.kotlin.dsl.*
@Suppress("unused")
class DevBundleExtension(
private val rootProject: Project,
objects: ObjectFactory
) {
val libraryRepositories: ListProperty<String> = objects.listProperty()
/**
* Registers a project dependency to have its publication included in the dev bundle, and it's coordinates
* depended on by the server artifact. Paper registers `paper-api` and `paper-mojangapi` using this method.
*/
fun registerProjectPublication(project: Project, publicationName: String, coordinates: String) {
rootProject.registerProjectPublicationForDevBundle(project, publicationName, coordinates)
}
private fun Project.registerProjectPublicationForDevBundle(
project: Project,
publicationName: String,
coordinates: String,
) {
val archive = project.archivePublication(publicationName)
tasks.named<GenerateDevBundle>("generateDevelopmentBundle") {
projectArchivedPublication(project, archive, coordinates)
}
}
}

View file

@ -22,6 +22,7 @@
package io.papermc.paperweight.taskcontainers
import io.papermc.paperweight.extension.DevBundleExtension
import io.papermc.paperweight.extension.RelocationExtension
import io.papermc.paperweight.taskcontainers.BundlerJarTasks.Companion.registerVersionArtifact
import io.papermc.paperweight.tasks.*
@ -72,6 +73,7 @@ class DevBundleTasks(
vanillaBundlerJarFile: Provider<Path?>,
accessTransformFile: Provider<Path?>,
versionJsonFile: Provider<RegularFile>,
devBundleExtension: DevBundleExtension,
devBundleConfiguration: GenerateDevBundle.() -> Unit
) {
serverBundlerForDevBundle {
@ -110,6 +112,8 @@ class DevBundleTasks(
decompiledJar.pathProvider(decompileJar)
atFile.pathProvider(accessTransformFile)
libraryRepositories.addAll(devBundleExtension.libraryRepositories)
devBundleConfiguration(this)
}
}
@ -121,18 +125,3 @@ class DevBundleTasks(
}
}
}
/**
* Registers a project dependency to have its publication included in the dev bundle, and it's coordinates
* depended on by the server artifact. Paper registers `paper-api` and `paper-mojangapi` using this method.
*/
fun Project.registerProjectPublicationForDevBundle(
project: Project,
publicationName: String,
coordinates: String,
) {
val archive = project.archivePublication(publicationName)
tasks.named<GenerateDevBundle>("generateDevelopmentBundle") {
projectArchivedPublication(project, archive, coordinates)
}
}

View file

@ -179,7 +179,8 @@ class PaperweightPatcher : Plugin<Project> {
upstreamData.map { it.serverLibrariesList },
upstreamData.map { it.vanillaJar },
upstreamData.map { it.accessTransform },
upstreamData.map { it.bundlerVersionJson }.convertToFileProvider(layout, providers)
upstreamData.map { it.bundlerVersionJson }.convertToFileProvider(layout, providers),
patcher.devBundle,
) {
vanillaJarIncludes.set(upstreamData.map { it.vanillaIncludes })
reobfMappingsFile.set(patchReobfMappings.flatMap { it.outputMappings })

View file

@ -22,6 +22,7 @@
package io.papermc.paperweight.patcher
import io.papermc.paperweight.extension.DevBundleExtension
import io.papermc.paperweight.patcher.upstream.DefaultPaperRepoPatcherUpstream
import io.papermc.paperweight.patcher.upstream.DefaultPatcherUpstream
import io.papermc.paperweight.patcher.upstream.DefaultRepoPatcherUpstream
@ -65,6 +66,8 @@ open class PaperweightPatcherExtension(project: Project, private val objects: Ob
val upstreams: ExtensiblePolymorphicDomainObjectContainer<PatcherUpstream> = objects.polymorphicDomainObjectContainer(PatcherUpstream::class)
val devBundle = DevBundleExtension(project, objects)
/**
* The directory upstreams should be checked out in. Paperweight will use the directory specified in the
* following order, whichever is set first:
@ -101,4 +104,8 @@ open class PaperweightPatcherExtension(project: Project, private val objects: Ob
}
}
}
fun devBundle(action: Action<in DevBundleExtension>) {
action.execute(devBundle)
}
}