Skip to content

Commit

Permalink
Update gradle + deps + remove wildcard imports (#21)
Browse files Browse the repository at this point in the history
* Update gradle + deps

* Remove wildcard imports
  • Loading branch information
Caedis authored Oct 10, 2023
1 parent 817299a commit 6c9e8db
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 78 deletions.
155 changes: 87 additions & 68 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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")
Expand All @@ -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 = """
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
<module name="SuppressionCommentFilter"/>
<module name="AvoidStarImport">
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
<property name="allowStaticMemberImports" value="true"/>
</module>
</module>
</module>
"""

checkPropertyExists("modName")
checkPropertyExists("modId")
Expand Down Expand Up @@ -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/"
Expand Down Expand Up @@ -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
}
}


Expand Down Expand Up @@ -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"
Expand All @@ -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()
Expand All @@ -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')
Expand All @@ -623,7 +664,7 @@ dependencies {
}
}
if (usesMixins.toBoolean()) {
implementation(mixinProviderSpec)
implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap))
} else if (forceEnableMixins.toBoolean()) {
runtimeOnlyNonPublishable(mixinProviderSpec)
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -768,7 +775,6 @@ tasks.named("processResources", ProcessResources).configure {
}

if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}
Expand All @@ -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}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/eigenraven/personalspace/gui/WButton.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.eigenraven.personalspace.gui;

import java.awt.*;
import java.awt.Rectangle;

import javax.annotation.Nonnull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.eigenraven.personalspace.gui;

import java.awt.*;
import java.awt.Rectangle;

public class WRectangle extends Widget {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/eigenraven/personalspace/gui/WSlider.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.eigenraven.personalspace.gui;

import java.awt.*;
import java.awt.Rectangle;

public class WToggleButton extends WButton {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/eigenraven/personalspace/gui/Widget.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 6c9e8db

Please sign in to comment.