ViaForge/build.gradle
xcfrg b1c239fdbb
🛠 Forgegradle 5 & Gradle 7 Upgrade
- Use the latest forgegradle available, forgegradle 5
- Update mixins
- Remove the terrible libs folder and grab libs from repos
- Rewrite build.gradle, settings.gradle, gradle.properties to support forgegradle 5
- Upgraded to gradle 7.2
- Use DefaultEventLoopGroup instead of LocalEventLoopGroup, as the latter is deprecated
- Both dev environment and building have been tested
2021-08-31 19:12:30 -04:00

180 lines
7.1 KiB
Groovy

plugins {
id "java"
id "idea"
id "maven-publish"
id "net.minecraftforge.gradle" version "5.1.+"
id "org.spongepowered.mixin" version "0.7-SNAPSHOT"
id "com.github.johnrengelman.shadow" version "7.0.0"
}
version = "${minecraft_version}-${mod_version}"
group = "${mod_base_package}.${mod_id}"
archivesBaseName = mod_id
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
compileJava.options.encoding = "UTF-8"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly.
// stable # Stables are built at the discretion of the MCP team.
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVer Javadocs and parameters layered on top of Mojmaps from the ParchmentMC team.
//
// You must be aware of the Mojang license when using the 'official' / 'parchment' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mappings_channel, version: mappings_version
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file("run")
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
property "forge.logging.console.level", "debug"
// mixin
property 'mixin.debug.export', 'true'
property "mixin.hotSwap", "true"
property "fml.coreMods.load", "de.enzaxd.viaforge.injection.MixinLoader"
// These arguments allow for optional authentication with Mojang servers.
// If you want to authenticate, put these properties in GRADLE_HOME/gradle.properties.
// By default, this is C:\Users\<your username>\.gradle\gradle.properties on Windows or ~/.gradle/gradle.properties on Linux/MacOS.
if (project.hasProperty('mc_uuid')) {
// Your UUID, trimmed / without the dashes
args '--uuid', project.getProperty('mc_uuid')
}
if (project.hasProperty('mc_username')) {
// Your Minecraft in-game username, not email
args '--username', project.getProperty('mc_username')
}
if (project.hasProperty('mc_accessToken')) {
// Your current access token. When it expires, you need to retrieve a new one and regenerate your run configurations.
// You may be able to find it in your .minecraft folder in launcher_accounts.json or launcher_profiles.json.
args '--accessToken', project.getProperty('mc_accessToken')
}
args '-mixin.config=' + 'mixins.' + project.getProperty('mod_id') + '.json'
mods {
"${mod_id}" {
source sourceSets.main
}
}
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven { url = "https://repo.spongepowered.org/repository/maven-public" }
maven { url = "https://repo.viaversion.com" }
}
configurations {
include
implementation.extendsFrom(include)
}
dependencies {
// Specify the version of Minecraft to use, If this is any group other then "net.minecraft" it is assumed
// that the dep is a ForgeGradle "patcher" dependency. And it"s patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile "com.mod-buildcraft:buildcraft:6.0.8:dev" // adds buildcraft to the dev env
// compile "com.googlecode.efficient-java-matrix-library:ejml:0.24" // adds ejml to the dev env
// The "provided" configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided "com.mod-buildcraft:buildcraft:6.0.8:dev"
// These dependencies get remapped to your current MCP mappings
// deobf "com.mod-buildcraft:buildcraft:6.0.8:dev"
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
include "org.spongepowered:mixin:${mixin_version}"
include "com.viaversion:viaversion:4.0.2-SNAPSHOT"
include "com.viaversion:viabackwards:4.0.2-SNAPSHOT"
include "org.yaml:snakeyaml:1.29"
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
}
mixin {
add sourceSets.main, "mixins.${mod_id}.refmap.json"
}
jar {
manifest.attributes(
"Specification-Title": "viaforge",
"Specification-Vendor": "viaforge",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${archiveVersion}",
"Implementation-Vendor" :"viaforge",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd"-"HH:mm:ssZ"),
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": "0",
"FMLCorePluginContainsFMLMod": "de.enzaxd.viaforge.injection.MixinLoader",
"MixinConfigs": "mixins.${mod_id}.json"
)
enabled = false
}
shadowJar {
archiveFileName = jar.archiveFileName
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations = [project.configurations.include]
exclude "LICENSE.md"
exclude "dummyThing"
exclude "**/module-info.class"
exclude "*.so"
exclude "*.dylib"
exclude "*.dll"
exclude "*.jnilib"
exclude "ibxm/**"
exclude "com/jcraft/**"
exclude "org/lwjgl/**"
exclude "net/java/**"
exclude "META-INF/proguard/**"
exclude "META-INF/maven/**"
exclude "META-INF/versions/**"
exclude "META-INF/com.android.tools/**"
exclude "fabric.mod.json"
exclude "bungee.yml"
exclude "plugin.yml"
exclude "velocity-plugin.json"
exclude "LICENSE.txt"
}
reobf {
shadowJar {}
}
jar.dependsOn("shadowJar")