Compare commits

...

1 commit

Author SHA1 Message Date
MiniDigger
210a8346a2 initial try to add a importmcdev task 2021-06-14 19:39:23 +02:00
2 changed files with 76 additions and 0 deletions

View file

@ -126,4 +126,18 @@ open class AllTasks(
description = "Rebuilds patches to api and server"
dependsOn(rebuildApiPatches, rebuildServerPatches)
}
@Suppress("unused")
val importMcDev by tasks.registering<ImportMcDev> {
group = "paper"
description = "Imports files from vanilla into the project"
patchDir.set(extension.paper.spigotServerPatchDir)
sourceMcDevJar.set(decompileJar.flatMap { it.outputJar })
mcLibrariesDir.set(downloadMcLibraries.flatMap { it.sourcesOutputDir })
libraryImports.set(extension.paper.libraryClassImports)
mcdevImports.set(extension.paper.mcdevClassImports.flatMap { project.provider { if (it.path.exists()) it else null } })
paperServerDir.set(extension.paper.paperServerDir)
}
}

View file

@ -0,0 +1,62 @@
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2021 Kyle Wood (DemonWav)
* 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.tasks
import io.papermc.paperweight.util.McDev
import io.papermc.paperweight.util.path
import io.papermc.paperweight.util.pathOrNull
import kotlin.io.path.listDirectoryEntries
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
abstract class ImportMcDev : DefaultTask() {
@get:InputDirectory
abstract val patchDir: DirectoryProperty
@get:InputFile
abstract val sourceMcDevJar: RegularFileProperty
@get:InputDirectory
abstract val mcLibrariesDir: DirectoryProperty
@get:Optional
@get:InputFile
abstract val libraryImports: RegularFileProperty
@get:Optional
@get:InputFile
abstract val mcdevImports: RegularFileProperty
@get:OutputDirectory
abstract val paperServerDir: DirectoryProperty
@TaskAction
fun run() {
val patches = patchDir.path.listDirectoryEntries("*.patch")
val sourceDir = paperServerDir.path.resolve("src/main/java")
McDev.importMcDev(patches, sourceMcDevJar.path, libraryImports.pathOrNull, mcLibrariesDir.path, mcdevImports.pathOrNull, sourceDir)
}
}