Skip to content

Commit

Permalink
Further gutting of the buildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Mar 9, 2024
1 parent d1041d6 commit 918098d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 175 deletions.
140 changes: 8 additions & 132 deletions EntityCulling-Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("minecraftVersion") // hard-coding this makes it harder to immediately tell what version a mod is in (even though this only really supports 1.12.2)
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinsPackage")
Expand All @@ -34,45 +33,20 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
// Optional properties: we can assume some default behavior if these are missing
propertyDefaultIfUnset("modVersion", "")
propertyDefaultIfUnset("includeMCVersionJar", false)
propertyDefaultIfUnset("autoUpdateBuildScript", false)
propertyDefaultIfUnset("modArchivesBaseName", project.modId)
propertyDefaultIfUnsetWithEnvVar("developmentEnvironmentUserName", "Developer", "DEV_USERNAME")
propertyDefaultIfUnset("generateGradleTokenClass", "")
propertyDefaultIfUnset("gradleTokenModId", "")
propertyDefaultIfUnset("gradleTokenModName", "")
propertyDefaultIfUnset("gradleTokenVersion", "")
propertyDefaultIfUnset("useSrcApiPath", false)
propertyDefaultIfUnset("includeWellKnownRepositories", true)
propertyDefaultIfUnset("includeCommonDevEnvMods", true)
propertyDefaultIfUnset("noPublishedSources", false)
propertyDefaultIfUnset("forceEnableMixins", false)
propertyDefaultIfUnsetWithEnvVar("enableCoreModDebug", false, "CORE_MOD_DEBUG")
propertyDefaultIfUnset("generateMixinConfig", true)
propertyDefaultIfUnset("usesShadowedDependencies", false)
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
propertyDefaultIfUnset("separateRunDirectories", false)
propertyDefaultIfUnset("versionDisplayFormat", '$MOD_NAME \u2212 $VERSION')
propertyDefaultIfUnsetWithEnvVar("modrinthProjectId", "", "MODRINTH_PROJECT_ID")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnsetWithEnvVar("curseForgeProjectId", "", "CURSEFORGE_PROJECT_ID")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnsetWithEnvVar("releaseType", "release", "RELEASE_TYPE")
propertyDefaultIfUnset("generateDefaultChangelog", false)
propertyDefaultIfUnset("customMavenPublishUrl", "")
propertyDefaultIfUnset("mavenArtifactGroup", getDefaultArtifactGroup())
propertyDefaultIfUnset("enableModernJavaSyntax", false)
propertyDefaultIfUnset("enableSpotless", false)
propertyDefaultIfUnset("enableJUnit", false)
propertyDefaultIfUnsetWithEnvVar("deploymentDebug", false, "DEPLOYMENT_DEBUG")


// Project property assertions

final String javaSourceDir = 'src/main/java/'

final String modGroupPath = modGroup.toString().replace('.' as char, '/' as char)
final String apiPackagePath = apiPackage.toString().replace('.' as char, '/' as char)

String targetPackageJava = javaSourceDir + modGroupPath

Expand All @@ -93,11 +67,7 @@ if (usesShadowedDependencies.toBoolean()) {

java {
toolchain {
if (enableModernJavaSyntax.toBoolean()) {
languageVersion.set(JavaLanguageVersion.of(17))
} else {
languageVersion.set(JavaLanguageVersion.of(8))
}
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8+ toolchains, crucially including MacOS arm64
vendor.set(JvmVendorSpec.AZUL)
}
Expand All @@ -108,20 +78,6 @@ java {

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'

if (enableModernJavaSyntax.toBoolean()) {
if (it.name in ['compileMcLauncherJava', 'compilePatchedMcJava']) {
return
}

sourceCompatibility = 17
options.release.set(8)

javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.AZUL)
})
}
}

tasks.withType(ScalaCompile).configureEach {
Expand Down Expand Up @@ -161,17 +117,6 @@ minecraft {
username = developmentEnvironmentUserName.toString()
useDependencyAccessTransformers = true

// Automatic token injection with RetroFuturaGradle
if (gradleTokenModId) {
injectedTags.put gradleTokenModId, modId
}
if (gradleTokenModName) {
injectedTags.put gradleTokenModName, modName
}
if (gradleTokenVersion) {
injectedTags.put gradleTokenVersion, modVersion
}

// JVM arguments
extraRunJvmArguments.add("-ea:${modGroup}")
if (usesMixins.toBoolean()) {
Expand All @@ -182,17 +127,6 @@ minecraft {
])
}

if (enableCoreModDebug.toBoolean()) {
extraRunJvmArguments.addAll([
'-Dlegacy.debugClassLoading=true',
'-Dlegacy.debugClassLoadingFiner=true',
'-Dlegacy.debugClassLoadingSave=true'
])
}
}

if (generateGradleTokenClass) {
tasks.injectTags.outputClassName.set(generateGradleTokenClass)
}


Expand Down Expand Up @@ -253,7 +187,7 @@ repositories {
maven {
url "https://repo.codemc.io/repository/maven-public/"
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
maven {
name 'Cleanroom Maven'
url 'https://maven.cleanroommc.com'
Expand Down Expand Up @@ -313,8 +247,12 @@ dependencies {
transitive = false
}

shadowImplementation "com.logisticscraft:occlusionculling:${project.occlusionculling_version}"
}

if (getFile('dependencies.gradle').exists()) {
apply from: 'dependencies.gradle'
} else if (getFile('dependencies.gradle.kts').exists()) {
apply from: 'dependencies.gradle.kts'
}

// Resource processing and jar building
Expand Down Expand Up @@ -346,68 +284,6 @@ processResources {
}
}

// Automatically generate a mixin json file if it does not already exist
tasks.register('generateAssets') {
group = 'GT Buildscript'
description = 'Generates a pack.mcmeta, mcmod.info, or mixins.{modid}.json if needed'
doLast {
// pack.mcmeta
def packMcmetaFile = getFile('src/main/resources/pack.mcmeta')
if (!packMcmetaFile.exists()) {
packMcmetaFile.text = """{
"pack": {
"pack_format": 3,
"description": "${modName} Resource Pack"
}
}
"""
}

// mcmod.info
def mcmodInfoFile = getFile('src/main/resources/mcmod.info')
if (!mcmodInfoFile.exists()) {
mcmodInfoFile.text = """[{
"modid": "\${modid}",
"name": "\${modname}",
"description": "An example mod for Minecraft 1.12.2 with Forge",
"version": "\${version}",
"mcversion": "\${mcversion}",
"logoFile": "",
"url": "",
"authorList": [],
"credits": "",
"dependencies": []
}]
"""
}

// mixins.{modid}.json
if (usesMixins.toBoolean() && generateMixinConfig.toBoolean()) {
def mixinConfigFile = getFile("src/main/resources/mixins.${modId}.json")
if (!mixinConfigFile.exists()) {
def mixinConfigRefmap = "mixins.${modId}.refmap.json"

mixinConfigFile.text = """{
"package": "${modGroup}.${mixinsPackage}",
"refmap": "${mixinConfigRefmap}",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
"""
}
}
}
}

tasks.named('processResources').configure {
dependsOn('generateAssets')
}


jar {
manifest {
attributes(getManifestAttributes())
Expand Down Expand Up @@ -473,7 +349,7 @@ def getManifestAttributes() {
if (usesMixins.toBoolean()) {
attributes['ForceLoadAsMod'] = !containsMixinsAndOrCoreModOnly.toBoolean()
}
attributes['FMLCorePlugin'] = "dev.tr7zw.entityculling.EntityCullingEarlyLoader"
attributes['FMLCorePlugin'] = "${coreModClass}"
return attributes
}

Expand Down
3 changes: 3 additions & 0 deletions EntityCulling-Forge/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
shadowImplementation "com.logisticscraft:occlusionculling:${project.occlusionculling_version}"
}
44 changes: 1 addition & 43 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ includeMCVersionJar = true
# The name of your jar when you produce builds, not including any versioning info
modArchivesBaseName = entityculling

# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false

minecraftVersion = 1.12.2

# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
Expand All @@ -42,20 +39,6 @@ minecraftVersion = 1.12.2
# Alternatively this can be set with the 'DEV_USERNAME' environment variable.
developmentEnvironmentUserName = Developer

# Generate a class with String fields for the mod id, name and version named with the fields below
generateGradleTokenClass = com.myname.mymodid.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenVersion = VERSION

# 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.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =

# If you want to keep your API code in src/api instead of src/main
useSrcApiPath = false

# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/
# There can be multiple files in a comma-separated list.
# Example value: mymodid_at.cfg,jei_at.cfg
Expand All @@ -69,28 +52,11 @@ mixinsPackage = dev.tr7zw.entityculling.mixins
generateMixinConfig = false
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
coreModClass = dev.tr7zw.entityculling.EntityCullingEarlyLoader
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod (meaning that
# there is no class annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false

# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false

# Outputs pre-transformed and post-transformed loaded classes to run/CLASSLOADER_TEMP. Can be used in combination with
# diff to see exactly what your ASM or Mixins are changing in the target file.
# Optionally can be specified with the 'CORE_MOD_DEBUG' env var. Will output a lot of files!
enableCoreModDebug = false

# Adds CurseMaven, Modrinth Maven, BlameJared maven, and some more well-known 1.12.2 repositories
includeWellKnownRepositories = true

# Adds JEI and TheOneProbe to your development environment. Adds them as 'implementation', meaning they will
# be available at compiletime and runtime for your mod (in-game and in-code).
# Overrides the above setting to be always true, as these repositories are needed to fetch the mods
includeCommonDevEnvMods = false


# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
Expand All @@ -100,14 +66,6 @@ minimizeShadowedDependencies = false
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Separate run directories into "run/client" for runClient task, and "run/server" for runServer task.
# Useful for debugging a server and client simultaneously. If not enabled, it will be in the standard location "run/"
separateRunDirectories = false

# The display name format of versions published to Curse and Modrinth. $MOD_NAME and $VERSION are available variables.
# Default: $MOD_NAME \u2212 $VERSION. \u2212 is the minus character which looks much better than the hyphen minus on Curse.
versionDisplayFormat = $MOD_NAME \u2212 $VERSION

# Gradle Settings
# Effectively applies the '--stacktrace' flag by default
org.gradle.logging.stacktrace = all
Expand Down

0 comments on commit 918098d

Please sign in to comment.