Skip to content

Commit

Permalink
Update to loom 1.3 and use Mod Publish Plugin (#3158)
Browse files Browse the repository at this point in the history
* Update to loom 1.3

* Fix more 1.3 deprecations

* Opps

* Move to mod publish plugin

* Revert some changes

* Fix some more Gradle deprecations

* Fix names

* Remove extra stuff

* Cleanup
  • Loading branch information
modmuss50 authored Aug 2, 2023
1 parent d9acd82 commit f4b7e42
Show file tree
Hide file tree
Showing 58 changed files with 62 additions and 150 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew check build publishToMavenLocal --stacktrace --warning-mode=fail -Porg.gradle.parallel.threads=4
- run: ./gradlew check build publishToMavenLocal publishMods --stacktrace --warning-mode=fail -Porg.gradle.parallel.threads=4
- uses: Juuxel/publish-checkstyle-report@v1
if: ${{ failure() }}
with:
Expand All @@ -28,10 +28,14 @@ jobs:
with:
name: Artifacts
path: ./*/build/libs/
- uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/publishMods/
- uses: actions/upload-artifact@v3
with:
name: Maven Local
path: /root/.m2/repository
path: /root/.m2/repository/net/fabricmc/

client_test:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
context: changelog
workflow_id: release.yml
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew checkVersion build publish curseforge github modrinth --stacktrace -Porg.gradle.parallel.threads=4
- run: ./gradlew checkVersion build publish publishMods --stacktrace -Porg.gradle.parallel.threads=4
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
Expand Down
140 changes: 47 additions & 93 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.135'
}
}

plugins {
id "java-library"
id "eclipse"
id "idea"
id "maven-publish"
id 'jacoco'
id "fabric-loom" version "1.2.7" apply false
id "com.diffplug.spotless" version "6.18.0"
id "fabric-loom" version "1.3.8" apply false
id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "3.1.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "2.4.3"
id "me.modmuss50.remotesign" version "0.4.0" apply false
id "me.modmuss50.mod-publish-plugin" version "0.2.0"
}

def ENV = System.getenv()
def signingEnabled = ENV.SIGNING_SERVER

version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
logger.lifecycle("Building Fabric: " + version)
Expand Down Expand Up @@ -123,16 +115,16 @@ allprojects {
enabled = false
}

if (signingEnabled) {
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY

afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
useDummyForTesting = ENV.SIGNING_SERVER == null

afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
}

Expand Down Expand Up @@ -266,18 +258,16 @@ allprojects {

checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = "10.11.0"
toolVersion = "10.12.1"
}

tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

if (signingEnabled) {
remoteSign {
sign remapJar
}
remoteSign {
sign remapJar
}

// Run this task after updating minecraft to regenerate any required resources
Expand Down Expand Up @@ -411,7 +401,7 @@ loom {
}
autoTestServer {
inherit testmodServer
name "Auto Test Server"
name "Auto Test Server"
vmArg "-Dfabric.autoTest"
}
autoTestClient {
Expand Down Expand Up @@ -595,6 +585,10 @@ subprojects {
return
}

base {
archivesName = project.name
}

dependencies {
testmodImplementation sourceSets.main.output

Expand All @@ -619,8 +613,8 @@ subprojects {
pom {
addPomMetadataInformation(project, pom)
}
artifact(signingEnabled ? signRemapJar.output : remapJar) {
builtBy(signingEnabled ? signRemapJar : remapJar)
artifact(signRemapJar.output) {
builtBy(signRemapJar)
}

artifact(remapSourcesJar) {
Expand All @@ -639,8 +633,8 @@ subprojects {
publishing {
publications {
mavenJava(MavenPublication) {
artifact(signingEnabled ? signRemapJar.output : remapJar) {
builtBy(signingEnabled ? signRemapJar : remapJar)
artifact(signRemapJar.output) {
builtBy(signRemapJar)
}

artifact(sourcesJar) {
Expand Down Expand Up @@ -727,77 +721,39 @@ remapJar {
}

// Include the signed or none signed jar from the sub project.
nestedJars.from project("${it.path}").tasks.getByName(signingEnabled ? "signRemapJar" : "remapJar")
nestedJars.from project("${it.path}").tasks.getByName("signRemapJar")
}
}
}

curseforge {
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}

project {
id = "306612"
changelog = ENV.CHANGELOG ?: "No changelog provided"
releaseType = project.prerelease == "true" ? "beta" : "release"
addGameVersion "1.20.1"
addGameVersion "Fabric"
publishMods {
file = signRemapJar.output
changelog = providers.environmentVariable("CHANGELOG").getOrElse("No changelog provided")
type = project.prerelease == "true" ? BETA : STABLE
displayName = "[${project.minecraft_version}] Fabric API $project.version"
modLoaders.add("fabric")
dryRun = providers.environmentVariable("GITHUB_TOKEN").getOrNull() == null

mainArtifact(signingEnabled ? signRemapJar.output : remapJar) {
displayName = "[$project.minecraft_version] Fabric API $project.version"
}

afterEvaluate {
uploadTask.dependsOn("remapJar")
}
curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
projectId = "306612"
minecraftVersions.add(project.curseforge_minecraft_version)
}

options {
forgeGradleIntegration = false
modrinth {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "P7dR8mSH"
minecraftVersions.add(project.minecraft_version)
}
}

if (signingEnabled) {
project.tasks.curseforge.dependsOn signRemapJar
project.tasks.modrinth.dependsOn signRemapJar
build.dependsOn signRemapJar
}

import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub

import java.util.stream.Collectors

tasks.register('github') {
dependsOn(signingEnabled ? signRemapJar : remapJar)
onlyIf {
ENV.GITHUB_TOKEN
}

doLast {
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
def repository = github.getRepository(ENV.GITHUB_REPOSITORY)

def releaseBuilder = new GHReleaseBuilder(repository, version as String)
releaseBuilder.name("[$project.minecraft_version] Fabric API $project.version")
releaseBuilder.body(ENV.CHANGELOG ?: "No changelog provided")
releaseBuilder.commitish(getBranch())
releaseBuilder.prerelease(project.prerelease == "true")

def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(signingEnabled ? signRemapJar.output.get().getAsFile() : remapJar.archiveFile.get().getAsFile(), "application/java-archive");
github {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("FabricMC/dryrun")
commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun")
}
}

modrinth {
projectId = "fabric-api"
versionName = "[$project.minecraft_version] Fabric API $project.version"
versionType = project.prerelease == "true" ? "beta" : "release"
changelog = ENV.CHANGELOG ?: "No changelog provided"
assemble.dependsOn signRemapJar

uploadFile = signingEnabled ? signRemapJar.output : remapJar
}
import java.util.stream.Collectors

// A task to ensure that the version being released has not already been released.
tasks.register('checkVersion') {
Expand All @@ -811,7 +767,5 @@ tasks.register('checkVersion') {
}
}

github.mustRunAfter checkVersion
project.tasks.modrinth.mustRunAfter checkVersion
tasks.publishMods.dependsOn checkVersion
publish.mustRunAfter checkVersion
project.tasks.curseforge.mustRunAfter checkVersion
1 change: 0 additions & 1 deletion deprecated/fabric-command-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-command-api-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-commands-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-commands-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-containers-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-containers-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-events-lifecycle-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-events-lifecycle-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-keybindings-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-keybindings-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-loot-tables-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-loot-tables-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-models-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-models-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-networking-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-networking-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-renderer-registries-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-renderer-registries-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion deprecated/fabric-rendering-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-rendering-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion fabric-api-base/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-api-base"
version = getSubprojectVersion(project)

testDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion fabric-api-lookup-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-api-lookup-api-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down
1 change: 0 additions & 1 deletion fabric-biome-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-biome-api-v1"
version = getSubprojectVersion(project)

loom {
Expand Down
1 change: 0 additions & 1 deletion fabric-block-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
archivesBaseName = "fabric-block-api-v1"
version = getSubprojectVersion(project)
1 change: 0 additions & 1 deletion fabric-blockrenderlayer-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-blockrenderlayer-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
1 change: 0 additions & 1 deletion fabric-client-tags-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-client-tags-api-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
Expand Down
1 change: 0 additions & 1 deletion fabric-command-api-v2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-command-api-v2"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
Expand Down
1 change: 0 additions & 1 deletion fabric-content-registries-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-content-registries-v0"
version = getSubprojectVersion(project)

loom {
Expand Down
1 change: 0 additions & 1 deletion fabric-convention-tags-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-convention-tags-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
Expand Down
1 change: 0 additions & 1 deletion fabric-crash-report-info-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
archivesBaseName = "fabric-crash-report-info-v1"
version = getSubprojectVersion(project)
3 changes: 1 addition & 2 deletions fabric-data-generation-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-data-generation-api-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, [
Expand Down Expand Up @@ -54,7 +53,7 @@ loom {
test.dependsOn runDatagen

task datapackZip(type: Zip, dependsOn: runDatagen) {
archiveFileName = "${archivesBaseName}-${project.version}-test-datapack.zip"
archiveFileName = "${base.archivesName.get()}-${project.version}-test-datapack.zip"
destinationDirectory = layout.buildDirectory.dir('libs')

from file("src/testmod/generated")
Expand Down
1 change: 0 additions & 1 deletion fabric-dimensions-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-dimensions-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
Expand Down
1 change: 0 additions & 1 deletion fabric-entity-events-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-entity-events-v1"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
Expand Down
1 change: 0 additions & 1 deletion fabric-events-interaction-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-events-interaction-v0"
version = getSubprojectVersion(project)

moduleDependencies(project, ['fabric-api-base'])
1 change: 0 additions & 1 deletion fabric-game-rule-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-game-rule-api-v1"
version = getSubprojectVersion(project)

loom {
Expand Down
1 change: 0 additions & 1 deletion fabric-gametest-api-v1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
archivesBaseName = "fabric-gametest-api-v1"
version = getSubprojectVersion(project)

loom {
Expand Down
Loading

0 comments on commit f4b7e42

Please sign in to comment.