Files
UniMix/build.gradle
T
modmuss50 ed1a103051 Merge remote-tracking branch 'remotes/upstream/0.8' into fabric-0.8
# Conflicts:
#	build.gradle
#	src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java
2019-10-11 20:58:42 +01:00

416 lines
12 KiB
Groovy

// Gradle repositories and dependencies
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
}
}
// Apply plugin
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
// Default tasks
defaultTasks 'build'
// Basic project information
group = 'net.fabricmc'
archivesBaseName = 'sponge-mixin'
version = buildVersion
ext.buildNumber = '0'
def ENV = System.getenv()
if (ENV.BUILD_NUMBER) {
version = version + "." + "${ENV.BUILD_NUMBER}"
ext.buildNumber = "${ENV.BUILD_NUMBER}"
}
// Extended project information
ext.projectName = 'Mixin'
ext.inceptionYear = '2014'
ext.packaging = 'jar'
// Define variables
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
ext.asmVersion = project.hasProperty("asmVersion") ? asmVersion : '6.2'
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.6'
targetCompatibility = '1.6'
// 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
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
// 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"
}
compile "org.ow2.asm:asm-tree:$asmVersion"
compile "org.ow2.asm:asm-commons:$asmVersion"
compile "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
// Fernflower decompiler
fernflowerCompile configurations.compile
fernflowerCompile 'org.jetbrains:intellij-fernflower:1.0.0.9'
// LegacyLauncher service
launchwrapperCompile configurations.compile
launchwrapperCompile ('net.minecraft:launchwrapper:1.11') {
exclude module: 'lwjgl'
}
modlauncherCompile configurations.compile
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:4.0.0') {
exclude module: 'log4j-core'
}
// agent
agentCompile configurations.compile
// asm bridge
bridgeCompile log4j2
bridgeCompile "org.ow2.asm:asm-commons:$legacyForgeAsmVersion"
legacyCompile "org.ow2.asm:asm-tree:$asmVersion"
}
javadoc {
classpath += sourceSets.legacy.output // why?
options.encoding = 'UTF-8'
}
// 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'
}
// Source compiler configuration
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-path', '-proc:none']
options.deprecation = true
options.encoding = 'utf8'
}
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 + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"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 + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"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(jar.outputs)
outputs.files jar.outputs.files.collect {
new File(it.parent, it.name.replace('-unsigned', ''))
}
doLast {
jar.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'
)
}
}
}
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
}
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 {
maven {
url "http://mavenupload.modmuss50.me/"
if (project.hasProperty('mavenPass')) {
credentials {
username 'buildslave'
password project.getProperty('mavenPass')
}
}
}
}
}