Update to loom 1.3 and use Mod Publish Plugin (#3158)

* 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
This commit is contained in:
modmuss 2023-08-02 18:51:21 +01:00 committed by GitHub
parent d9acd820fc
commit f4b7e42468
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 62 additions and 150 deletions

View file

@ -14,7 +14,7 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1 - 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 - uses: Juuxel/publish-checkstyle-report@v1
if: ${{ failure() }} if: ${{ failure() }}
with: with:
@ -28,10 +28,14 @@ jobs:
with: with:
name: Artifacts name: Artifacts
path: ./*/build/libs/ path: ./*/build/libs/
- uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/publishMods/
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: Maven Local name: Maven Local
path: /root/.m2/repository path: /root/.m2/repository/net/fabricmc/
client_test: client_test:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04

View file

@ -22,7 +22,7 @@ jobs:
context: changelog context: changelog
workflow_id: release.yml workflow_id: release.yml
- uses: gradle/wrapper-validation-action@v1 - 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: env:
MAVEN_URL: ${{ secrets.MAVEN_URL }} MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}

View file

@ -1,25 +1,17 @@
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.135'
}
}
plugins { plugins {
id "java-library" id "java-library"
id "eclipse" id "eclipse"
id "idea" id "idea"
id "maven-publish" id "maven-publish"
id 'jacoco' id 'jacoco'
id "fabric-loom" version "1.2.7" apply false id "fabric-loom" version "1.3.8" apply false
id "com.diffplug.spotless" version "6.18.0" id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "3.1.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.remotesign" version "0.4.0" apply false
id "me.modmuss50.mod-publish-plugin" version "0.2.0"
} }
def ENV = System.getenv() def ENV = System.getenv()
def signingEnabled = ENV.SIGNING_SERVER
version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch() version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
logger.lifecycle("Building Fabric: " + version) logger.lifecycle("Building Fabric: " + version)
@ -123,16 +115,16 @@ allprojects {
enabled = false enabled = false
} }
if (signingEnabled) { remoteSign {
remoteSign { requestUrl = ENV.SIGNING_SERVER
requestUrl = ENV.SIGNING_SERVER pgpAuthKey = ENV.SIGNING_PGP_KEY
pgpAuthKey = ENV.SIGNING_PGP_KEY jarAuthKey = ENV.SIGNING_JAR_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY
afterEvaluate { useDummyForTesting = ENV.SIGNING_SERVER == null
// PGP sign all maven publications.
sign publishing.publications.mavenJava afterEvaluate {
} // PGP sign all maven publications.
sign publishing.publications.mavenJava
} }
} }
@ -266,7 +258,7 @@ allprojects {
checkstyle { checkstyle {
configFile = rootProject.file("checkstyle.xml") configFile = rootProject.file("checkstyle.xml")
toolVersion = "10.11.0" toolVersion = "10.12.1"
} }
tasks.withType(AbstractArchiveTask).configureEach { tasks.withType(AbstractArchiveTask).configureEach {
@ -274,10 +266,8 @@ allprojects {
reproducibleFileOrder = true reproducibleFileOrder = true
} }
if (signingEnabled) { remoteSign {
remoteSign { sign remapJar
sign remapJar
}
} }
// Run this task after updating minecraft to regenerate any required resources // Run this task after updating minecraft to regenerate any required resources
@ -411,7 +401,7 @@ loom {
} }
autoTestServer { autoTestServer {
inherit testmodServer inherit testmodServer
name "Auto Test Server" name "Auto Test Server"
vmArg "-Dfabric.autoTest" vmArg "-Dfabric.autoTest"
} }
autoTestClient { autoTestClient {
@ -595,6 +585,10 @@ subprojects {
return return
} }
base {
archivesName = project.name
}
dependencies { dependencies {
testmodImplementation sourceSets.main.output testmodImplementation sourceSets.main.output
@ -619,8 +613,8 @@ subprojects {
pom { pom {
addPomMetadataInformation(project, pom) addPomMetadataInformation(project, pom)
} }
artifact(signingEnabled ? signRemapJar.output : remapJar) { artifact(signRemapJar.output) {
builtBy(signingEnabled ? signRemapJar : remapJar) builtBy(signRemapJar)
} }
artifact(remapSourcesJar) { artifact(remapSourcesJar) {
@ -639,8 +633,8 @@ subprojects {
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
artifact(signingEnabled ? signRemapJar.output : remapJar) { artifact(signRemapJar.output) {
builtBy(signingEnabled ? signRemapJar : remapJar) builtBy(signRemapJar)
} }
artifact(sourcesJar) { artifact(sourcesJar) {
@ -727,78 +721,40 @@ remapJar {
} }
// Include the signed or none signed jar from the sub project. // 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 { publishMods {
if (ENV.CURSEFORGE_API_KEY) { file = signRemapJar.output
apiKey = ENV.CURSEFORGE_API_KEY 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
curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
projectId = "306612"
minecraftVersions.add(project.curseforge_minecraft_version)
} }
modrinth {
project { accessToken = providers.environmentVariable("MODRINTH_TOKEN")
id = "306612" projectId = "P7dR8mSH"
changelog = ENV.CHANGELOG ?: "No changelog provided" minecraftVersions.add(project.minecraft_version)
releaseType = project.prerelease == "true" ? "beta" : "release"
addGameVersion "1.20.1"
addGameVersion "Fabric"
mainArtifact(signingEnabled ? signRemapJar.output : remapJar) {
displayName = "[$project.minecraft_version] Fabric API $project.version"
}
afterEvaluate {
uploadTask.dependsOn("remapJar")
}
} }
github {
options { accessToken = providers.environmentVariable("GITHUB_TOKEN")
forgeGradleIntegration = false repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("FabricMC/dryrun")
commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun")
} }
} }
if (signingEnabled) { assemble.dependsOn signRemapJar
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 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");
}
}
modrinth {
projectId = "fabric-api"
versionName = "[$project.minecraft_version] Fabric API $project.version"
versionType = project.prerelease == "true" ? "beta" : "release"
changelog = ENV.CHANGELOG ?: "No changelog provided"
uploadFile = signingEnabled ? signRemapJar.output : remapJar
}
// A task to ensure that the version being released has not already been released. // A task to ensure that the version being released has not already been released.
tasks.register('checkVersion') { tasks.register('checkVersion') {
doFirst { doFirst {
@ -811,7 +767,5 @@ tasks.register('checkVersion') {
} }
} }
github.mustRunAfter checkVersion tasks.publishMods.dependsOn checkVersion
project.tasks.modrinth.mustRunAfter checkVersion
publish.mustRunAfter checkVersion publish.mustRunAfter checkVersion
project.tasks.curseforge.mustRunAfter checkVersion

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-command-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-commands-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-containers-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-events-lifecycle-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-keybindings-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-loot-tables-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-models-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-networking-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-renderer-registries-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-rendering-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-api-base"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
testDependencies(project, [ testDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-api-lookup-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-biome-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,2 +1 @@
archivesBaseName = "fabric-block-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-blockrenderlayer-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-client-tags-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-command-api-v2"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-content-registries-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-convention-tags-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,2 +1 @@
archivesBaseName = "fabric-crash-report-info-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-data-generation-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [
@ -54,7 +53,7 @@ loom {
test.dependsOn runDatagen test.dependsOn runDatagen
task datapackZip(type: Zip, 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') destinationDirectory = layout.buildDirectory.dir('libs')
from file("src/testmod/generated") from file("src/testmod/generated")

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-dimensions-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-entity-events-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-events-interaction-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-game-rule-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-gametest-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-item-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-item-group-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-key-binding-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
testDependencies(project, [ testDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-lifecycle-events-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-loot-api-v2"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-message-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-mining-level-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-model-loading-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-networking-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-object-builder-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-particles-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-recipe-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-registry-sync-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-renderer-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-renderer-indigo"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-rendering-data-attachment-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-rendering-fluids-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-rendering-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-resource-conditions-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
testDependencies(project, [':fabric-gametest-api-v1']) testDependencies(project, [':fabric-gametest-api-v1'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-resource-loader-v0"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-screen-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, ['fabric-api-base']) moduleDependencies(project, ['fabric-api-base'])

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-screen-handler-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-sound-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
testDependencies(project, [ testDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-transfer-api-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
moduleDependencies(project, [ moduleDependencies(project, [

View file

@ -1,4 +1,3 @@
archivesBaseName = "fabric-transitive-access-wideners-v1"
version = getSubprojectVersion(project) version = getSubprojectVersion(project)
loom { loom {

View file

@ -9,6 +9,7 @@ loader_version=0.14.21
installer_version=0.11.1 installer_version=0.11.1
prerelease=false prerelease=false
curseforge_minecraft_version=1.20.1
# Do not manually update, use the bumpversions task: # Do not manually update, use the bumpversions task:
fabric-api-base-version=0.4.30 fabric-api-base-version=0.4.30

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

5
gradlew vendored
View file

@ -130,10 +130,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.