232 lines
8.2 KiB
Groovy
232 lines
8.2 KiB
Groovy
buildscript {
|
|
repositories {
|
|
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'eclipse'
|
|
id 'idea'
|
|
id 'maven-publish'
|
|
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
|
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
|
id 'org.spongepowered.mixin' version '0.7.+'
|
|
id 'com.diffplug.spotless' version '7.0.2'
|
|
}
|
|
|
|
apply from: "$rootDir/gradle/scripts/spotless.gradle"
|
|
apply plugin: 'org.spongepowered.mixin'
|
|
|
|
version = mod_version
|
|
group = mod_group_id
|
|
|
|
base {
|
|
archivesName = mod_id
|
|
}
|
|
|
|
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
|
|
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
|
minecraft {
|
|
mappings channel: mapping_channel, version: mapping_version
|
|
|
|
copyIdeResources = true
|
|
runs {
|
|
// applies to all the run configs below
|
|
configureEach {
|
|
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
|
|
// You can set various levels here.
|
|
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
|
property 'forge.logging.console.level', 'debug'
|
|
property 'mixin.env.remapRefMap', 'true'
|
|
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
|
|
mods {
|
|
"${mod_id}" {
|
|
source sourceSets.main
|
|
}
|
|
}
|
|
}
|
|
|
|
client {
|
|
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
|
property 'forge.enabledGameTestNamespaces', mod_id
|
|
jvmArgs += [
|
|
"-Dmixin.debug.export=true", "-Dmixin.debug.verbose=true","-Dmixin.dumpTargetOnFailure=true"
|
|
]
|
|
|
|
// arg "-mixin.config=${mod_id}.mixin.json"
|
|
|
|
}
|
|
|
|
server {
|
|
property 'forge.enabledGameTestNamespaces', mod_id
|
|
// arg "-mixin.config=${mod_id}.mixin.json"
|
|
args '--nogui'
|
|
}
|
|
|
|
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
|
// By default, the server will crash when no gametests are provided.
|
|
// The gametest system is also enabled by default for other run configs under the /test command.
|
|
gameTestServer {
|
|
property 'forge.enabledGameTestNamespaces', mod_id
|
|
}
|
|
|
|
data {
|
|
// example of overriding the workingDirectory set in configureEach above
|
|
workingDirectory project.file('run-data')
|
|
|
|
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
|
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
|
}
|
|
}
|
|
}
|
|
|
|
// Include resources generated by data generators.
|
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
|
|
maven { // JEI mirror, AE2
|
|
name = "ModMaven"
|
|
url = "https://modmaven.dev"
|
|
}
|
|
|
|
maven { url = "https://api.modrinth.com/maven" }
|
|
|
|
maven {
|
|
name = 'GTCEu Maven'
|
|
url = 'https://maven.gtceu.com'
|
|
content {
|
|
includeGroup 'com.gregtechceu.gtceu'
|
|
}
|
|
}
|
|
|
|
maven {
|
|
name = 'GeckoLib'
|
|
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
|
|
content {
|
|
includeGroupByRegex("software\\.bernie.*")
|
|
includeGroup("com.eliotlash.mclib")
|
|
}
|
|
}
|
|
|
|
maven { // LDLib, Shimmer
|
|
name = "FirstDarkDev Maven"
|
|
url = "https://maven.firstdarkdev.xyz/snapshots"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
|
|
|
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
|
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
|
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
|
|
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
|
|
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
|
|
|
|
// For more info:
|
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
|
|
|
|
|
compileOnly "org.projectlombok:lombok:${lombok_version}"
|
|
annotationProcessor "org.projectlombok:lombok:${lombok_version}"
|
|
|
|
annotationProcessor "org.spongepowered:mixin:${mixin_processor_version}:processor"
|
|
testAnnotationProcessor "org.spongepowered:mixin:${mixin_processor_version}:processor"
|
|
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}"))
|
|
implementation(jarJar("io.github.llamalad7:mixinextras-forge:${mixinextras_version}")) {
|
|
jarJar.ranged(it, "[${mixinextras_version},)")
|
|
}
|
|
|
|
implementation fg.deobf("com.lowdragmc.ldlib:ldlib-forge-${minecraft_version}:${ldlib_version}") { transitive = false }
|
|
implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${minecraft_version}:${gtm_version}") {transitive = false}
|
|
|
|
implementation fg.deobf("software.bernie.geckolib:geckolib-forge-${minecraft_version}:${geckolib_version}")
|
|
implementation("com.eliotlash.mclib:mclib:${mclib_version}")
|
|
|
|
implementation fg.deobf("maven.modrinth:jade:${jade_version}")
|
|
}
|
|
|
|
mixin {
|
|
add sourceSets.main, "ibg.refmap.json"
|
|
config "ibg.mixin.json"
|
|
}
|
|
|
|
tasks.named('processResources', ProcessResources).configure {
|
|
var replaceProperties = [
|
|
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
|
forge_version: forge_version, forge_version_range: forge_version_range,
|
|
loader_version_range: loader_version_range,
|
|
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
|
mod_authors: mod_authors, mod_description: mod_description,
|
|
gtm_version: gtm_version, geckolib_version: geckolib_version,
|
|
]
|
|
inputs.properties replaceProperties
|
|
|
|
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
|
expand replaceProperties + [project: project]
|
|
}
|
|
}
|
|
|
|
// Example for how to get properties into the manifest for reading at runtime.
|
|
tasks.named('jar', Jar).configure {
|
|
manifest {
|
|
attributes([
|
|
'Specification-Title' : mod_id,
|
|
'Specification-Vendor' : mod_authors,
|
|
'Specification-Version' : '1', // We are version 1 of ourselves
|
|
'Implementation-Title' : project.name,
|
|
'Implementation-Version' : project.jar.archiveVersion,
|
|
'Implementation-Vendor' : mod_authors,
|
|
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
])
|
|
}
|
|
|
|
// This is the preferred method to reobfuscate your jar file
|
|
finalizedBy 'reobfJar'
|
|
}
|
|
|
|
tasks.named('build') {
|
|
dependsOn tasks.named('spotlessApply')
|
|
}
|
|
|
|
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
|
|
// tasks.named('publish').configure {
|
|
// dependsOn 'reobfJar'
|
|
// }
|
|
|
|
// Example configuration to allow publishing using the maven-publish plugin
|
|
publishing {
|
|
publications {
|
|
register('mavenJava', MavenPublication) {
|
|
artifact jar
|
|
}
|
|
}
|
|
repositories {
|
|
maven {
|
|
url "file://${project.projectDir}/mcmodsrepo"
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
|
}
|
|
|
|
task showMeCache doLast() {
|
|
configurations.compileClasspath.each { println it }
|
|
}
|