diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 36e679b3e..286161bf9 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -47,9 +47,11 @@ dependencies { implementation(libs.kotlin.plugin) implementation(libs.spotless) + implementation(libs.curseForgeGradle) implementation(libs.fabric.loom) implementation(libs.forgeGradle) implementation(libs.librarian) + implementation(libs.minotaur) implementation(libs.quiltflower) implementation(libs.vanillaGradle) } diff --git a/buildSrc/src/main/kotlin/cc-tweaked.mod-publishing.gradle.kts b/buildSrc/src/main/kotlin/cc-tweaked.mod-publishing.gradle.kts new file mode 100644 index 000000000..68ea3dabb --- /dev/null +++ b/buildSrc/src/main/kotlin/cc-tweaked.mod-publishing.gradle.kts @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers +// +// SPDX-License-Identifier: MPL-2.0 + +import net.darkhax.curseforgegradle.TaskPublishCurseForge +import cc.tweaked.gradle.setProvider + +plugins { + id("net.darkhax.curseforgegradle") + id("com.modrinth.minotaur") + id("cc-tweaked.publishing") +} + +abstract class ModPublishingExtension { + abstract val output: Property + + init { + output.finalizeValueOnRead() + } +} + +val modPublishing = project.extensions.create("modPublishing", ModPublishingExtension::class.java) + +val isUnstable = project.properties["isUnstable"] == "true" +val modVersion: String by extra +val mcVersion: String by extra + +val publishCurseForge by tasks.registering(TaskPublishCurseForge::class) { + group = PublishingPlugin.PUBLISH_TASK_GROUP + description = "Upload artifacts to CurseForge" + + apiToken = findProperty("curseForgeApiKey") ?: "" + enabled = apiToken != "" + + val mainFile = upload("282001", modPublishing.output.get().archiveFile) + dependsOn(modPublishing.output) // See https://github.com/Darkhax/CurseForgeGradle/pull/7. + mainFile.changelog = + "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)." + mainFile.changelogType = "markdown" + mainFile.releaseType = if (isUnstable) "alpha" else "release" + mainFile.gameVersions.add(mcVersion) +} + +tasks.publish { dependsOn(publishCurseForge) } + +modrinth { + token.set(findProperty("modrinthApiKey") as String? ?: "") + projectId.set("gu7yAYhd") + versionNumber.set("$mcVersion-$modVersion") + versionName.set(modVersion) + versionType.set(if (isUnstable) "alpha" else "release") + uploadFile.setProvider(modPublishing.output) + gameVersions.add(mcVersion) + changelog.set("Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion).") + + syncBodyFrom.set(provider { file("doc/mod-page.md").readText() }) +} + +tasks.publish { dependsOn(tasks.modrinth) } diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt index af27c6a5a..41f97276b 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt @@ -5,6 +5,8 @@ package cc.tweaked.gradle import org.gradle.api.artifacts.dsl.DependencyHandler +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider import org.gradle.api.tasks.JavaExec import org.gradle.process.BaseExecSpec import org.gradle.process.JavaExecSpec @@ -119,3 +121,6 @@ class CloseScope : AutoCloseable { } } } + +/** Proxy method to avoid overload ambiguity. */ +fun Property.setProvider(provider: Provider) = set(provider) diff --git a/doc/mod-page.md b/doc/mod-page.md index 81a17cc54..5d9cd11bd 100644 --- a/doc/mod-page.md +++ b/doc/mod-page.md @@ -7,8 +7,6 @@ SPDX-License-Identifier: MPL-2.0 # ![CC: Tweaked](https://tweaked.cc/logo.png) CC: Tweaked is a mod for Minecraft which adds programmable computers, turtles and more to the game. A fork of the much-beloved [ComputerCraft], it continues its legacy with better performance, stability, and a wealth of new features. -**Fabric support is added by the [CC: Restitched][ccrestitched] project** - ## Testimonials > I'm not sure what that is [...] I don't know where that came from. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 88887a2cb..f1607a63e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -115,6 +115,7 @@ slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } # Build tools cctJavadoc = { module = "cc.tweaked:cct-javadoc", version.ref = "cctJavadoc" } checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" } +curseForgeGradle = { module = "net.darkhax.curseforgegradle:CurseForgeGradle", version.ref = "curseForgeGradle" } errorProne-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "errorProne-core" } errorProne-api = { module = "com.google.errorprone:error_prone_check_api", version.ref = "errorProne-core" } errorProne-core = { module = "com.google.errorprone:error_prone_core", version.ref = "errorProne-core" } @@ -124,19 +125,18 @@ fabric-loom = { module = "net.fabricmc:fabric-loom", version.ref = "fabric-loom" forgeGradle = { module = "net.minecraftforge.gradle:ForgeGradle", version.ref = "forgeGradle" } kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } librarian = { module = "org.parchmentmc:librarian", version.ref = "librarian" } +minotaur = { module = "com.modrinth.minotaur:Minotaur", version.ref = "minotaur" } nullAway = { module = "com.uber.nullaway:nullaway", version.ref = "nullAway" } quiltflower = { module = "io.github.juuxel:loom-quiltflower", version.ref = "quiltflower" } spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } vanillaGradle = { module = "org.spongepowered:vanillagradle", version.ref = "vanillaGradle" } [plugins] -curseForgeGradle = { id = "net.darkhax.curseforgegradle", version.ref = "curseForgeGradle" } forgeGradle = { id = "net.minecraftforge.gradle", version.ref = "forgeGradle" } githubRelease = { id = "com.github.breadmoirai.github-release", version.ref = "githubRelease" } ideaExt = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "ideaExt" } kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } librarian = { id = "org.parchmentmc.librarian.forgegradle", version.ref = "librarian" } -minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" } mixinGradle = { id = "org.spongepowered.mixin", version.ref = "mixinGradle" } shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } taskTree = { id = "com.dorongold.task-tree", version.ref = "taskTree" } diff --git a/projects/fabric-api/build.gradle.kts b/projects/fabric-api/build.gradle.kts index 820e70c42..4ec3ab678 100644 --- a/projects/fabric-api/build.gradle.kts +++ b/projects/fabric-api/build.gradle.kts @@ -7,8 +7,6 @@ plugins { id("cc-tweaked.publishing") } -val mcVersion: String by extra - java { withJavadocJar() } diff --git a/projects/fabric/build.gradle.kts b/projects/fabric/build.gradle.kts index 0b8279520..f9ccb352c 100644 --- a/projects/fabric/build.gradle.kts +++ b/projects/fabric/build.gradle.kts @@ -9,11 +9,10 @@ import java.util.* plugins { id("cc-tweaked.fabric") id("cc-tweaked.gametest") - id("cc-tweaked.publishing") + id("cc-tweaked.mod-publishing") } val modVersion: String by extra -val mcVersion: String by extra val allProjects = listOf(":core-api", ":core", ":fabric-api").map { evaluationDependsOn(it) } cct { @@ -231,6 +230,10 @@ tasks.register("checkClient") { dependsOn(runGametestClient, runGametestClientWithSodium, runGametestClientWithIris) } +modPublishing { + output.set(tasks.remapJar) +} + tasks.withType(GenerateModuleMetadata::class).configureEach { isEnabled = false } publishing { publications { diff --git a/projects/forge/build.gradle.kts b/projects/forge/build.gradle.kts index 991425cb0..5a5e6f3f2 100644 --- a/projects/forge/build.gradle.kts +++ b/projects/forge/build.gradle.kts @@ -3,27 +3,18 @@ // SPDX-License-Identifier: MPL-2.0 import cc.tweaked.gradle.* -import net.darkhax.curseforgegradle.TaskPublishCurseForge import net.minecraftforge.gradle.common.util.RunConfig plugins { - // Build id("cc-tweaked.forge") id("cc-tweaked.gametest") alias(libs.plugins.mixinGradle) alias(libs.plugins.shadow) - // Publishing - alias(libs.plugins.curseForgeGradle) - alias(libs.plugins.minotaur) - id("cc-tweaked.illuaminate") - id("cc-tweaked.publishing") - id("cc-tweaked") + id("cc-tweaked.mod-publishing") } -val isUnstable = project.properties["isUnstable"] == "true" val modVersion: String by extra -val mcVersion: String by extra val allProjects = listOf(":core-api", ":core", ":forge-api").map { evaluationDependsOn(it) } cct { @@ -293,39 +284,10 @@ tasks.register("checkClient") { // Upload tasks -val publishCurseForge by tasks.registering(TaskPublishCurseForge::class) { - group = PublishingPlugin.PUBLISH_TASK_GROUP - description = "Upload artifacts to CurseForge" - - apiToken = findProperty("curseForgeApiKey") ?: "" - enabled = apiToken != "" - - val mainFile = upload("282001", tasks.shadowJar.get().archiveFile) - dependsOn(tasks.shadowJar) // Ughr. - mainFile.changelog = - "Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion)." - mainFile.changelogType = "markdown" - mainFile.releaseType = if (isUnstable) "alpha" else "release" - mainFile.gameVersions.add(mcVersion) +modPublishing { + output.set(tasks.shadowJar) } -tasks.publish { dependsOn(publishCurseForge) } - -modrinth { - token.set(findProperty("modrinthApiKey") as String? ?: "") - projectId.set("gu7yAYhd") - versionNumber.set("$mcVersion-$modVersion") - versionName.set(modVersion) - versionType.set(if (isUnstable) "alpha" else "release") - uploadFile.set(tasks.shadowJar as Any) - gameVersions.add(mcVersion) - changelog.set("Release notes can be found on the [GitHub repository](https://github.com/cc-tweaked/CC-Tweaked/releases/tag/v$mcVersion-$modVersion).") - - syncBodyFrom.set(provider { file("doc/mod-page.md").readText() }) -} - -tasks.publish { dependsOn(tasks.modrinth) } - // Don't publish the slim jar for (cfg in listOf(configurations.apiElements, configurations.runtimeElements)) { cfg.configure { artifacts.removeIf { it.classifier == "slim" } }