Skip to content

Commit

Permalink
Update Gradle, Spotless, Workflow actions (#155)
Browse files Browse the repository at this point in the history
* Update to gradle 8.5

* Fix crash when publishing to maven

* Update spotless

* Update workflows

* Ignore warnings for now

* Fix deprecation warnings

* Clean up a bit

* Switch back CI to eclipse temurin

* Configure spotless to apply our coding style more easily
  • Loading branch information
thecatcore committed Feb 11, 2024
1 parent 07a538d commit 81f9833
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 38 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ on: [push, pull_request]

jobs:
build:
strategy:
matrix:
java: [ 17-jdk, 21-jdk ]
runs-on: ubuntu-22.04
container:
image: eclipse-temurin:17-jdk
image: eclipse-temurin:${{ matrix.java }}
options: --user root
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew check build --stacktrace --parallel
- run: ./gradlew publishToMavenLocal --stacktrace
- uses: gradle/wrapper-validation-action@v2
- run: ./gradlew check build publishToMavenLocal --stacktrace -Porg.gradle.parallel.threads=4 --warning-mode=fail
- uses: Juuxel/publish-checkstyle-report@v1
if: ${{ failure() }}
with:
reports: |
**/build/reports/checkstyle/*.xml
- uses: actions/upload-artifact@v3
with:
name: Artifacts
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
build:
runs-on: ubuntu-22.04
container:
image: eclipse-temurin:17-jdk
image: eclipse-temurin:21-jdk
options: --user root
steps:
- run: apt update && apt install git -y && git --version
- run: git config --global --add safe.directory /__w/fabric/fabric
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v2
- run: ./gradlew checkVersion build publish publishMods --stacktrace
env:
MAVEN_PUBLISH_CREDENTIALS: ${{ secrets.MAVEN_PUBLISH_CREDENTIALS }}
Expand Down
33 changes: 23 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id "maven-publish"
id "fabric-loom" version "1.3.9" apply false
id "legacy-looming" version "1.3.75" 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.1"
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}
Expand Down Expand Up @@ -52,14 +52,22 @@ static def getProjectSimpleName(Project project) {
return projectFullName.split("_")[0]
}

def getProjectMavenName(project) {
if (!(project instanceof Project)) project = rootProject.findProject("$project.name".toString())
def getProjectMavenName(projectLike) {
Project project
if (!(projectLike instanceof Project)) {
if (projectLike instanceof BasePluginExtension) {
project = rootProject.findProject("${projectLike.archivesName.get()}".toString())
} else {
project = rootProject.findProject("$projectLike.name".toString())
}
}
else project = projectLike

def simpleName = getProjectSimpleName(project)

if (project.name.endsWith("_common")) {
if (project.hasProperty("artifactSuffix")) {
simpleName += project.artifactSuffix
simpleName += project["artifactSuffix"]
} else {
simpleName += "-common"
}
Expand Down Expand Up @@ -244,14 +252,13 @@ allprojects {
setupRepositories(repositories)
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

tasks.withType(JavaCompile).configureEach {
it.options.release = 8
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// Must be added before the split source sets are setup.
withSourcesJar()
}
Expand Down Expand Up @@ -331,6 +338,10 @@ allprojects {
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
removeUnusedImports()
importOrder("java", "javax", "", "net.minecraft", "net.fabricmc", "net.legacyfabric")
indentWithTabs()
trimTrailingWhitespace()
}
}

Expand All @@ -347,14 +358,14 @@ allprojects {
if (hasTest) {
task testmodJar(type: Jar) {
from sourceSets.testmod.output
destinationDirectory = new File(project.buildDir, "devlibs")
destinationDirectory = project.layout.buildDirectory.dir("devlibs")
archiveClassifier.set("testmod")
}
}

[jar, sourcesJar].each {
it.from(rootProject.file("LICENSE")) {
rename { "${it}-${project.archivesBaseName}" }
rename { "${it}-${project.base.archivesName}" }
}
}

Expand Down Expand Up @@ -419,7 +430,9 @@ task javadocJar(type: Jar) {
build.dependsOn javadocJar

subprojects {
base.setArchivesName(getProjectMavenName(it))
base {
archivesName = getProjectMavenName(it)
}

dependencies {
testmodImplementation sourceSets.main.output
Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

<module name="ImportOrder">
<property name="groups" value="java,javax,*,net.minecraft,net.fabricmc,net.legacyfabric"/>
<property name="ordered" value="false"/><!-- the plugin orders alphabetically without considering separators.. -->
<property name="ordered" value="true"/><!-- the plugin orders alphabetically without considering separators.. -->
<property name="separated" value="true"/>
<property name="option" value="top"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ 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
# shellcheck disable=SC2039,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
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package net.legacyfabric.fabric.impl.client.registry.sync;

import net.legacyfabric.fabric.impl.registry.RegistryHelperImpl;
import net.legacyfabric.fabric.impl.registry.sync.remappers.RegistryRemapper;
import net.legacyfabric.fabric.impl.registry.sync.RegistryRemapperAccess;
import net.legacyfabric.fabric.impl.registry.sync.remappers.RegistryRemapper;
import net.legacyfabric.fabric.impl.registry.sync.remappers.RegistryRemapperRegistryRemapper;

public class ClientRegistryRemapper implements RegistryRemapperAccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
import net.legacyfabric.fabric.api.util.VersionUtils;
import net.legacyfabric.fabric.impl.client.registry.sync.ClientRegistryRemapper;
import net.legacyfabric.fabric.impl.registry.sync.ServerRegistryRemapper;
import net.legacyfabric.fabric.impl.registry.sync.remappers.RegistryRemapper;
import net.legacyfabric.fabric.impl.registry.sync.compat.IdListCompat;
import net.legacyfabric.fabric.impl.registry.sync.compat.ItemCompat;
import net.legacyfabric.fabric.impl.registry.sync.compat.RegistriesGetter;
import net.legacyfabric.fabric.impl.registry.sync.compat.SimpleRegistryCompat;
import net.legacyfabric.fabric.impl.registry.sync.remappers.RegistryRemapper;
import net.legacyfabric.fabric.impl.registry.util.ArrayAndMapBasedRegistry;

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ public <T extends LivingEntity> void register(FeatureRenderer<T> featureRenderer
this.delegate.apply(featureRenderer);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,3 @@ static <V> V getSubmittedFuture(Future<V> future) throws IOException {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package net.legacyfabric.fabric.mixin.resource.loader.client;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import java.io.StringReader;
import java.io.IOException;
import java.io.InputStream;

import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
Expand All @@ -43,8 +43,8 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.resource.language.TranslationStorage;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;

import net.legacyfabric.fabric.api.util.VersionUtils;
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def loadProject(String path) {
if (it.isDirectory()) {
include("${path}_$it.name")

project(":${path}_$it.name").setProjectDir(it)
project(":${path}_$it.name").projectDir = it
}
}
}
Expand Down

0 comments on commit 81f9833

Please sign in to comment.