Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/config-kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ kotlin {
}
compilerOptions {
jvmTarget = JvmTarget.JVM_17
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=17")
freeCompilerArgs = listOf("-jvm-default=enable", "-Xjdk-release=17")
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ dependencies {

testing {
suites {
val test by getting(JvmTestSuite::class) {
val test = getByName<JvmTestSuite>("test") {
useKotlinTest(embeddedKotlinVersion)
dependencies {
implementation("org.junit.jupiter:junit-jupiter-engine:6.0.3")
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/config-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (noRelocate) {
}
}

val shade: Configuration by configurations.creating
val shade = configurations.create("shade")
configurations.implementation {
extendsFrom(shade)
}
Expand All @@ -41,7 +41,7 @@ fun ShadowJar.configureStandard() {
mergeServiceFiles()
}

val sourcesJar by tasks.existing(AbstractArchiveTask::class) {
val sourcesJar = tasks.named<AbstractArchiveTask>("sourcesJar") {
from(
zipTree(project(":paperweight-lib").tasks
.named("sourcesJar", AbstractArchiveTask::class)
Expand All @@ -56,13 +56,13 @@ gradlePlugin {
vcsUrl.set("https://github.com/PaperMC/paperweight")
}

val shadowJar by tasks.existing(ShadowJar::class) {
val shadowJar = tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set(null as String?)
configureStandard()

inputs.property("noRelocate", noRelocate)
if (noRelocate) {
return@existing
return@named
}

val prefix = "paper.libs"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.gradle.plugin.devel.PluginDeclaration
fun Configuration.compatibilityAttributes(objects: ObjectFactory) {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named("9.0.0"))
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named("9.5.0"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mockk = "io.mockk:mockk:1.14.9"
gradle-licenser = "net.kyori:indra-licenser-spotless:4.0.0"
gradle-spotless = "com.diffplug.spotless:spotless-plugin-gradle:8.1.0"
gradle-shadow = "com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.3.2"
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:6.4.2"
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:6.6.4"
gradle-plugin-kotlin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin" }
gradle-plugin-publish = "com.gradle.publish:plugin-publish-plugin:2.0.0"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ abstract class PaperweightSourceGeneratorHelper : Plugin<Project> {
override fun apply(target: Project) = with(target) {
val ext = extensions.create(PAPERWEIGHT_EXTENSION, PaperweightSourceGeneratorExt::class)

val minecraftJar by configurations.registering
val minecraftJar = configurations.register("minecraftJar")

val applyAts by tasks.registering<ApplyAccessTransform> {
val applyAts = tasks.register<ApplyAccessTransform>("applyAccessTransform") {
inputJar.set(layout.file(minecraftJar.flatMap { it.elements }.map { it.single().asFile }))
atFile.set(ext.atFile)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class PaperCheckstyle : Plugin<Project> {
toolVersion = LibraryVersions.CHECKSTYLE
}

val mergeCheckstyleConfigs by target.tasks.registering<MergeCheckstyleConfigs>()
val mergeCheckstyleConfigs = target.tasks.register<MergeCheckstyleConfigs>("mergeCheckstyleConfigs")

target.tasks.withType(PaperCheckstyleTask::class.java).configureEach {
rootPath.convention(layout.settingsDirectory.asFile.path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.UntrackedTask
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.Node
import org.xml.sax.InputSource

@UntrackedTask(because = "Task has already been registered internally")
abstract class MergeCheckstyleConfigs : BaseTask() {

@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val baseConfigFile: RegularFileProperty

@get:InputFile
@get:Optional
@get:PathSensitive(PathSensitivity.NONE)
abstract val overrideConfigFile: RegularFileProperty

@get:OutputFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.UntrackedTask

@UntrackedTask(because = "Tasks are run on demand via API calls")
abstract class PaperCheckstyleTask : Checkstyle() {

@get:Input
Expand All @@ -55,6 +59,7 @@ abstract class PaperCheckstyleTask : Checkstyle() {

@get:InputFile
@get:Optional
@get:PathSensitive(PathSensitivity.NONE)
abstract val configOverride: RegularFileProperty

@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ open class AllTasks(
downloadService: Provider<DownloadService> = project.download
) : InitialTasks(project) {

val downloadMcLibrariesSources by tasks.registering<DownloadMcLibraries> {
val downloadMcLibrariesSources = tasks.register<DownloadMcLibraries>("downloadMcLibrariesSources") {
mcLibrariesFile.set(extractFromBundler.flatMap { it.serverLibrariesTxt })
repositories.set(listOf(MC_LIBRARY_URL, MAVEN_CENTRAL_URL))
outputDir.set(cache.resolve(MINECRAFT_SOURCES_PATH))
Expand All @@ -54,7 +54,7 @@ open class AllTasks(
downloader.set(downloadService)
}

val downloadRuntimeClasspathSources by tasks.registering<DownloadPaperLibraries> {
val downloadRuntimeClasspathSources = tasks.register<DownloadPaperLibraries>("downloadRuntimeClasspathSources") {
paperDependencies.set(
project.configurations.named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).map { configuration ->
val view = configuration.incoming.artifactView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CoreTasks(
) : AllTasks(project) {
lateinit var paperPatchingTasks: MinecraftPatchingTasks

val macheRemapJar by tasks.registering(RunCodebook::class) {
val macheRemapJar = tasks.register<RunCodebook>("macheRemapJar") {
serverJar.set(extractFromBundler.flatMap { it.serverJar })

codebookArgs.set(mache.map { it.remapperArgs })
Expand All @@ -60,7 +60,7 @@ class CoreTasks(
outputJar.set(layout.cache.resolve(FINAL_REMAPPED_CODEBOOK_JAR))
}

val macheDecompileJar by tasks.registering(DecompileJar::class) {
val macheDecompileJar = tasks.register<DecompileJar>("macheDecompileJar") {
inputJar.set(macheRemapJar.flatMap { it.outputJar })
decompilerArgs.set(mache.map { it.decompilerArgs })

Expand All @@ -70,11 +70,11 @@ class CoreTasks(
outputJar.set(layout.cache.resolve(FINAL_DECOMPILE_JAR))
}

val collectPaperATsFromPatches by tasks.registering(CollectATsFromPatches::class) {
val collectPaperATsFromPatches = tasks.register<CollectATsFromPatches>("collectPaperATsFromPatches") {
patchDir.set(project.coreExt.paper.featurePatchDir.fileExists())
}

val mergePaperATs by tasks.registering<MergeAccessTransforms> {
val mergePaperATs = tasks.register<MergeAccessTransforms>("mergePaperATs") {
firstFile.set(project.coreExt.paper.additionalAts.fileExists())
secondFile.set(collectPaperATsFromPatches.flatMap { it.outputFile })
}
Expand All @@ -100,7 +100,7 @@ class CoreTasks(
predicate.set { Files.isRegularFile(it) && it.toString().endsWith(".java") }
}

val setupMacheSources by tasks.registering(SetupMinecraftSources::class) {
val setupMacheSources = tasks.register<SetupMinecraftSources>("setupMacheSources") {
description = "Setup Minecraft source dir (applying mache patches and paper ATs)."
configureSetupMacheSources()
libraryImports.set(importLibraryFiles.flatMap { it.outputDir })
Expand All @@ -111,31 +111,31 @@ class CoreTasks(
ats.jst.from(project.configurations.named(JST_CONFIG))
}

val extractMacheSources by tasks.registering(ExtractMinecraftSources::class) {
val extractMacheSources = tasks.register<ExtractMinecraftSources>("extractMacheSources") {
zip.set(setupMacheSources.flatMap { it.outputZip })
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("sources"))
}

val setupMacheSourcesForDevBundle by tasks.registering(SetupMinecraftSources::class) {
val setupMacheSourcesForDevBundle = tasks.register<SetupMinecraftSources>("setupMacheSourcesForDevBundle") {
description = "Setup Minecraft source dir (applying mache patches)."
configureSetupMacheSources()
outputZip.set(layout.cache.resolve(BASE_PROJECT).resolve("sources_dev_bundle.zip"))
}

val extractMacheSourcesForDevBundle by tasks.registering(ExtractMinecraftSources::class) {
val extractMacheSourcesForDevBundle = tasks.register<ExtractMinecraftSources>("extractMacheSourcesForDevBundle") {
zip.set(setupMacheSourcesForDevBundle.flatMap { it.outputZip })
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("sources_dev_bundle"))
}

val setupMacheResources by tasks.registering(SetupMinecraftSources::class) {
val setupMacheResources = tasks.register<SetupMinecraftSources>("setupMacheResources") {
description = "Setup Minecraft resources dir"

inputFile.set(extractFromBundler.flatMap { it.serverJar })
predicate.set { Files.isRegularFile(it) && !it.toString().endsWith(".class") }
outputZip.set(layout.cache.resolve(BASE_PROJECT).resolve("resources.zip"))
}

val extractMacheResources by tasks.registering(ExtractMinecraftSources::class) {
val extractMacheResources = tasks.register<ExtractMinecraftSources>("extractMacheResources") {
zip.set(setupMacheResources.flatMap { it.outputZip })
outputDir.set(layout.cache.resolve(BASE_PROJECT).resolve("resources"))
}
Expand All @@ -162,7 +162,7 @@ class CoreTasks(
}

if (!hasFork) {
val setupPaperScript by project.tasks.registering(SetupPaperScript::class) {
val setupPaperScript = project.tasks.register<SetupPaperScript>("setupPaperScript") {
group = GENERAL_TASK_GROUP
description = "Creates a util script and installs it into path"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ class DevBundleTasks(
private val coreTasks: CoreTasks,
tasks: TaskContainer = project.tasks,
) {
val serverBundlerForDevBundle by tasks.registering<CreateBundlerJar> {
val serverBundlerForDevBundle = tasks.register<CreateBundlerJar>("serverBundlerForDevBundle") {
mainClass.set(project.coreExt.mainClass)
paperclip.from(project.configurations.named(PAPERCLIP_CONFIG))
serverLibrariesList.set(coreTasks.extractFromBundler.flatMap { it.serverLibrariesList })
vanillaBundlerJar.set(coreTasks.downloadServerJar.flatMap { it.outputJar })
}

val paperclipForDevBundle by tasks.registering<CreatePaperclipJar> {
val paperclipForDevBundle = tasks.register<CreatePaperclipJar>("paperclipForDevBundle") {
bundlerJar.set(serverBundlerForDevBundle.flatMap { it.outputZip })
libraryChangesJson.set(serverBundlerForDevBundle.flatMap { it.libraryChangesJson })
originalBundlerJar.set(coreTasks.downloadServerJar.flatMap { it.outputJar })
mcVersion.set(project.coreExt.minecraftVersion)
}

val generateDevelopmentBundle by tasks.registering<GenerateDevBundle> {
val generateDevelopmentBundle = tasks.register<GenerateDevBundle>("generateDevelopmentBundle") {
group = "bundling"

devBundleFile.set(project.layout.buildDirectory.file("libs/paperweight-development-bundle-${project.version}.zip"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class InitialTasks(
downloadService: Provider<DownloadService> = project.download
) {

val downloadMcManifest by tasks.registering<DownloadTask> {
val downloadMcManifest = tasks.register<DownloadTask>("downloadMcManifest") {
url.set(project.coreExt.minecraftManifestUrl)
outputFile.set(cache.resolve(MC_MANIFEST))

Expand All @@ -54,7 +54,7 @@ open class InitialTasks(
}
private val mcManifest = downloadMcManifest.flatMap { it.outputFile }.map { gson.fromJson<MinecraftManifest>(it) }

val downloadMcVersionManifest by tasks.registering<CacheableDownloadTask> {
val downloadMcVersionManifest = tasks.register<CacheableDownloadTask>("downloadMcVersionManifest") {
url.set(
mcManifest.zip(extension.minecraftVersion) { manifest, version ->
manifest.versions.first { it.id == version }.url
Expand All @@ -71,14 +71,14 @@ open class InitialTasks(
}
private val versionManifest = downloadMcVersionManifest.flatMap { it.outputFile }.map { gson.fromJson<MinecraftVersionManifest>(it) }

val downloadServerJar by tasks.registering<DownloadServerJar> {
val downloadServerJar = tasks.register<DownloadServerJar>("downloadServerJar") {
downloadUrl.set(versionManifest.map { version -> version.serverDownload().url })
expectedHash.set(versionManifest.map { version -> version.serverDownload().hash() })

downloader.set(downloadService)
}

val extractFromBundler by tasks.registering<ExtractFromBundler> {
val extractFromBundler = tasks.register<ExtractFromBundler>("extractFromBundler") {
bundlerJar.set(downloadServerJar.flatMap { it.outputJar })

versionJson.set(cache.resolve(SERVER_VERSION_JSON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.UntrackedTask

// To make the Git repos cacheable they must be zipped, this tasks extracts them again...
@UntrackedTask(because = "Task has already been registered internally")
abstract class ExtractMinecraftSources : BaseTask() {
@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val zip: RegularFileProperty

@get:OutputDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,23 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.UntrackedTask

@UntrackedTask(because = "Tasks are run on demand via API calls")
abstract class FilterRepo : BaseTask() {
@get:InputDirectory
@get:PathSensitive(PathSensitivity.NONE)
abstract val inputDir: DirectoryProperty

@get:OutputDirectory
abstract val outputDir: DirectoryProperty

@get:InputDirectory
@get:Optional
@get:PathSensitive(PathSensitivity.NONE)
abstract val gitDir: DirectoryProperty

@get:Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.UntrackedTask

private data class LibraryImport(val libraryFileName: String, val importFilePath: String)

@UntrackedTask(because = "Task has already been registered internally")
abstract class IndexLibraryFiles : BaseTask() {

@get:InputFiles
@get:PathSensitive(PathSensitivity.NONE)
abstract val libraries: ConfigurableFileCollection

@get:OutputFile
Expand Down Expand Up @@ -95,20 +100,25 @@ abstract class IndexLibraryFiles : BaseTask() {
}
}

@UntrackedTask(because = "Task has already been registered internally")
abstract class ImportLibraryFiles : BaseTask() {

@get:InputFiles
@get:PathSensitive(PathSensitivity.NONE)
abstract val libraries: ConfigurableFileCollection

@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val libraryFileIndex: RegularFileProperty

@get:Optional
@get:InputFiles
@get:PathSensitive(PathSensitivity.NONE)
abstract val patches: ConfigurableFileCollection

@get:Optional
@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val devImports: RegularFileProperty

@get:OutputDirectory
Expand Down
Loading