diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/PaperweightCore.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/PaperweightCore.kt index e6d07585a..c56916224 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/PaperweightCore.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/PaperweightCore.kt @@ -143,26 +143,20 @@ class PaperweightCore : Plugin { */ target.afterEvaluate { - println("SoftSpoon: ${ext.softSpoon.get()}") - target.repositories { - if (!ext.softSpoon.get()) { - maven(ext.remapRepo) { - name = REMAPPER_REPO_NAME - content { onlyForConfigurations(REMAPPER_CONFIG) } - } - } else { - maven(ext.macheRepo) { - name = MACHE_REPO_NAME - content { onlyForConfigurations(MACHE_CONFIG) } - } + /* TODO + maven(ext.remapRepo) { + name = REMAPPER_REPO_NAME + content { onlyForConfigurations(REMAPPER_CONFIG) } + } + */ + maven(ext.macheRepo) { + name = MACHE_REPO_NAME + content { onlyForConfigurations(MACHE_CONFIG) } } } - if (ext.softSpoon.get()) { - softSpoonTasks.afterEvaluate() - return@afterEvaluate - } + softSpoonTasks.afterEvaluate() /* // Setup the server jar diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperExtension.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperExtension.kt index 22ddeeba5..04bed9916 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperExtension.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperExtension.kt @@ -32,14 +32,7 @@ import org.gradle.kotlin.dsl.* open class PaperExtension(objects: ObjectFactory, layout: ProjectLayout) { - @Suppress("MemberVisibilityCanBePrivate") - val baseTargetDir: DirectoryProperty = objects.dirWithDefault(layout, ".") - val spigotApiPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/api") - val spigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server") - val remappedSpigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server-remapped") - val unmappedSpigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server-unmapped") - val paperApiDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "paper-api") - val paperServerDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "paper-server") + val paperServerDir: DirectoryProperty = objects.directoryProperty().convention(layout.projectDirectory) val rejectsDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/rejected") val sourcePatchDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/sources") val resourcePatchDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/resources") @@ -47,15 +40,10 @@ open class PaperExtension(objects: ObjectFactory, layout: ProjectLayout) { @Suppress("MemberVisibilityCanBePrivate") val buildDataDir: DirectoryProperty = objects.dirWithDefault(layout, "../build-data") - val additionalSpigotClassMappings: RegularFileProperty = objects.fileProperty() val devImports: RegularFileProperty = objects.fileFrom(buildDataDir, "dev-imports.txt") val additionalAts: RegularFileProperty = objects.fileFrom(buildDataDir, "paper.at") val reobfMappingsPatch: RegularFileProperty = objects.fileProperty() val mappingsPatch: RegularFileProperty = objects.fileProperty() - val craftBukkitPatchPatchesDir: DirectoryProperty = objects.directoryProperty() - val spigotServerPatchPatchesDir: DirectoryProperty = objects.directoryProperty() - val spigotApiPatchPatchesDir: DirectoryProperty = objects.directoryProperty() - val reobfPackagesToFix: ListProperty = objects.listProperty() } diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperweightCoreExtension.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperweightCoreExtension.kt index 35af2691b..62d5f152d 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperweightCoreExtension.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/extension/PaperweightCoreExtension.kt @@ -22,7 +22,6 @@ package io.papermc.paperweight.core.extension -import io.papermc.paperweight.util.* import io.papermc.paperweight.util.constants.* import java.util.Locale import org.gradle.api.Action @@ -36,23 +35,13 @@ import org.gradle.kotlin.dsl.* open class PaperweightCoreExtension(project: Project, objects: ObjectFactory, layout: ProjectLayout) { - val softSpoon: Property = objects.property().convention(false) - - @Suppress("MemberVisibilityCanBePrivate") - val workDir: DirectoryProperty = objects.dirWithDefault(layout, "work") - val minecraftVersion: Property = objects.property() val minecraftManifestUrl: Property = objects.property().convention(MC_MANIFEST_URL) - val serverProject: Property = objects.property() val mainClass: Property = objects.property().convention("org.bukkit.craftbukkit.Main") val bundlerJarName: Property = objects.property().convention(project.name.lowercase(Locale.ENGLISH)) - val mcDevSourceDir: DirectoryProperty = objects.directoryProperty().convention(serverProject.map { it.layout.cacheDir(MC_DEV_SOURCES_DIR) }) - - val paramMappingsRepo: Property = objects.property() - val decompileRepo: Property = objects.property() - val remapRepo: Property = objects.property() + val remapRepo: Property = objects.property().convention(PAPER_MAVEN_REPO_URL) val macheRepo: Property = objects.property().convention(PAPER_MAVEN_REPO_URL) val macheOldPath: DirectoryProperty = objects.directoryProperty() diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/GeneralTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/GeneralTasks.kt index 0f2370b5d..fc46ed9c7 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/GeneralTasks.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/GeneralTasks.kt @@ -26,6 +26,8 @@ import io.papermc.paperweight.core.ext import io.papermc.paperweight.core.extension.PaperweightCoreExtension import io.papermc.paperweight.tasks.* import io.papermc.paperweight.util.* +import io.papermc.paperweight.util.constants.* +import java.nio.file.Path import org.gradle.api.Project import org.gradle.api.tasks.TaskContainer import org.gradle.kotlin.dsl.* @@ -34,6 +36,7 @@ import org.gradle.kotlin.dsl.* open class GeneralTasks( project: Project, tasks: TaskContainer = project.tasks, + cache: Path = project.layout.cache, extension: PaperweightCoreExtension = project.ext, ) : InitialTasks(project) { @@ -42,12 +45,12 @@ open class GeneralTasks( includes.set(extension.vanillaJarIncludes) } - val collectAtsFromPatches by tasks.registering { - patchDir.set(extension.paper.spigotServerPatchDir) - } + val generateMappings by tasks.registering { + vanillaJar.set(filterVanillaJar.flatMap { it.outputJar }) + libraries.from(extractFromBundler.map { it.serverLibraryJars.asFileTree }) + + vanillaMappings.set(downloadMappings.flatMap { it.outputFile }) - val mergePaperAts by tasks.registering { - firstFile.set(extension.paper.additionalAts.fileExists(project)) - secondFile.set(collectAtsFromPatches.flatMap { it.outputFile }) + outputMappings.set(cache.resolve(MOJANG_YARN_MAPPINGS)) } } diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt index 2d5be21d5..3aac713d2 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt @@ -25,8 +25,9 @@ package io.papermc.paperweight.core.taskcontainers import io.papermc.paperweight.core.ext import io.papermc.paperweight.restamp.RestampVersion import io.papermc.paperweight.tasks.* -import io.papermc.paperweight.tasks.mache.* +import io.papermc.paperweight.tasks.mache.DecompileJar import io.papermc.paperweight.tasks.mache.RemapJar +import io.papermc.paperweight.tasks.mache.SetupVanilla import io.papermc.paperweight.tasks.softspoon.ApplyFeaturePatches import io.papermc.paperweight.tasks.softspoon.ApplyFilePatches import io.papermc.paperweight.tasks.softspoon.ApplyFilePatchesFuzzy @@ -42,6 +43,7 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.plugins.JavaPlugin import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.provider.Property import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.TaskContainer import org.gradle.kotlin.dsl.* @@ -52,7 +54,7 @@ open class SoftSpoonTasks( tasks: TaskContainer = project.tasks ) { - lateinit var mache: MacheMeta + private val mache: Property = project.objects.property() val macheCodebook by project.configurations.registering { isTransitive = false @@ -69,8 +71,9 @@ open class SoftSpoonTasks( val macheConstants by project.configurations.registering { isTransitive = false } + val macheMinecraftLibraries by project.configurations.registering + val mappedJarOutgoing = project.configurations.consumable("mappedJarOutgoing") // For source generator modules val macheMinecraft by project.configurations.registering - val macheMinecraftExtended by project.configurations.registering val restampConfig = project.configurations.register(RESTAMP_CONFIG) { defaultDependencies { add(project.dependencies.create("io.papermc.restamp:restamp:${RestampVersion.VERSION}")) @@ -82,9 +85,9 @@ open class SoftSpoonTasks( serverJar.set(allTasks.extractFromBundler.flatMap { it.serverJar }) serverMappings.set(allTasks.downloadMappings.flatMap { it.outputFile }) - remapperArgs.set(mache.remapperArgs) + remapperArgs.set(mache.map { it.remapperArgs }) codebookClasspath.from(macheCodebook) - minecraftClasspath.from(macheMinecraft) + minecraftClasspath.from(macheMinecraftLibraries) remapperClasspath.from(macheRemapper) paramMappings.from(macheParamMappings) constants.from(macheConstants) @@ -95,9 +98,9 @@ open class SoftSpoonTasks( val macheDecompileJar by tasks.registering(DecompileJar::class) { group = "mache" inputJar.set(macheRemapJar.flatMap { it.outputJar }) - decompilerArgs.set(mache.decompilerArgs) + decompilerArgs.set(mache.map { it.decompilerArgs }) - minecraftClasspath.from(macheMinecraft) + minecraftClasspath.from(macheMinecraftLibraries) decompiler.from(macheDecompiler) outputJar.set(layout.cache.resolve(FINAL_DECOMPILE_JAR)) @@ -122,7 +125,7 @@ open class SoftSpoonTasks( macheOld.set(project.ext.macheOldPath) machePatches.set(layout.cache.resolve(PATCHES_FOLDER)) ats.set(mergeCollectedAts.flatMap { it.outputFile }) - minecraftClasspath.from(macheMinecraft) + minecraftClasspath.from(macheMinecraftLibraries) libraries.from( allTasks.downloadPaperLibrariesSources.flatMap { it.outputDir }, @@ -203,7 +206,7 @@ open class SoftSpoonTasks( group = "softspoon" description = "Rebuilds patches to the vanilla sources" - minecraftClasspath.from(macheMinecraftExtended) + minecraftClasspath.from(macheMinecraft) atFile.set(project.ext.paper.additionalAts.fileExists(project)) atFileOut.set(project.ext.paper.additionalAts.fileExists(project)) @@ -269,11 +272,18 @@ open class SoftSpoonTasks( fun afterEvaluate() { // load mache - mache = this.project.configurations.named(MACHE_CONFIG).get().singleFile.toPath().openZip().use { zip -> - return@use gson.fromJson(zip.getPath("/mache.json").readLines().joinToString("\n")) - } + mache.set( + project.configurations.getByName(MACHE_CONFIG).singleFile.toPath().openZip().use { zip -> + gson.fromJson(zip.getPath("/mache.json").readLines().joinToString("\n")) + } + ) + val mache = mache.get() println("Loaded mache ${mache.macheVersion} for minecraft ${mache.minecraftVersion}") + mappedJarOutgoing { + outgoing.artifact(macheRemapJar) + } + // setup repos this.project.repositories { println("setup repos for ${project.name}") @@ -290,11 +300,11 @@ open class SoftSpoonTasks( } // setup mc deps - macheMinecraft { + macheMinecraftLibraries { extendsFrom(project.configurations.getByName(MACHE_CONFIG)) } - macheMinecraftExtended { - extendsFrom(macheMinecraft.get()) + macheMinecraft { + extendsFrom(macheMinecraftLibraries.get()) withDependencies { add( project.dependencies.create( @@ -325,7 +335,7 @@ open class SoftSpoonTasks( // impl extends minecraft project.configurations.named(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME) { - extendsFrom(macheMinecraft.get()) + extendsFrom(macheMinecraftLibraries.get()) } // add vanilla source set diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SpigotTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SpigotTasks.kt index 88f986331..8059d5319 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SpigotTasks.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SpigotTasks.kt @@ -39,7 +39,7 @@ open class SpigotTasks( tasks: TaskContainer = project.tasks, cache: Path = project.layout.cache, extension: PaperweightCoreExtension = project.ext, -) : VanillaTasks(project) { +) : GeneralTasks(project) { val cloneSpigotBuildData by tasks.registering { url.set("https://hub.spigotmc.org/stash/scm/spigot/builddata.git") @@ -57,8 +57,6 @@ open class SpigotTasks( val generateSpigotMappings by tasks.registering { classMappings.set(unpackSpigotBuildData.flatMap { it.classMappings }) - // todo hypo update breaks generate mappings, hardcode for now - // sourceMappings.set(Path.of("D:\\IntellijProjects\\PaperClean\\.gradle\\caches\\paperweight\\mappings\\official-mojang+yarn.tiny")) sourceMappings.set(generateMappings.flatMap { it.outputMappings }) outputMappings.set(cache.resolve(SPIGOT_MOJANG_YARN_MAPPINGS)) @@ -75,8 +73,6 @@ open class SpigotTasks( mcVersion.set(extension.minecraftVersion) - // workDirName.set(extension.craftBukkit.buildDataInfo.asFile.map { it.parentFile.parentFile.name }) - specialSourceJar.set(unpackSpigotBuildData.flatMap { it.specialSourceJar }) specialSource2Jar.set(unpackSpigotBuildData.flatMap { it.specialSource2Jar }) diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/VanillaTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/VanillaTasks.kt deleted file mode 100644 index bb195ec73..000000000 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/VanillaTasks.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * paperweight is a Gradle plugin for the PaperMC project. - * - * Copyright (c) 2023 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.core.taskcontainers - -import io.papermc.paperweight.tasks.* -import io.papermc.paperweight.util.* -import io.papermc.paperweight.util.constants.* -import java.nio.file.Path -import org.gradle.api.Project -import org.gradle.api.tasks.TaskContainer -import org.gradle.kotlin.dsl.* - -@Suppress("MemberVisibilityCanBePrivate") -open class VanillaTasks( - project: Project, - tasks: TaskContainer = project.tasks, - cache: Path = project.layout.cache, -) : GeneralTasks(project) { - - val generateMappings by tasks.registering { - vanillaJar.set(filterVanillaJar.flatMap { it.outputJar }) - libraries.from(extractFromBundler.map { it.serverLibraryJars.asFileTree }) - - vanillaMappings.set(downloadMappings.flatMap { it.outputFile }) - // paramMappings.fileProvider(project.configurations.named(PARAM_MAPPINGS_CONFIG).map { it.singleFile }) - - outputMappings.set(cache.resolve(MOJANG_YARN_MAPPINGS)) - } - - val remapJar by tasks.registering { - inputJar.set(filterVanillaJar.flatMap { it.outputJar }) - // TODO fix hypo for v1 stuff - // mappingsFile.set(generateMappings.flatMap { it.outputMappings }) - mappingsFile.set(Path.of("D:\\IntellijProjects\\PaperClean\\.gradle\\caches\\paperweight\\mappings\\official-mojang+yarn.tiny")) - fromNamespace.set(OBF_NAMESPACE) - toNamespace.set(DEOBF_NAMESPACE) - remapper.from(project.configurations.named(REMAPPER_CONFIG)) - remapperArgs.set(TinyRemapper.minecraftRemapArgs) - } - - val fixJar by tasks.registering { - inputJar.set(remapJar.flatMap { it.outputJar }) - vanillaJar.set(extractFromBundler.flatMap { it.serverJar }) - } -} diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/PaperweightSourceGeneratorHelper.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/PaperweightSourceGeneratorHelper.kt index ff3e78712..c01388f81 100644 --- a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/PaperweightSourceGeneratorHelper.kt +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/PaperweightSourceGeneratorHelper.kt @@ -25,8 +25,6 @@ package io.papermc.paperweight import io.papermc.paperweight.extension.PaperweightSourceGeneratorExt import io.papermc.paperweight.tasks.* import io.papermc.paperweight.util.* -import io.papermc.paperweight.util.constants.* -import kotlin.io.path.* import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* @@ -35,32 +33,17 @@ abstract class PaperweightSourceGeneratorHelper : Plugin { override fun apply(target: Project) = with(target) { val ext = extensions.create("paperweight", PaperweightSourceGeneratorExt::class) + val minecraftJar by configurations.registering + val applyAts by tasks.registering { - inputJar.set(rootProject.tasks.named("fixJar").flatMap { it.outputJar }) + inputJar.set(layout.file(minecraftJar.flatMap { it.elements }.map { it.single().asFile })) atFile.set(ext.atFile) } - val copyResources by tasks.registering { - inputJar.set(applyAts.flatMap { it.outputJar }) - vanillaJar.set(rootProject.tasks.named("extractFromBundler").flatMap { it.serverJar }) - } - - val libsFile = rootProject.layout.cache.resolve(SERVER_LIBRARIES_TXT) - val vanilla = configurations.register("vanillaServer") { - withDependencies { - dependencies { - val libs = libsFile.convertToPathOrNull() - if (libs != null && libs.exists()) { - libs.forEachLine { line -> - add(create(line)) - } - } - } - } - } + val vanilla = configurations.register("vanillaServer") dependencies { - vanilla.name(files(copyResources.flatMap { it.outputJar })) + vanilla.name(files(applyAts.flatMap { it.outputJar })) } afterEvaluate { diff --git a/paperweight-lib/src/main/resources/META-INF/gradle-plugins/io.papermc.paperweight.source-generator.properties b/paperweight-lib/src/main/resources/META-INF/gradle-plugins/io.papermc.paperweight.source-generator.properties new file mode 100644 index 000000000..0a629d9ee --- /dev/null +++ b/paperweight-lib/src/main/resources/META-INF/gradle-plugins/io.papermc.paperweight.source-generator.properties @@ -0,0 +1 @@ +implementation-class=io.papermc.paperweight.PaperweightSourceGeneratorHelper