diff --git a/build.gradle b/build.gradle index bd6289c..621bc62 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1689409577 +//version: 1696265388 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -69,7 +69,7 @@ plugins { id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.3.19' + id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24' } print("You might want to check out './gradlew :faq' if your build fails.\n") @@ -89,6 +89,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output') def projectJavaVersion = JavaLanguageVersion.of(8) boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false +boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false + +final String CHECKSTYLE_CONFIG = """ + + + + + + + + + + + +""" checkPropertyExists("modName") checkPropertyExists("modId") @@ -140,6 +157,17 @@ if (!disableSpotless) { apply from: Blowdryer.file('spotless.gradle') } +if (!disableCheckstyle) { + apply plugin: 'checkstyle' + tasks.named("checkstylePatchedMc") { enabled = false } + tasks.named("checkstyleMcLauncher") { enabled = false } + tasks.named("checkstyleIdeVirtualMain") { enabled = false } + tasks.named("checkstyleInjectedTags") { enabled = false } + checkstyle { + config = resources.text.fromString(CHECKSTYLE_CONFIG) + } +} + String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" String kotlinSourceDir = "src/main/kotlin/" @@ -401,9 +429,13 @@ if (identifiedVersion == versionOverride) { group = "com.github.GTNewHorizons" if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { - archivesBaseName = customArchiveBaseName + base { + archivesName = customArchiveBaseName + } } else { - archivesBaseName = modId + base { + archivesName = modId + } } @@ -558,9 +590,6 @@ repositories { maven { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' - mavenContent { - excludeGroup("net.minecraftforge") // missing the `universal` artefact - } } maven { name = "GTNH Maven" @@ -575,24 +604,34 @@ repositories { } } if (includeWellKnownRepositories.toBoolean()) { - maven { - name "CurseMaven" - url "https://cursemaven.com" - content { + exclusiveContent { + forRepository { + maven { + name "CurseMaven" + url "https://cursemaven.com" + } + } + filter { includeGroup "curse.maven" } } - maven { - name = "ic2" - url = "https://maven.ic2.player.to/" - metadataSources { - mavenPom() - artifact() + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } + } + filter { + includeGroup "maven.modrinth" } } maven { - name = "ic2-mirror" - url = "https://maven2.ic2.player.to/" + name = "ic2" + url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/") + content { + includeGroup "net.industrial-craft" + } metadataSources { mavenPom() artifact() @@ -612,6 +651,8 @@ def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule} def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev" ext.mixinProviderSpec = mixinProviderSpec +def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json' + dependencies { if (usesMixins.toBoolean()) { annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3') @@ -623,7 +664,7 @@ dependencies { } } if (usesMixins.toBoolean()) { - implementation(mixinProviderSpec) + implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap)) } else if (forceEnableMixins.toBoolean()) { runtimeOnlyNonPublishable(mixinProviderSpec) } @@ -676,11 +717,6 @@ if (file('dependencies.gradle.kts').exists()) { throw new RuntimeException("Missing dependencies.gradle[.kts]") } -def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json' -def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins' -def refMap = "${mixinTmpDir}" + File.separator + mixingConfigRefMap -def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg" - tasks.register('generateAssets') { group = "GTNH Buildscript" description = "Generates a mixin config file at /src/main/resources/mixins.modid.json if needed" @@ -711,46 +747,17 @@ tasks.register('generateAssets') { } if (usesMixins.toBoolean()) { - tasks.named("reobfJar", ReobfuscatedJar).configure { - extraSrgFiles.from(mixinSrg) - } - tasks.named("processResources").configure { dependsOn("generateAssets") } tasks.named("compileJava", JavaCompile).configure { - doFirst { - new File(mixinTmpDir).mkdirs() - } options.compilerArgs += [ - "-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}", - "-AoutSrgFile=${mixinSrg}", - "-AoutRefMapFile=${refMap}", // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code "-XDenableSunApiLintControl", "-XDignore.symbol.file" ] } - - pluginManager.withPlugin('org.jetbrains.kotlin.kapt') { - kapt { - correctErrorTypes = true - javacOptions { - option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}") - option("-AoutSrgFile=$mixinSrg") - option("-AoutRefMapFile=$refMap") - } - } - tasks.configureEach { task -> - if (task.name == "kaptKotlin") { - task.doFirst { - new File(mixinTmpDir).mkdirs() - } - } - } - } - } tasks.named("processResources", ProcessResources).configure { @@ -768,7 +775,6 @@ tasks.named("processResources", ProcessResources).configure { } if (usesMixins.toBoolean()) { - from refMap dependsOn("compileJava", "compileScala") } } @@ -787,23 +793,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies" } dependencies { - def lwjgl3ifyVersion = '1.4.0' - def asmVersion = '9.4' + def lwjgl3ifyVersion = '1.5.0' if (modId != 'lwjgl3ify') { java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") } if (modId != 'hodgepodge') { - java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.19') + java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.7') } - java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false} - java17PatchDependencies("org.ow2.asm:asm:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}") - java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1') - java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0") java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false} } @@ -1166,7 +1163,10 @@ tasks.named("processIdeaSettings").configure { tasks.named("ideVirtualMainClasses").configure { // Make IntelliJ "Build project" build the mod jars - dependsOn("jar", "reobfJar", "spotlessCheck") + dependsOn("jar", "reobfJar") + if (!disableSpotless) { + dependsOn("spotlessCheck") + } } // workaround variable hiding in pom processing @@ -1311,7 +1311,7 @@ def addCurseForgeRelation(String type, String name) { // Updating -def buildscriptGradleVersion = "8.1.1" +def buildscriptGradleVersion = "8.2.1" tasks.named('wrapper', Wrapper).configure { gradleVersion = buildscriptGradleVersion @@ -1590,6 +1590,25 @@ def getSecondaryArtifacts() { return secondaryArtifacts } +def getURL(String main, String fallback) { + return pingURL(main, 10000) ? main : fallback +} + +// credit: https://stackoverflow.com/a/3584332 +def pingURL(String url, int timeout) { + url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates. + try { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection() + connection.setConnectTimeout(timeout) + connection.setReadTimeout(timeout) + connection.setRequestMethod("HEAD") + int responseCode = connection.getResponseCode() + return 200 <= responseCode && responseCode <= 399 + } catch (IOException ignored) { + return false + } +} + // For easier scripting of things that require variables defined earlier in the buildscript if (file('addon.late.gradle.kts').exists()) { apply from: 'addon.late.gradle.kts' diff --git a/dependencies.gradle b/dependencies.gradle index 6eadea9..f27c6d2 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,10 +1,10 @@ // Add your dependencies here dependencies { - implementation("com.github.GTNewHorizons:NotEnoughItems:2.3.45-GTNH:dev") + implementation("com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev") - compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-195-GTNH:dev") { transitive = false } - compileOnly("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.1.65-GTNH:dev") {transitive = false} + compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-261-GTNH:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:Galaxy-Space-GTNH:1.2.9-GTNH:dev") {transitive = false} compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive = false} compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') {transitive = false} } diff --git a/src/main/java/me/eigenraven/personalspace/gui/GuiEditWorld.java b/src/main/java/me/eigenraven/personalspace/gui/GuiEditWorld.java index 65d2afd..7e8057e 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/GuiEditWorld.java +++ b/src/main/java/me/eigenraven/personalspace/gui/GuiEditWorld.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/src/main/java/me/eigenraven/personalspace/gui/WButton.java b/src/main/java/me/eigenraven/personalspace/gui/WButton.java index 7993f87..c4ef025 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/WButton.java +++ b/src/main/java/me/eigenraven/personalspace/gui/WButton.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; import javax.annotation.Nonnull; diff --git a/src/main/java/me/eigenraven/personalspace/gui/WRectangle.java b/src/main/java/me/eigenraven/personalspace/gui/WRectangle.java index 8685c62..47237b2 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/WRectangle.java +++ b/src/main/java/me/eigenraven/personalspace/gui/WRectangle.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; public class WRectangle extends Widget { diff --git a/src/main/java/me/eigenraven/personalspace/gui/WSlider.java b/src/main/java/me/eigenraven/personalspace/gui/WSlider.java index d208432..184e86e 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/WSlider.java +++ b/src/main/java/me/eigenraven/personalspace/gui/WSlider.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; import java.util.function.DoubleConsumer; import javax.annotation.Nonnull; diff --git a/src/main/java/me/eigenraven/personalspace/gui/WTextField.java b/src/main/java/me/eigenraven/personalspace/gui/WTextField.java index 0fe6d94..db432b1 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/WTextField.java +++ b/src/main/java/me/eigenraven/personalspace/gui/WTextField.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiTextField; diff --git a/src/main/java/me/eigenraven/personalspace/gui/WToggleButton.java b/src/main/java/me/eigenraven/personalspace/gui/WToggleButton.java index deff8bb..fd1cc4e 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/WToggleButton.java +++ b/src/main/java/me/eigenraven/personalspace/gui/WToggleButton.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; public class WToggleButton extends WButton { diff --git a/src/main/java/me/eigenraven/personalspace/gui/Widget.java b/src/main/java/me/eigenraven/personalspace/gui/Widget.java index 5d98c08..1d46ac7 100644 --- a/src/main/java/me/eigenraven/personalspace/gui/Widget.java +++ b/src/main/java/me/eigenraven/personalspace/gui/Widget.java @@ -1,6 +1,6 @@ package me.eigenraven.personalspace.gui; -import java.awt.*; +import java.awt.Rectangle; import java.util.ArrayList; import net.minecraft.client.Minecraft;