Skip to content

Commit

Permalink
Update to Architectury Loom 1.2 + Gradle 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jun 3, 2023
1 parent 3121be7 commit bdba073
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 24 deletions.
26 changes: 18 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.text.SimpleDateFormat
import java.util.Date

import com.diffplug.gradle.spotless.SpotlessExtension
import com.fasterxml.jackson.core.type.TypeReference
Expand All @@ -12,12 +11,13 @@ import net.fabricmc.loom.task.RemapJarTask
import dev.architectury.plugin.ArchitectPluginExtension

import me.shedaniel.unifiedpublishing.UnifiedPublishingExtension
import java.util.*

plugins {
java
`maven-publish`
id("architectury-plugin") version "3.4-SNAPSHOT" apply false
id("dev.architectury.loom") version "1.0-SNAPSHOT" apply false
id("dev.architectury.loom") version "1.2-SNAPSHOT" apply false
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("me.shedaniel.unified-publishing") version "0.1.+" apply false
id("com.diffplug.spotless") version "6.4.1" apply false
Expand All @@ -31,6 +31,16 @@ val platforms by extra {
property("enabledPlatforms").toString().split(',')
}

fun capitalise(str: String): String {
return str.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
} else {
it.toString()
}
}
}

tasks {
val collectJars by registering(Copy::class) {
val tasks = subprojects.filter { it.name in platforms }.map { it.tasks.named("remapJar") }
Expand Down Expand Up @@ -173,7 +183,7 @@ subprojects {

publishing {
publications {
create<MavenPublication>("maven${project.name.capitalize()}") {
create<MavenPublication>("maven${capitalise(project.name)}") {
groupId = project.group.toString()
artifactId = project.base.archivesName.get()
version = project.version.toString()
Expand Down Expand Up @@ -205,12 +215,12 @@ for (platform in platforms) {
configurations {
compileClasspath.get().extendsFrom(common)
runtimeClasspath.get().extendsFrom(common)
getByName("development${platform.capitalize()}").extendsFrom(common)
getByName("development${capitalise(platform)}").extendsFrom(common)
}

dependencies {
common(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
shadowCommon(project(path = ":common", configuration = "transformProduction${platform.capitalize()}")) { isTransitive = false }
shadowCommon(project(path = ":common", configuration = "transformProduction${capitalise(platform)}")) { isTransitive = false }
}

tasks {
Expand Down Expand Up @@ -265,10 +275,10 @@ for (platform in platforms) {
var releaseChannel = "release"
var changes = System.getenv("CHANGELOG") ?: "No changelog provided?"

if (modVersion.toLowerCase().contains("alpha")) {
if (modVersion.lowercase().contains("alpha")) {
releaseChannel = "alpha"
changes = "THIS IS AN ALPHA RELEASE, MAKE A BACKUP BEFORE INSTALLING AND FREQUENTLY WHILE PLAYING, AND PLEASE REPORT ANY ISSUE YOU MAY FIND ON THE ISSUE TRACKER.\n\n$changes"
} else if (modVersion.toLowerCase().contains("beta")) {
} else if (modVersion.lowercase().contains("beta")) {
releaseChannel = "beta"
changes = "This is a beta release. It is expected to be mostly stable, but in any case please report any issue you may find.\n\n$changes"
}
Expand All @@ -277,7 +287,7 @@ for (platform in platforms) {
changelog.set(changes)
displayName.set(String.format("%s (%s %s)",
modVersion.substring(0, modVersion.lastIndexOf("-")),
platform.capitalize(),
capitalise(platform),
minecraftVersion))

mainPublication(project.tasks.getByName("remapJar"))
Expand Down
7 changes: 5 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ architectury {
dependencies {
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")

val fabricProject = project(":fabric").dependencyProject

modCompileOnly("net.fabricmc.fabric-api:fabric-api:${fabricProject.property("fabricApiVersion")}+${property("minecraftVersion")}")
modCompileOnly("appeng:appliedenergistics2-fabric:${property("ae2Version")}")
modCompileOnly("curse.maven:ae2wtlib-459929:${project(":fabric").dependencyProject.property("ae2wtFile")}")
modCompileOnly("curse.maven:applied-botanics-addon-610632:${project(":fabric").dependencyProject.property("appbotFile")}")
modCompileOnly("curse.maven:ae2wtlib-459929:${fabricProject.property("ae2wtFile")}")
modCompileOnly("curse.maven:applied-botanics-addon-610632:${fabricProject.property("appbotFile")}")
}
15 changes: 9 additions & 6 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
val generated = file("src/generated/resources")

loom {
val modId: String by project

runs {
create("data") {
data()
programArgs("--all", "--mod", modId)
programArgs("--output", generated.absolutePath)
programArgs("--existing", file("src/main/resources").absolutePath)
}
}

forge {
val modId: String by project

dataGen {
mod(modId)
}

convertAccessWideners.set(true)
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)

Expand Down Expand Up @@ -101,6 +101,7 @@ dependencies {
sourceSets {
main {
resources {
srcDir(generated)
exclude("**/.cache")
}
}
Expand All @@ -114,4 +115,6 @@ tasks.processResources {
"ae2VersionEnd" to ae2Version.substringBefore('.').toInt() + 1
))
}

duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down

0 comments on commit bdba073

Please sign in to comment.