mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-24 03:34:30 +00:00
# Conflicts: # build.gradle # gradle.properties # src/ap/java/org/spongepowered/tools/obfuscation/AnnotatedMixins.java # src/main/java/org/spongepowered/asm/mixin/transformer/MixinConfig.java
481 lines
14 KiB
Groovy
481 lines
14 KiB
Groovy
// Gradle repositories and dependencies
|
|
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
dependencies {
|
|
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
|
|
}
|
|
}
|
|
|
|
// Apply plugin
|
|
apply plugin: 'java'
|
|
apply plugin: 'license'
|
|
apply plugin: 'checkstyle'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'idea'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
// Default tasks
|
|
defaultTasks 'licenseFormat', 'check', 'build'
|
|
|
|
// Basic project information
|
|
group = 'net.fabricmc'
|
|
archivesBaseName = 'sponge-mixin'
|
|
version = buildVersion + "+mixin." + upstreamMixinVersion
|
|
|
|
|
|
def ENV = System.getenv()
|
|
if (!ENV.CI) {
|
|
version = version + "-local"
|
|
}
|
|
|
|
// Extended project information
|
|
ext.projectName = 'Mixin'
|
|
ext.inceptionYear = '2014'
|
|
ext.packaging = 'jar'
|
|
|
|
// Define variables
|
|
ext.asmVersion = project.hasProperty("asmVersion") ? asmVersion : '9.0'
|
|
ext.legacyForgeAsmVersion = project.hasProperty("legacyForgeAsmVersion") ? asmVersion : '5.0.3'
|
|
|
|
// True to do jar signing task
|
|
ext.doSignJar = project.hasProperty("keyStorePath")
|
|
|
|
// Minimum version of Java required
|
|
sourceCompatibility = '1.8'
|
|
targetCompatibility = '1.8'
|
|
|
|
// Project repositories
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
name = 'minecraft'
|
|
url = 'https://libraries.minecraft.net/'
|
|
}
|
|
maven {
|
|
name = 'fabric'
|
|
url = 'http://maven.fabricmc.net/'
|
|
}
|
|
maven {
|
|
// For modlauncher
|
|
name = 'forge'
|
|
url = 'https://files.minecraftforge.net/maven'
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
thinJar
|
|
stagingJar
|
|
}
|
|
|
|
// Include annotation processor sourceSet
|
|
sourceSets {
|
|
legacy
|
|
main {
|
|
compileClasspath += legacy.output
|
|
}
|
|
ap {
|
|
compileClasspath += main.output
|
|
}
|
|
fernflower {
|
|
compileClasspath += main.output
|
|
}
|
|
agent {
|
|
compileClasspath += main.output
|
|
}
|
|
bridge {
|
|
compileClasspath += main.output
|
|
}
|
|
example {
|
|
compileClasspath += main.output
|
|
compileClasspath += ap.output
|
|
}
|
|
launchwrapper {
|
|
compileClasspath += main.output
|
|
}
|
|
modlauncher {
|
|
compileClasspath += main.output
|
|
}
|
|
}
|
|
|
|
// Project dependencies
|
|
dependencies {
|
|
def guava = 'com.google.guava:guava:21.0' // from mc1.12 onwards
|
|
def log4j2 = 'org.apache.logging.log4j:log4j-core:2.0-beta9'
|
|
|
|
compile guava
|
|
compile log4j2
|
|
compile 'com.google.code.gson:gson:2.2.4'
|
|
if (Float.parseFloat(asmVersion) < 6) {
|
|
compile "org.ow2.asm:asm-debug-all:$asmVersion"
|
|
}
|
|
implementation "org.ow2.asm:asm-tree:$asmVersion"
|
|
implementation "org.ow2.asm:asm-commons:$asmVersion"
|
|
implementation "org.ow2.asm:asm-util:$asmVersion"
|
|
|
|
thinJar "org.ow2.asm:asm-tree:$asmVersion"
|
|
thinJar "org.ow2.asm:asm-util:$asmVersion"
|
|
|
|
// Tests
|
|
// testCompile 'junit:junit:4.11'
|
|
// testCompile 'org.hamcrest:hamcrest-library:1.3'
|
|
// testCompile 'org.mockito:mockito-core:1.9.0'
|
|
|
|
// Annotation Processor
|
|
apCompile "org.ow2.asm:asm-tree:$asmVersion"
|
|
apCompile guava
|
|
|
|
// AP extension example
|
|
exampleCompile configurations.compile
|
|
exampleImplementation configurations.implementation
|
|
|
|
// Fernflower decompiler
|
|
fernflowerCompile configurations.compile
|
|
fernflowerImplementation configurations.implementation
|
|
fernflowerCompile 'org.jetbrains:intellij-fernflower:1.0.0.9'
|
|
|
|
// LegacyLauncher service
|
|
launchwrapperCompile configurations.compile
|
|
launchwrapperImplementation configurations.implementation
|
|
launchwrapperCompile ('net.minecraft:launchwrapper:1.11') {
|
|
exclude module: 'lwjgl'
|
|
}
|
|
|
|
modlauncherCompile configurations.compile
|
|
modlauncherImplementation configurations.implementation
|
|
modlauncherCompile 'net.sf.jopt-simple:jopt-simple:5.0.4'
|
|
modlauncherCompile "org.ow2.asm:asm-tree:$modlauncherAsmVersion"
|
|
modlauncherCompile "org.ow2.asm:asm-commons:$modlauncherAsmVersion"
|
|
modlauncherCompile "org.ow2.asm:asm-util:$modlauncherAsmVersion"
|
|
modlauncherCompile ("cpw.mods:modlauncher:$modlauncherVersion") {
|
|
exclude module: 'log4j-core'
|
|
}
|
|
modlauncherCompile 'cpw.mods:grossjava9hacks:1.3.+'
|
|
|
|
// agent
|
|
agentCompile configurations.compile
|
|
agentImplementation configurations.implementation
|
|
|
|
// asm bridge
|
|
bridgeCompile log4j2
|
|
bridgeCompile "org.ow2.asm:asm-commons:$legacyForgeAsmVersion"
|
|
|
|
legacyCompile "org.ow2.asm:asm-tree:$asmVersion"
|
|
}
|
|
|
|
javadoc {
|
|
exclude '**/throwables'
|
|
classpath += sourceSets.legacy.output
|
|
source sourceSets.ap.allJava
|
|
options.encoding = 'UTF-8'
|
|
exclude {
|
|
it.relativePath.file && it.relativePath.pathString =~ 'tools' && !(it.name =~ /SuppressedBy|package-info/) }
|
|
options {
|
|
docTitle 'Welcome to the Mixin Javadoc'
|
|
overview 'docs/javadoc/overview.html'
|
|
stylesheetFile file('docs/javadoc/mixin.css')
|
|
addBooleanOption '-allow-script-in-comments', true
|
|
}
|
|
doLast {
|
|
copy {
|
|
from 'docs/javadoc/resources'
|
|
into outputDirectory
|
|
}
|
|
}
|
|
}
|
|
|
|
// Eclipse
|
|
eclipse.classpath.plusConfigurations += [
|
|
configurations.fernflowerCompile,
|
|
configurations.launchwrapperCompile,
|
|
configurations.modlauncherCompile,
|
|
configurations.bridgeCompile
|
|
]
|
|
|
|
// IntelliJ
|
|
idea.module.scopes.COMPILE.plus += [
|
|
configurations.fernflowerCompile,
|
|
configurations.launchwrapperCompile,
|
|
configurations.modlauncherCompile,
|
|
configurations.bridgeCompile
|
|
]
|
|
|
|
// Filter, process, and include resources
|
|
processResources {
|
|
// Include in final JAR
|
|
from 'LICENSE.txt'
|
|
}
|
|
|
|
// License header formatting
|
|
license {
|
|
ext {
|
|
name = "Mixin"
|
|
organization = "SpongePowered"
|
|
url = "https://www.spongepowered.org"
|
|
}
|
|
include '**/*.java'
|
|
header file("HEADER.txt")
|
|
sourceSets = project.sourceSets
|
|
ignoreFailures false
|
|
strictCheck true
|
|
mapping {
|
|
java = 'SLASHSTAR_STYLE'
|
|
}
|
|
}
|
|
|
|
checkstyle {
|
|
configProperties = [
|
|
"name" : project.name,
|
|
"organization": project.organization,
|
|
"url" : project.url,
|
|
"year" : project.inceptionYear
|
|
]
|
|
configFile = file("checkstyle.xml")
|
|
toolVersion = '8.36.1'
|
|
}
|
|
|
|
// Source compiler configuration
|
|
tasks.withType(JavaCompile) {
|
|
options.compilerArgs += ['-Xlint:all', '-Xlint:-path', '-proc:none']
|
|
options.deprecation = true
|
|
options.encoding = 'utf8'
|
|
if (JavaVersion.current().isJava9Compatible()) {
|
|
options.release = 8
|
|
}
|
|
}
|
|
|
|
if (JavaVersion.current().isJava8Compatible()) {
|
|
tasks.withType(Javadoc) {
|
|
// disable the crazy super-strict doclint tool in Java 8
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
}
|
|
}
|
|
|
|
task stagingJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
|
|
sourceSets.each {
|
|
if (it.name != 'example') {
|
|
from it.output
|
|
}
|
|
}
|
|
|
|
configurations = [project.configurations.stagingJar]
|
|
|
|
// JAR manifest configuration
|
|
manifest.attributes(
|
|
"Built-By": System.properties['user.name'],
|
|
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
|
|
"Implementation-Title": name,
|
|
"Implementation-Version": version,
|
|
"Implementation-Vendor": url,
|
|
// for hotswap agent
|
|
"Premain-Class": "org.spongepowered.tools.agent.MixinAgent",
|
|
"Agent-Class": "org.spongepowered.tools.agent.MixinAgent",
|
|
"Can-Redefine-Classes": true,
|
|
"Can-Retransform-Classes": true
|
|
)
|
|
|
|
if (project.doSignJar) {
|
|
classifier = 'unsigned'
|
|
}
|
|
|
|
mergeServiceFiles()
|
|
}
|
|
|
|
// Clear artifacts because jar will be there by default and we want to use staging jar instead
|
|
configurations.archives.artifacts.clear()
|
|
|
|
task thinJar(type: Jar) {
|
|
from sourceSets.main.output
|
|
// from { configurations.thinJar.collect { zipTree(it) }
|
|
baseName = 'sponge-mixin-runtime'
|
|
classifier = ''
|
|
|
|
exclude 'org/spongepowered/asm/launch/**'
|
|
exclude 'org/spongepowered/asm/mixin/injection/invoke/**'
|
|
exclude 'org/spongepowered/asm/mixin/transformer/*.class'
|
|
exclude 'org/spongepowered/asm/mixin/transformer/debug/**'
|
|
exclude 'org/spongepowered/asm/mixin/transformer/verify/**'
|
|
|
|
manifest.mainAttributes(
|
|
"Built-By": System.properties['user.name'],
|
|
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
|
|
"Implementation-Title": name,
|
|
"Implementation-Version": version,
|
|
"Implementation-Vendor": url,
|
|
)
|
|
}
|
|
build.dependsOn(thinJar)
|
|
|
|
// generate shadow jar so we can use the AP standalone
|
|
shadowJar {
|
|
from sourceSets.ap.output
|
|
exclude 'META-INF/*.DSA'
|
|
exclude 'META-INF/*.RSA'
|
|
classifier = 'processor'
|
|
}
|
|
build.dependsOn(shadowJar)
|
|
|
|
if (project.doSignJar) {
|
|
// Define signjar task
|
|
task signJar() {
|
|
inputs.files(stagingJar.outputs)
|
|
outputs.files stagingJar.outputs.files.collect {
|
|
new File(it.parent, it.name.replace('-unsigned', ''))
|
|
}
|
|
doLast {
|
|
stagingJar.outputs.files.each {
|
|
ant.signjar(
|
|
alias: project.keyStoreCert,
|
|
jar: it,
|
|
signedJar: new File(it.parent, it.name.replace('-unsigned', '')),
|
|
keystore: project.keyStorePath,
|
|
storepass: project.keyStoreSecret,
|
|
keypass: project.keyStoreSecret,
|
|
tsaurl: project.timestampAuthority,
|
|
preservelastmodified: 'true',
|
|
verbose: true
|
|
)
|
|
}
|
|
}
|
|
}
|
|
build.dependsOn(signJar)
|
|
}
|
|
|
|
// Run this task instead of build to generate a timestamped shadow jar (for dev)
|
|
task timestamp(type: Jar, dependsOn: build) {
|
|
if (gradle.startParameter.taskNames.contains(name)) {
|
|
shadowJar.classifier = new Date().format('yyyyMMddHHmmss')
|
|
}
|
|
}
|
|
|
|
task sourceJar(type: Jar) {
|
|
sourceSets.each {
|
|
from it.java
|
|
from it.resources
|
|
}
|
|
classifier = "sources"
|
|
}
|
|
|
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
from javadoc.destinationDir
|
|
classifier = "javadoc"
|
|
}
|
|
|
|
artifacts {
|
|
if (project.doSignJar) {
|
|
archives signJar.outputs.files[0]
|
|
} else {
|
|
archives stagingJar
|
|
}
|
|
archives thinJar
|
|
archives sourceJar
|
|
archives javadocJar
|
|
archives shadowJar
|
|
}
|
|
|
|
ext.excludePomDeps = [
|
|
'fernflower',
|
|
'jarjar',
|
|
'hamcrest-library',
|
|
'junit',
|
|
'mockito-core',
|
|
'mixin-asm-debug-all',
|
|
'log4j-core'
|
|
]
|
|
|
|
publishing {
|
|
publications {
|
|
developer(MavenPublication) { publication ->
|
|
groupId project.group
|
|
artifactId project.archivesBaseName
|
|
version project.version
|
|
|
|
artifact stagingJar
|
|
artifact sourceJar
|
|
artifact javadocJar
|
|
|
|
// https://issues.gradle.org/browse/GRADLE-2966
|
|
pom.withXml {
|
|
def dependenciesNode = asNode().appendNode('dependencies')
|
|
|
|
configurations.runtime.allDependencies.each {
|
|
if (it.group != null && it.name != null && !excludePomDeps.contains(it.name)) {
|
|
def dependencyNode = dependenciesNode.appendNode('dependency')
|
|
dependencyNode.appendNode('groupId', it.group)
|
|
dependencyNode.appendNode('artifactId', it.name)
|
|
dependencyNode.appendNode('version', it.version)
|
|
|
|
if (it.excludeRules.size() > 0) {
|
|
def exclusionsNode = dependencyNode.appendNode('exclusions')
|
|
it.excludeRules.each { rule ->
|
|
def exclusionNode = exclusionsNode.appendNode('exclusion')
|
|
exclusionNode.appendNode('groupId', rule.group)
|
|
exclusionNode.appendNode('artifactId', rule.module)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
runtime(MavenPublication) { publication ->
|
|
groupId project.group
|
|
artifactId "sponge-mixin-runtime"
|
|
version project.version
|
|
|
|
artifact thinJar
|
|
|
|
// https://issues.gradle.org/browse/GRADLE-2966
|
|
pom.withXml {
|
|
def dependenciesNode = asNode().appendNode('dependencies')
|
|
|
|
configurations.runtime.allDependencies.each {
|
|
if (it.group != null && it.name != null && !excludePomDeps.contains(it.name)) {
|
|
def dependencyNode = dependenciesNode.appendNode('dependency')
|
|
dependencyNode.appendNode('groupId', it.group)
|
|
dependencyNode.appendNode('artifactId', it.name)
|
|
dependencyNode.appendNode('version', it.version)
|
|
|
|
if (it.excludeRules.size() > 0) {
|
|
def exclusionsNode = dependencyNode.appendNode('exclusions')
|
|
it.excludeRules.each { rule ->
|
|
def exclusionNode = exclusionsNode.appendNode('exclusion')
|
|
exclusionNode.appendNode('groupId', rule.group)
|
|
exclusionNode.appendNode('artifactId', rule.module)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
if (ENV.MAVEN_URL) {
|
|
maven {
|
|
url ENV.MAVEN_URL
|
|
credentials {
|
|
username ENV.MAVEN_USERNAME
|
|
password ENV.MAVEN_PASSWORD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// A task to ensure that the version being released has not already been released.
|
|
task checkVersion {
|
|
doFirst {
|
|
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/sponge-mixin/maven-metadata.xml").text
|
|
def metadata = new XmlSlurper().parseText(xml)
|
|
def versions = metadata.versioning.versions.version*.text();
|
|
if (versions.contains(version)) {
|
|
throw new RuntimeException("${version} has already been released!")
|
|
}
|
|
}
|
|
}
|
|
|
|
publish.mustRunAfter checkVersion |