Skip to content

Commit

Permalink
Merge branch 'GTNewHorizons:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Taskeren authored Jan 6, 2025
2 parents aa0cd19 + 5d3be77 commit e6e7e71
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
with:
fetch-depth: 0

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Set up JDK 8 and 17
uses: actions/setup-java@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish-javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
with:
fetch-depth: 0

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- uses: actions/setup-java@v3
with:
java-version: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
with:
fetch-depth: 0

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/validate-gradle-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Validates the integrity of the Gradle Wrapper
name: Validate Gradle Wrapper

on:
push:
branches:
- master
paths:
- 'gradle/**'
pull_request:
paths:
- 'gradle/**'

concurrency:
group: gradle-wrapper-validation-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
Validation:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ dependencies {
annotationProcessor("net.java.dev.jna:jna-platform:5.13.0")

// All these plugins will be present in the classpath of the project using our plugin, but not activated until explicitly applied
api(pluginDep("com.gtnewhorizons.retrofuturagradle","1.4.1"))
api(pluginDep("com.gtnewhorizons.retrofuturagradle","1.4.2"))

// Settings plugins
api(pluginDep("com.diffplug.blowdryerSetup", "1.7.1"))
api(pluginDep("org.gradle.toolchains.foojay-resolver-convention", "0.7.0"))
api(pluginDep("org.gradle.toolchains.foojay-resolver-convention", "0.9.0"))

// Project plugins
api(pluginDep("com.github.johnrengelman.shadow", "8.1.1"))
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.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empt
preferPopulated = false,
required = false,
hidden = true,
docComment = "Whether to automatically set the version based on the VERSION environment variable or the current git status.")
docComment = """
Whether to automatically set the version based on the VERSION environment variable or the current git status.
If not used, make sure to set project.ext.modVersion to a String with a correct version number during project evaluation.
""")
public boolean moduleGitVersion = true;

/** See annotation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ public class UpdateableConstants {
/** Latest Gradle version to update to. */
// https://github.com/gradle/gradle/releases
@SuppressWarnings("unused") // Used via reflection
public static final @NotNull String NEWEST_GRADLE_VERSION = "8.9";
public static final @NotNull String NEWEST_GRADLE_VERSION = "8.11.1";

/** Latest tag of ExampleMod with blowdryer settings */
// https://github.com/GTNewHorizons/ExampleMod1.7.10/releases
public static final @NotNull String NEWEST_BLOWDRYER_TAG = "0.2.2";

/** Latest version of UniMixins */
public static final String NEWEST_UNIMIXINS = "io.github.legacymoddingmc:unimixins:0.1.17";
public static final String NEWEST_UNIMIXINS = "io.github.legacymoddingmc:unimixins:0.1.19";

/** Latest version of Jabel for modern Java support */
public static final @NotNull String NEWEST_JABEL = "com.github.bsideup.jabel:jabel-javac-plugin:1.0.1";
/** Latest version of GTNHLib for modern Java support */
// https://github.com/GTNewHorizons/GTNHLib/releases
public static final @NotNull String NEWEST_GTNH_LIB = "com.github.GTNewHorizons:GTNHLib:0.3.3";
public static final @NotNull String NEWEST_GTNH_LIB = "com.github.GTNewHorizons:GTNHLib:0.5.21";
/** Latest version of GTNHLib for modern Java support */
// https://github.com/GTNewHorizons/lwjgl3ify/releases
public static final @NotNull String NEWEST_LWJGL3IFY = "com.github.GTNewHorizons:lwjgl3ify:2.1.1";
public static final @NotNull String NEWEST_LWJGL3IFY = "com.github.GTNewHorizons:lwjgl3ify:2.1.5";
/** Latest version of GTNHLib for modern Java support */
// https://github.com/GTNewHorizons/Hodgepodge/releases
public static final @NotNull String NEWEST_HODGEPODGE = "com.github.GTNewHorizons:Hodgepodge:2.5.38";
public static final @NotNull String NEWEST_HODGEPODGE = "com.github.GTNewHorizons:Hodgepodge:2.5.82";
/** Latest version of LWJGL3 for modern Java support */
// https://github.com/LWJGL/lwjgl3/releases - but check what latest Minecraft uses too
public static final @NotNull String NEWEST_LWJGL3 = "3.3.3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import com.palantir.gradle.gitversion.VersionDetails;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project;
import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.jetbrains.annotations.NotNull;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;

/**
Expand All @@ -31,19 +30,7 @@ public boolean isEnabled(@NotNull PropertiesConfiguration configuration) {

@Override
public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project project) {
final Path projectDir = gtnh.getProjectLayout()
.getProjectDirectory()
.getAsFile()
.toPath();
String versionOverride = System.getenv("VERSION");
// In submodules, .git is a file pointing to the real git dir
final boolean isAGitRepo = Files.exists(projectDir.resolve(".git"));

if (!isAGitRepo && versionOverride == null) {
gtnh.logger.error(
"Project is not a git repository, and no VERSION override was set. Either initialize a git repo, set a VERSION environment variable override, or disable the gitVersion module.");
throw new IllegalStateException("Not a git repo, and no VERSION set.");
}

// Pulls version first from the VERSION env and then git tag
String identifiedVersion;
Expand Down Expand Up @@ -81,19 +68,27 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
} else {
identifiedVersion = versionOverride;
}
} catch (Exception ignored) {
gtnh.logger.error("""
This mod must be version controlled by Git AND the repository must provide at least one tag,
or the VERSION override must be set! (Do NOT download from GitHub using the ZIP option, instead
clone the repository, see https://gtnh.miraheze.org/wiki/Development for details.
""");
} catch (Exception underlyingError) {
gtnh.logger.debug("Could not use the Git version source", underlyingError);
gtnh.logger.error(
"""
This mod must be version controlled by Git AND the repository must provide at least one Git tag,
or the VERSION override must be set! (Do NOT download from GitHub using the ZIP option, instead
clone the repository, see https://gtnh.miraheze.org/wiki/Development for details.
If you don't want Git-based versioning, you can also replace it with a custom mechanism by setting
gtnh.modules.gitVersion = false
in your project's gradle.properties file, and populating project.ext.modVersion with a valid string in your buildscript.
""");
versionOverride = "NO-GIT-TAG-SET";
identifiedVersion = versionOverride;
}
project.setVersion(identifiedVersion);
project.getExtensions()
.getExtraProperties()
.set(GTNHConstants.MOD_VERSION_PROPERTY, identifiedVersion);
ExtraPropertiesExtension extraProps = project.getExtensions()
.getExtraProperties();
if (!extraProps.has(GTNHConstants.MOD_VERSION_PROPERTY)) {
extraProps.set(GTNHConstants.MOD_VERSION_PROPERTY, identifiedVersion);
}

if (identifiedVersion.equals(versionOverride)) {
gtnh.logger.warn("Version override set to {}!", identifiedVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.darkhax.curseforgegradle.TaskPublishCurseForge;
import org.gradle.api.Project;
import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.plugins.PublishingPlugin;
Expand Down Expand Up @@ -45,8 +46,9 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project

final ExtraPropertiesExtension ext = project.getExtensions()
.getExtraProperties();
final String modVersion = Objects.requireNonNull(ext.get(GTNHConstants.MOD_VERSION_PROPERTY))
.toString();
final Provider<String> modVersion = project.provider(
() -> Objects.requireNonNull(ext.get(GTNHConstants.MOD_VERSION_PROPERTY))
.toString());

// Maven
publishing.getPublications()
Expand All @@ -65,7 +67,8 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
project.getGroup()
.toString()));
mvn.setArtifactId(ObjectUtils.firstNonNull(System.getenv("ARTIFACT_ID"), project.getName()));
mvn.setVersion(ObjectUtils.firstNonNull(System.getenv("RELEASE_VERSION"), modVersion));
project.afterEvaluate(
_p -> mvn.setVersion(ObjectUtils.firstNonNull(System.getenv("RELEASE_VERSION"), modVersion.get())));
});
final String mavenUser = System.getenv("MAVEN_USER");
final String mavenPass = System.getenv("MAVEN_PASSWORD");
Expand Down Expand Up @@ -100,7 +103,7 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
mr.getVersionNumber()
.set(modVersion);
mr.getVersionType()
.set(modVersion.endsWith("-pre") ? "beta" : "release");
.set(modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release"));
if (changelogFile.exists()) {
final String contents = new String(Files.readAllBytes(changelogFile.toPath()), StandardCharsets.UTF_8);
mr.getChangelog()
Expand Down Expand Up @@ -165,7 +168,7 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
artifact.changelogType = "markdown";
artifact.changelog = changelogFile;
}
artifact.releaseType = modVersion.endsWith("-pre") ? "beta" : "release";
artifact.releaseType = modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release");
artifact.addGameVersion(gtnh.configuration.minecraftVersion, "Forge");
artifact.addModLoader("Forge");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.java.archives.Manifest;
import org.gradle.api.plugins.BasePluginExtension;
import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.MapProperty;
Expand Down Expand Up @@ -264,14 +265,15 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
}
}
if (!gtnh.configuration.gradleTokenVersion.isEmpty()) {
ExtraPropertiesExtension extraProps = project.getExtensions()
.getExtraProperties();
minecraft.getInjectedTags()
.put(
gtnh.configuration.gradleTokenVersion,
Objects.requireNonNull(
project.getExtensions()
.getExtraProperties()
.get(GTNHConstants.MOD_VERSION_PROPERTY))
.toString());
project.getProviders()
.provider(
() -> Objects.requireNonNull(extraProps.get(GTNHConstants.MOD_VERSION_PROPERTY))
.toString()));
}

// Other assorted settings
Expand Down

0 comments on commit e6e7e71

Please sign in to comment.