Skip to content

Commit

Permalink
Update RFG and add a propertiesHelp task to print a list of all avail…
Browse files Browse the repository at this point in the history
…able properties (#16)

* Update RFG, Gradle and mod versions

* Add a propertiesHelp task to print a list of all available properties
  • Loading branch information
eigenraven authored Jun 16, 2024
1 parent fa0ddb9 commit 640a6c8
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ gtnh.modules.codeStyle = false
gtnh.modules.modernJava = false

```

Run `./gradlew propertiesHelp` to list all the available properties along with their descriptions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ 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.3.35"))
api(pluginDep("com.gtnewhorizons.retrofuturagradle","1.4.0"))

// Settings plugins
api(pluginDep("com.diffplug.blowdryerSetup", "1.7.1"))
Expand All @@ -50,11 +50,11 @@ dependencies {
api(pluginDep("org.jetbrains.kotlin.kapt", "1.8.0"))
api(pluginDep("com.google.devtools.ksp", "1.8.0-1.0.9"))
api(pluginDep("org.ajoberstar.grgit", "4.1.1")) // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
api(pluginDep("com.github.johnrengelman.shadow", "8.1.1"))
api(pluginDep("io.github.goooler.shadow", "8.1.7"))
api(pluginDep("de.undercouch.download", "5.6.0"))
api(pluginDep("com.github.gmazzo.buildconfig", "3.1.0")) // Unused, available for addon.gradle
api(pluginDep("com.modrinth.minotaur", "2.8.7"))
api(pluginDep("net.darkhax.curseforgegradle", "1.1.23"))
api(pluginDep("net.darkhax.curseforgegradle", "1.1.24"))

testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
Expand Down
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.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down Expand Up @@ -926,6 +927,48 @@ private static void appendPropertySafeString(StringBuilder sb, String text) {
});
}

/**
* Prints documentation for all the available properties
*
* @param out The stream to write to.
*/
public static void printPropertyDocs(final PrintStream out) {
out.println("GTNHGradle supports various Gradle properties to change its behaviour:");
final Field[] fields = PropertiesConfiguration.class.getDeclaredFields();
final PropertiesConfiguration defaultCfg = new PropertiesConfiguration();
try {
for (final Field field : fields) {
final Prop prop = field.getAnnotation(Prop.class);
if (prop == null) {
continue;
}
final String key = prop.name();
Object defaultValue = field.get(defaultCfg);
if (defaultValue instanceof String) {
defaultValue = '"' + (String) defaultValue + '"';
} else if (defaultValue == null) {
defaultValue = "null";
}
out.println();
out.print("Key: ");
out.println(key);
out.printf(
"Affects settings.gradle: %s Required: %s Default: %s%n",
prop.isSettings(),
prop.required(),
defaultValue);
out.println("Description: ");
String docOut = "\n" + prop.docComment()
.trim();
// indent everything two spaces
docOut = docOut.replace("\n", "\n ");
out.println(docOut);
}
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}

/** Property metadata */
@Documented
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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.7";
public static final @NotNull String NEWEST_GRADLE_VERSION = "8.8";

/** Latest tag of ExampleMod with blowdryer settings */
// https://github.com/GTNewHorizons/ExampleMod1.7.10/releases
Expand All @@ -26,10 +26,10 @@ public class UpdateableConstants {
public static final @NotNull String NEWEST_GTNH_LIB = "com.github.GTNewHorizons:GTNHLib:0.2.11";
/** 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.0.6";
public static final @NotNull String NEWEST_LWJGL3IFY = "com.github.GTNewHorizons:lwjgl3ify:2.0.9";
/** 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.4.42";
public static final @NotNull String NEWEST_HODGEPODGE = "com.github.GTNewHorizons:Hodgepodge:2.5.19";
/** 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.2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
run.setWorkingDirectory(
runClient.getWorkingDir()
.getAbsolutePath());
run.setProgramParameters(quotedJoin(runClient.calculateArgs(project)));
run.setProgramParameters(quotedJoin(runClient.calculateArgs()));
run.setJvmArgs(
quotedJoin(runClient.calculateJvmArgs(project)) + ' '
+ quotedPropJoin(runClient.getSystemProperties()));
quotedJoin(runClient.calculateJvmArgs()) + ' ' + quotedPropJoin(runClient.getSystemProperties()));
});
final var ijServerRun = runs.register("Run Server (IJ Native)", Application.class, run -> {
run.setMainClass("GradleStartServer");
Expand All @@ -196,10 +195,9 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
run.setWorkingDirectory(
runServer.getWorkingDir()
.getAbsolutePath());
run.setProgramParameters(quotedJoin(runServer.calculateArgs(project)));
run.setProgramParameters(quotedJoin(runServer.calculateArgs()));
run.setJvmArgs(
quotedJoin(runServer.calculateJvmArgs(project)) + ' '
+ quotedPropJoin(runServer.getSystemProperties()));
quotedJoin(runServer.calculateJvmArgs()) + ' ' + quotedPropJoin(runServer.getSystemProperties()));
});

ideaExt.withIDEADir(ideaDir -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project
});
});

tasks.register("propertiesHelp", t -> {
t.setGroup("GTNH Buildscript");
t.setDescription("Prints descriptions for all the settings available in gradle.properties");
t.doLast(inner -> { PropertiesConfiguration.printPropertyDocs(System.out); });
});

tasks.register("deobfParams", t -> {
t.setGroup("GTNH Buildscript");
t.setDescription("Rename all obfuscated parameter names inherited from Minecraft classes");
Expand Down

0 comments on commit 640a6c8

Please sign in to comment.