Commit 9eca984c72ff9a0182c100b37da282df784203fc

Authored by Mumfrey
1 parent ebb3c2be

Update build.gradle for Mixins

Showing 1 changed file with 91 additions and 18 deletions
build.gradle
1 1 buildscript {
2 2 repositories {
  3 + jcenter()
3 4 mavenLocal()
4 5 mavenCentral()
5 6 maven {
... ... @@ -13,38 +14,59 @@ buildscript {
13 14 }
14 15 dependencies {
15 16 classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
  17 + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
16 18 }
17 19 }
18 20  
19 21 apply plugin: 'net.minecraftforge.gradle.tweaker-client'
20 22 apply plugin: 'checkstyle'
21 23 apply plugin: 'maven'
  24 +apply plugin: 'com.github.johnrengelman.shadow'
22 25  
23   -// Artefact details
24   -ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
25   -ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
26   -ext.commit = project.hasProperty("commit") ? commit : 'unknown'
27   -ext.classifier = project.hasProperty("buildType") ? buildType : 'SNAPSHOT'
28   -ext.isReleaseBuild = "RELEASE".equals(project.classifier.toUpperCase())
29   -ext.mavenRepo = project.isReleaseBuild ? "mavenUrl" : "mavenSnapshotUrl"
  26 +ext {
  27 + // Artefact details
  28 + buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
  29 + ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
  30 + commit = project.hasProperty("commit") ? commit : 'unknown'
  31 + classifier = project.hasProperty("buildType") ? buildType : 'SNAPSHOT'
  32 + isReleaseBuild = "RELEASE".equals(project.classifier.toUpperCase())
  33 + mavenRepo = project.isReleaseBuild ? "mavenUrl" : "mavenSnapshotUrl"
  34 +
  35 + // Extended project information
  36 + projectName = 'LiteLoader'
  37 + inceptionYear = '2012'
  38 + packaging = 'jar'
  39 +
  40 + startClass = 'com.mumfrey.liteloader.debug.Start'
  41 + tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
  42 +
  43 + mixinSrg = new File(project.buildDir, 'tmp/mixins.liteloader/mixins.srg')
  44 + mixinRefMap = new File(project.buildDir, "tmp/mixins.liteloader/mixins.liteloader.refmap.json")
  45 +}
30 46  
31 47 // Basic project information
32 48 group = "com.mumfrey"
33 49 archivesBaseName = "liteloader"
34 50 version = buildVersion + (project.isReleaseBuild ? '' : '-' + project.classifier)
35 51  
36   -// Extended project information
37   -ext.projectName = 'LiteLoader'
38   -ext.inceptionYear = '2012'
39   -ext.packaging = 'jar'
40   -
41   -ext.startClass = 'com.mumfrey.liteloader.debug.Start'
42   -ext.tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
43   -
44 52 // Minimum version of Java required
45 53 sourceCompatibility = '1.6'
46 54 targetCompatibility = '1.6'
47 55  
  56 +repositories {
  57 + maven {
  58 + name = 'sponge'
  59 + url = 'https://repo.spongepowered.org/maven/'
  60 + }
  61 +}
  62 +
  63 +dependencies {
  64 + compile('org.spongepowered:mixin:0.4.7-SNAPSHOT') {
  65 + exclude module: 'launchwrapper'
  66 + exclude module: 'guava'
  67 + }
  68 +}
  69 +
48 70 minecraft {
49 71 version = project.mcVersion
50 72 mappings = project.mcMappings
... ... @@ -104,7 +126,29 @@ jar {
104 126 task releaseJar(type: Jar) {
105 127 from sourceSets.main.output
106 128 from sourceSets.client.output
  129 + from project.mixinRefMap
  130 +
  131 + manifest jarManifest
  132 + classifier = 'staging'
  133 +}
  134 +
  135 +shadowJar {
107 136 manifest jarManifest
  137 + dependsOn 'reobfReleaseJar'
  138 +
  139 + from sourceSets.main.output
  140 + from sourceSets.client.output
  141 + from project.mixinRefMap
  142 +
  143 + exclude 'META-INF/*.DSA'
  144 + exclude 'META-INF/*.RSA'
  145 + exclude 'dummyThing'
  146 + exclude 'LICENSE.txt'
  147 +
  148 + dependencies {
  149 + include(dependency('org.spongepowered:mixin'))
  150 + }
  151 +
108 152 classifier = 'release'
109 153 }
110 154  
... ... @@ -122,7 +166,15 @@ task runClient(type: JavaExec, overwrite: true) {
122 166 }
123 167  
124 168 tasks.withType(JavaCompile) {
125   - options.compilerArgs += ['-Xlint:all', '-Xlint:-path', '-Xlint:-rawtypes']
  169 + options.compilerArgs += [
  170 + '-Xlint:all',
  171 + '-Xlint:-path',
  172 + '-Xlint:-rawtypes',
  173 + '-Xlint:-processing',
  174 + "-AoutSrgFile=${project.mixinSrg.canonicalPath}",
  175 + "-AoutRefMapFile=${project.mixinRefMap.canonicalPath}",
  176 + "-AreobfSrgFile=${genSrgs.mcpToNotch.canonicalPath}"
  177 + ]
126 178 options.deprecation = true
127 179 options.encoding = 'utf8'
128 180 }
... ... @@ -141,6 +193,16 @@ reobf {
141 193 releaseJar {
142 194 useNotchSrg()
143 195 classpath = sourceSets.main.compileClasspath
  196 + extraFiles([
  197 + project.mixinSrg
  198 + ])
  199 + }
  200 + shadowJar {
  201 + useNotchSrg()
  202 + classpath = sourceSets.main.compileClasspath
  203 + extraFiles([
  204 + project.mixinSrg
  205 + ])
144 206 }
145 207 }
146 208  
... ... @@ -150,17 +212,28 @@ compileJava.doFirst {
150 212 println '------------------------------------------------------------'
151 213 }
152 214  
153   -build.dependsOn "reobfReleaseJar"
  215 +build.dependsOn {[
  216 + 'reobfReleaseJar',
  217 + 'reobfShadowJar'
  218 + ]
  219 +}
154 220  
155 221 artifacts {
156 222 if (project.isReleaseBuild) {
157 223 archives jar
158 224 }
159   - archives releaseJar
  225 + archives shadowJar
160 226 archives sourceJar
161 227 archives javadocJar
162 228 }
163 229  
  230 +task deploy(type: Copy, dependsOn: build) {
  231 + def libraryDir = new File(new File(System.env.APPDATA), ".minecraft/libraries")
  232 + from shadowJar.outputs.files[0]
  233 + into new File(libraryDir, sprintf('%1$s%4$s%2$s%4$s%3$s', project.group.replace('.', File.separator), archivesBaseName, buildVersion, File.separatorChar))
  234 + rename shadowJar.outputs.files[0].name, sprintf("%s-%s.jar", archivesBaseName, buildVersion)
  235 +}
  236 +
164 237 uploadArchives {
165 238 repositories {
166 239 mavenDeployer {
... ...