Skip to content

Commit 3d68a82

Browse files
authored
Don't use ObjectInputStream (#24)
* Remove outdated script * updateBuildScript * Don't use ObjectInputStream
1 parent a5a88f3 commit 3d68a82

File tree

10 files changed

+155
-222
lines changed

10 files changed

+155
-222
lines changed

.github/scripts/test_no_error_reports

-51
This file was deleted.

build.gradle

+130-55
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1685785062
1+
//version: 1690104383
22
/*
33
DO NOT CHANGE THIS FILE!
44
Also, you may replace this file at any time if there is an update available.
@@ -69,7 +69,7 @@ plugins {
6969
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
7070
id 'com.modrinth.minotaur' version '2.+' apply false
7171
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
72-
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.14'
72+
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.21'
7373
}
7474

7575
print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -115,6 +115,8 @@ propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
115115
propertyDefaultIfUnset("forceEnableMixins", false)
116116
propertyDefaultIfUnset("channel", "stable")
117117
propertyDefaultIfUnset("mappingsVersion", "12")
118+
propertyDefaultIfUnset("usesMavenPublishing", true)
119+
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
118120
propertyDefaultIfUnset("modrinthProjectId", "")
119121
propertyDefaultIfUnset("modrinthRelations", "")
120122
propertyDefaultIfUnset("curseForgeProjectId", "")
@@ -357,7 +359,27 @@ catch (Exception ignored) {
357359
String identifiedVersion
358360
String versionOverride = System.getenv("VERSION") ?: null
359361
try {
360-
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
362+
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
363+
if (versionOverride == null) {
364+
def gitDetails = versionDetails()
365+
def isDirty = gitVersion().endsWith(".dirty") // No public API for this, isCleanTag has a different meaning
366+
String branchName = gitDetails.branchName ?: (System.getenv('GIT_BRANCH') ?: 'git')
367+
if (branchName.startsWith('origin/')) {
368+
branchName = branchName.minus('origin/')
369+
}
370+
branchName = branchName.replaceAll("[^a-zA-Z0-9-]+", "-") // sanitize branch names for semver
371+
identifiedVersion = gitDetails.lastTag ?: '${gitDetails.gitHash}'
372+
if (gitDetails.commitDistance > 0) {
373+
identifiedVersion += "-${branchName}.${gitDetails.commitDistance}+${gitDetails.gitHash}"
374+
if (isDirty) {
375+
identifiedVersion += "-dirty"
376+
}
377+
} else if (isDirty) {
378+
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
379+
}
380+
} else {
381+
identifiedVersion = versionOverride
382+
}
361383
}
362384
catch (Exception ignored) {
363385
out.style(Style.Failure).text(
@@ -465,10 +487,19 @@ sourceSets {
465487
}
466488
}
467489

468-
if (file('addon.gradle').exists()) {
490+
if (file('addon.gradle.kts').exists()) {
491+
apply from: 'addon.gradle.kts'
492+
} else if (file('addon.gradle').exists()) {
469493
apply from: 'addon.gradle'
470494
}
471495

496+
// File for local tweaks not commited to Git
497+
if (file('addon.local.gradle.kts').exists()) {
498+
apply from: 'addon.local.gradle.kts'
499+
} else if (file('addon.local.gradle').exists()) {
500+
apply from: 'addon.local.gradle'
501+
}
502+
472503
// Allow unsafe repos but warn
473504
repositories.configureEach { repo ->
474505
if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) {
@@ -479,7 +510,14 @@ repositories.configureEach { repo ->
479510
}
480511
}
481512

482-
apply from: 'repositories.gradle'
513+
if (file('repositories.gradle.kts').exists()) {
514+
apply from: 'repositories.gradle.kts'
515+
} else if (file('repositories.gradle').exists()) {
516+
apply from: 'repositories.gradle'
517+
} else {
518+
logger.error("Neither repositories.gradle.kts nor repositories.gradle was found, make sure you extracted the full ExampleMod template.")
519+
throw new RuntimeException("Missing repositories.gradle[.kts]")
520+
}
483521

484522
configurations {
485523
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
@@ -537,13 +575,28 @@ repositories {
537575
}
538576
}
539577
if (includeWellKnownRepositories.toBoolean()) {
540-
maven {
541-
name "CurseMaven"
542-
url "https://cursemaven.com"
543-
content {
578+
exclusiveContent {
579+
forRepository {
580+
maven {
581+
name "CurseMaven"
582+
url "https://cursemaven.com"
583+
}
584+
}
585+
filter {
544586
includeGroup "curse.maven"
545587
}
546588
}
589+
exclusiveContent {
590+
forRepository {
591+
maven {
592+
name = "Modrinth"
593+
url = "https://api.modrinth.com/maven"
594+
}
595+
}
596+
filter {
597+
includeGroup "maven.modrinth"
598+
}
599+
}
547600
maven {
548601
name = "ic2"
549602
url = "https://maven.ic2.player.to/"
@@ -585,7 +638,7 @@ dependencies {
585638
}
586639
}
587640
if (usesMixins.toBoolean()) {
588-
implementation(mixinProviderSpec)
641+
implementation(modUtils.enableMixins(mixinProviderSpec))
589642
} else if (forceEnableMixins.toBoolean()) {
590643
runtimeOnlyNonPublishable(mixinProviderSpec)
591644
}
@@ -611,12 +664,34 @@ configurations.all {
611664
}
612665
}
613666

614-
apply from: 'dependencies.gradle'
667+
dependencies {
668+
constraints {
669+
def minGtnhLibVersion = "0.0.13"
670+
implementation("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
671+
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
672+
}
673+
runtimeOnly("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
674+
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
675+
}
676+
devOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
677+
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
678+
}
679+
runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
680+
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
681+
}
682+
}
683+
}
684+
685+
if (file('dependencies.gradle.kts').exists()) {
686+
apply from: 'dependencies.gradle.kts'
687+
} else if (file('dependencies.gradle').exists()) {
688+
apply from: 'dependencies.gradle'
689+
} else {
690+
logger.error("Neither dependencies.gradle.kts nor dependencies.gradle was found, make sure you extracted the full ExampleMod template.")
691+
throw new RuntimeException("Missing dependencies.gradle[.kts]")
692+
}
615693

616694
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
617-
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
618-
def refMap = "${mixinTmpDir}" + File.separator + mixingConfigRefMap
619-
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"
620695

621696
tasks.register('generateAssets') {
622697
group = "GTNH Buildscript"
@@ -648,46 +723,17 @@ tasks.register('generateAssets') {
648723
}
649724

650725
if (usesMixins.toBoolean()) {
651-
tasks.named("reobfJar", ReobfuscatedJar).configure {
652-
extraSrgFiles.from(mixinSrg)
653-
}
654-
655726
tasks.named("processResources").configure {
656727
dependsOn("generateAssets")
657728
}
658729

659730
tasks.named("compileJava", JavaCompile).configure {
660-
doFirst {
661-
new File(mixinTmpDir).mkdirs()
662-
}
663731
options.compilerArgs += [
664-
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
665-
"-AoutSrgFile=${mixinSrg}",
666-
"-AoutRefMapFile=${refMap}",
667732
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
668733
"-XDenableSunApiLintControl",
669734
"-XDignore.symbol.file"
670735
]
671736
}
672-
673-
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
674-
kapt {
675-
correctErrorTypes = true
676-
javacOptions {
677-
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
678-
option("-AoutSrgFile=$mixinSrg")
679-
option("-AoutRefMapFile=$refMap")
680-
}
681-
}
682-
tasks.configureEach { task ->
683-
if (task.name == "kaptKotlin") {
684-
task.doFirst {
685-
new File(mixinTmpDir).mkdirs()
686-
}
687-
}
688-
}
689-
}
690-
691737
}
692738

693739
tasks.named("processResources", ProcessResources).configure {
@@ -705,7 +751,6 @@ tasks.named("processResources", ProcessResources).configure {
705751
}
706752

707753
if (usesMixins.toBoolean()) {
708-
from refMap
709754
dependsOn("compileJava", "compileScala")
710755
}
711756
}
@@ -724,13 +769,13 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
724769
}
725770

726771
dependencies {
727-
def lwjgl3ifyVersion = '1.3.5'
772+
def lwjgl3ifyVersion = '1.4.0'
728773
def asmVersion = '9.4'
729774
if (modId != 'lwjgl3ify') {
730775
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
731776
}
732777
if (modId != 'hodgepodge') {
733-
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.13')
778+
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.19')
734779
}
735780

736781
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
@@ -979,6 +1024,9 @@ idea {
9791024
}
9801025
}
9811026
runConfigurations {
1027+
"0. Build and Test"(Gradle) {
1028+
taskNames = ["build"]
1029+
}
9821030
"1. Run Client"(Gradle) {
9831031
taskNames = ["runClient"]
9841032
}
@@ -1098,6 +1146,11 @@ tasks.named("processIdeaSettings").configure {
10981146
dependsOn("injectTags")
10991147
}
11001148

1149+
tasks.named("ideVirtualMainClasses").configure {
1150+
// Make IntelliJ "Build project" build the mod jars
1151+
dependsOn("jar", "reobfJar", "spotlessCheck")
1152+
}
1153+
11011154
// workaround variable hiding in pom processing
11021155
def projectConfigs = project.configurations
11031156

@@ -1118,12 +1171,14 @@ publishing {
11181171
}
11191172

11201173
repositories {
1121-
maven {
1122-
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
1123-
allowInsecureProtocol = true
1124-
credentials {
1125-
username = System.getenv("MAVEN_USER") ?: "NONE"
1126-
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
1174+
if (usesMavenPublishing.toBoolean()) {
1175+
maven {
1176+
url = mavenPublishUrl
1177+
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
1178+
credentials {
1179+
username = System.getenv("MAVEN_USER") ?: "NONE"
1180+
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
1181+
}
11271182
}
11281183
}
11291184
}
@@ -1238,7 +1293,7 @@ def addCurseForgeRelation(String type, String name) {
12381293

12391294
// Updating
12401295

1241-
def buildscriptGradleVersion = "8.1.1"
1296+
def buildscriptGradleVersion = "8.2.1"
12421297

12431298
tasks.named('wrapper', Wrapper).configure {
12441299
gradleVersion = buildscriptGradleVersion
@@ -1344,8 +1399,14 @@ boolean isNewBuildScriptVersionAvailable() {
13441399

13451400
String currentBuildScript = getFile("build.gradle").getText()
13461401
String currentBuildScriptHash = getVersionHash(currentBuildScript)
1347-
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
1348-
String availableBuildScriptHash = getVersionHash(availableBuildScript)
1402+
String availableBuildScriptHash
1403+
try {
1404+
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
1405+
availableBuildScriptHash = getVersionHash(availableBuildScript)
1406+
} catch (IOException e) {
1407+
logger.warn("Could not check for buildscript update availability: {}", e.message)
1408+
return false
1409+
}
13491410

13501411
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
13511412
return !isUpToDate
@@ -1510,3 +1571,17 @@ def getSecondaryArtifacts() {
15101571
if (apiPackage) secondaryArtifacts += [apiJar]
15111572
return secondaryArtifacts
15121573
}
1574+
1575+
// For easier scripting of things that require variables defined earlier in the buildscript
1576+
if (file('addon.late.gradle.kts').exists()) {
1577+
apply from: 'addon.late.gradle.kts'
1578+
} else if (file('addon.late.gradle').exists()) {
1579+
apply from: 'addon.late.gradle'
1580+
}
1581+
1582+
// File for local tweaks not commited to Git
1583+
if (file('addon.late.local.gradle.kts').exists()) {
1584+
apply from: 'addon.late.local.gradle.kts'
1585+
} else if (file('addon.late.local.gradle').exists()) {
1586+
apply from: 'addon.late.local.gradle'
1587+
}

gradle/wrapper/gradle-wrapper.jar

468 Bytes
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)