Untitled
unknown
java
2 years ago
5.3 kB
12
Indexable
import net.minecraftforge.gradle.delayed.DelayedFile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
//import org.gradle.api.internal.file.copy.DefaultFileCopyDetails
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.1.+') {
changing = true
}
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'forge'
version = "1.0"
group = "com.example.mod"
archivesBaseName = "ExampleMod"
targetCompatibility = sourceCompatibility = JavaVersion.VERSION_1_8
ext.dependenciesPath = System.getenv("GITHUB_ACTIONS") != null ? "../Dependencies" : '../../Dependencies';
ext.joinedAnnotationProcessor = resources.text.fromString("""com.llamalad7.mixinextras.ap.MixinExtrasAP
org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection
org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets""").asFile();
minecraft {
mappingsVersion = 12
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "idea"
}
configurations {
shadowMixins
implementation.extendsFrom shadowMixins
//shadow
//implementation.extendsFrom shadow
}
dependencies {
// Main
shadow files(dependenciesPath + '/mixinextras-common-0.2.0-rc.4.jar')
// Mixins
shadowMixins 'com.google.guava:guava:21.0'
shadowMixins 'com.google.code.gson:gson:2.2.4'
shadowMixins 'org.ow2.asm:asm-tree:9.5'
shadowMixins 'org.ow2.asm:asm-commons:9.5'
shadowMixins 'org.ow2.asm:asm-util:9.5'
shadowMixins files(dependenciesPath + '/mixin-0.8.5.jar')
}
shadowJar {
configurations = [project.configurations.shadow]
destinationDirectory = file 'build/tmp'
classifier = 'main'
// Mixins extras
relocate 'com.llamalad7.mixinextras', 'com.example.mod.mixinextras'
}
task shadowJarMixins(type: ShadowJar) {
configurations = [project.configurations.shadowMixins]
classifier = ''
// Mixins
relocate 'org.objectweb.asm', 'org.spongepowered.asm.lib'
relocate 'com.google', 'org.spongepowered.libraries.com.google'
// Exclude stuff that's compiled for Java 16
exclude 'org/spongepowered/asm/service/modlauncher/*'
exclude 'org/spongepowered/asm/launch/MixinTransformationServiceLegacy*'
exclude 'org/spongepowered/asm/launch/MixinLaunchPlugin*'
exclude 'org/spongepowered/asm/launch/MixinTransformationService*'
exclude 'org/spongepowered/asm/launch/platform/container/ContainerHandleModLauncherEx*'
exclude 'META-INF/services/cpw.mods.modlauncher.api.ITransformationService'
exclude 'META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService'
// Exclude annotation processor config (we need combine configs from MixinExtras and Mixins)
exclude 'META-INF/services/javax.annotation.processing.Processor'
// Exclude additional files
exclude '**/module-info.class'
exclude 'META-INF/MANIFEST.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF', 'CREDITS', 'LICENSE*', 'README*'
from fileTree('build') {
include 'mixins/mixins.examplemod.refmap.json'
}
from (sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version, 'mcversion': project.minecraft.version
}
from (joinedAnnotationProcessor) {
into 'META-INF/services'
rename {
'javax.annotation.processing.Processor'
}
}
from zipTree(shadowJar.archivePath)
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
enabled = false
dependsOn shadowJar
dependsOn shadowJarMixins
manifest {
attributes(
'Class-Path': ''
// Put manifest attributes here, example
// 'FMLCorePluginContainsFMLMod': 'true',
)
}
}
// Mixin stuff
ext {
new File(project.buildDir, 'mixins').mkdirs();
mixinSrg = new File(project.buildDir, 'mixins/mixins.examplemod.srg')
mixinSrg.createNewFile()
mixinRefMap = new File(project.buildDir, "mixins/mixins.examplemod.refmap.json")
mixinRefMap.createNewFile()
}
reobf {
addExtraSrgFile project.mixinSrg
}
compileJava {
options.encoding = "UTF-8"
options.compilerArgs += [
'-Xlint:-processing',
"-AoutSrgFile=${project.mixinSrg.canonicalPath}",
"-AoutRefMapFile=${project.mixinRefMap.canonicalPath}",
"-AreobfSrgFile=${project.file('build/srgs/mcp-srg.srg').canonicalPath}"
]
}
task copySrgs(type: Copy, dependsOn: 'genSrgs') {
from new DelayedFile(project, '{SRG_DIR}', plugins.getPlugin("forge"))
include '**/*.srg'
into 'build/srgs'
}
compileJava.dependsOn copySrgs
//Editor is loading...