diff --git a/build.gradle b/build.gradle index b7756e80..78caf988 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1674943145 +//version: 1675074449 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -55,9 +55,9 @@ plugins { id 'eclipse' id 'scala' id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false - id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false - id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false + id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false + id 'org.jetbrains.kotlin.kapt' version '1.8.0' apply false + id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version ,unused, available for addon.gradle id 'com.github.johnrengelman.shadow' version '7.1.2' apply false id 'com.palantir.git-version' version '0.13.0' apply false // 0.13.0 is the last jvm8 supporting version @@ -66,7 +66,7 @@ plugins { id 'com.diffplug.spotless' version '6.7.2' apply false id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.0.16' + id 'com.gtnewhorizons.retrofuturagradle' version '1.0.18' } boolean settingsupdated = verifySettingsGradle() settingsupdated = verifyGitAttributes() || settingsupdated @@ -113,6 +113,7 @@ propertyDefaultIfUnset("modrinthRelations", "") propertyDefaultIfUnset("curseForgeProjectId", "") propertyDefaultIfUnset("curseForgeRelations", "") propertyDefaultIfUnset("minimizeShadowedDependencies", true) +propertyDefaultIfUnset("relocateShadowedDependencies", true) // Deprecated properties (kept for backwards compat) propertyDefaultIfUnset("gradleTokenModId", "") propertyDefaultIfUnset("gradleTokenModName", "") @@ -149,6 +150,30 @@ java { } } +pluginManager.withPlugin('org.jetbrains.kotlin.jvm') { + // If Kotlin is enabled in the project + kotlin { + jvmToolchain(8) + } + // Kotlin hacks our source sets, so we hack Kotlin's tasks + def disabledKotlinTaskList = [ + "kaptGenerateStubsMcLauncherKotlin", + "kaptGenerateStubsPatchedMcKotlin", + "kaptGenerateStubsInjectedTagsKotlin", + "compileMcLauncherKotlin", + "compilePatchedMcKotlin", + "compileInjectedTagsKotlin", + "kaptMcLauncherKotlin", + "kaptPatchedMcKotlin", + "kaptInjectedTagsKotlin", + ] + tasks.configureEach { task -> + if (task.name in disabledKotlinTaskList) { + task.enabled = false + } + } +} + configurations { create("runtimeOnlyNonPublishable") { description = "Runtime only dependencies that are not published alongside the jar" @@ -212,6 +237,25 @@ if (accessTransformersFile) { } tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(targetFile) tasks.srgifyBinpatchedJar.accessTransformerFiles.from(targetFile) +} else { + boolean atsFound = false + for (File at : sourceSets.getByName("main").resources.files) { + if (at.name.toLowerCase().endsWith("_at.cfg")) { + atsFound = true + tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) + tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) + } + } + for (File at : sourceSets.getByName("api").resources.files) { + if (at.name.toLowerCase().endsWith("_at.cfg")) { + atsFound = true + tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) + tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) + } + } + if (atsFound) { + logger.warn("Found and added access transformers in the resources folder, please configure gradle.properties to explicitly mention them by name") + } } if (usesMixins.toBoolean()) { @@ -356,6 +400,16 @@ configurations.configureEach { } } +// Ensure tests have access to minecraft classes +sourceSets { + test { + java { + compileClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output + runtimeClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output + } + } +} + if (file('addon.gradle').exists()) { apply from: 'addon.gradle' } @@ -363,7 +417,7 @@ if (file('addon.gradle').exists()) { // Allow unsafe repos but warn repositories.configureEach { repo -> if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) { - if (repo.getUrl().getScheme() == "http" && !repo.allowInsecureProtocol) { + if (repo.getUrl() != null && repo.getUrl().getScheme() == "http" && !repo.allowInsecureProtocol) { logger.warn("Deprecated: Allowing insecure connections for repo '${repo.name}' - add 'allowInsecureProtocol = true'") repo.allowInsecureProtocol = true } @@ -473,6 +527,14 @@ dependencies { } } +pluginManager.withPlugin('org.jetbrains.kotlin.kapt') { + if (usesMixins.toBoolean()) { + dependencies { + kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor') + } + } +} + apply from: 'dependencies.gradle' def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json' @@ -513,9 +575,11 @@ if (usesMixins.toBoolean()) { tasks.named("reobfJar", ReobfuscatedJar).configure { extraSrgFiles.from(mixinSrg) } -} -if (usesMixins.toBoolean()) { + tasks.named("processResources").configure { + dependsOn("generateAssets") + } + tasks.named("compileJava", JavaCompile).configure { doFirst { new File(mixinTmpDir).mkdirs() @@ -529,6 +593,25 @@ if (usesMixins.toBoolean()) { "-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 { @@ -584,6 +667,7 @@ if (usesShadowedDependencies.toBoolean()) { tasks.register('relocateShadowJar', ConfigureShadowRelocation) { target = tasks.shadowJar prefix = modGroup + ".shadow" + enabled = minimizeShadowedDependencies.toBoolean() } tasks.named("shadowJar", ShadowJar).configure { manifest { @@ -599,7 +683,9 @@ if (usesShadowedDependencies.toBoolean()) { project.configurations.shadeCompile ] archiveClassifier.set('dev') - dependsOn(relocateShadowJar) + if (minimizeShadowedDependencies.toBoolean()) { + dependsOn(relocateShadowJar) + } } configurations.runtimeElements.outgoing.artifacts.clear() configurations.apiElements.outgoing.artifacts.clear() diff --git a/dependencies.gradle b/dependencies.gradle index 17e7cfa6..2b70485b 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,7 +1,7 @@ // Add your dependencies here dependencies { - compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.6:dev') - compile('com.github.GTNewHorizons:CodeChickenCore:1.1.7:dev') - shadowImplementation('org.apache.commons:commons-csv:1.8') + api('com.github.GTNewHorizons:CodeChickenLib:1.1.6:dev') + api('com.github.GTNewHorizons:CodeChickenCore:1.1.10:dev') + shadowImplementation('org.apache.commons:commons-csv:1.9.0') } diff --git a/gradle.properties b/gradle.properties index 5a8add40..11abecec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,11 +26,19 @@ developmentEnvironmentUserName = Developer # The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's # version in @Mod([...], version = VERSION, [...]) # Leave these properties empty to skip individual token replacements -replaceGradleTokenInFile = NEIModContainer.java -gradleTokenModId = GRADLETOKEN_MODID -gradleTokenModName = GRADLETOKEN_MODNAME -gradleTokenVersion = GRADLETOKEN_VERSION -gradleTokenGroupName = +# Generate a class with String fields for the mod id, name, version and group name named with the fields below +generateGradleTokenClass = codechicken.nei.Tags +gradleTokenModId = MODID +gradleTokenModName = MODNAME +gradleTokenVersion = VERSION +gradleTokenGroupName = GROUPNAME +# [DEPRECATED] +# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]) +# Leave these properties empty to skip individual token replacements +replaceGradleTokenInFile = # In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can # leave this property empty. diff --git a/src/main/java/codechicken/nei/NEIModContainer.java b/src/main/java/codechicken/nei/NEIModContainer.java index 354df5b3..45842911 100644 --- a/src/main/java/codechicken/nei/NEIModContainer.java +++ b/src/main/java/codechicken/nei/NEIModContainer.java @@ -42,9 +42,9 @@ public class NEIModContainer extends DummyModContainer { private static ModMetadata getModMetadata() { final ModMetadata modMetadata = new ModMetadata(); - modMetadata.name = "GRADLETOKEN_MODNAME"; - modMetadata.modId = "GRADLETOKEN_MODID"; - modMetadata.version = "GRADLETOKEN_VERSION"; + modMetadata.name = "NotEnoughItems"; + modMetadata.modId = "NotEnoughItems"; + modMetadata.version = Tags.VERSION; modMetadata.authorList = Arrays.asList("ChickenBones", "mitchej123"); modMetadata.url = "https://github.com/GTNewHorizons/NotEnoughItems"; modMetadata.description = "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements."; diff --git a/src/main/resources/dependencies.info b/src/main/resources/dependencies.info index 68689eb9..8da776ae 100644 --- a/src/main/resources/dependencies.info +++ b/src/main/resources/dependencies.info @@ -1,7 +1,7 @@ { - "repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.5.6/", - "file": "CodeChickenLib-1.7.10-1.1.5.6.jar", - "dev": "CodeChickenLib-1.7.10-1.1.5.6-dev.jar", + "repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.6/", + "file": "CodeChickenLib-1.7.10-1.1.6.jar", + "dev": "CodeChickenLib-1.7.10-1.1.6-dev.jar", "class": "codechicken.lib.asm.ASMHelper", "coreLib": true }