Blame view

build.gradle 10.5 KB
Mumfrey authored
1
2
buildscript {
    repositories {
3
        jcenter()
Mumfrey authored
4
5
6
7
8
9
10
11
12
13
        mavenLocal()
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
14
15
16
17
        maven {
            name = 'sponge'
            url = 'http://repo.spongepowered.org/maven'
        }
Mumfrey authored
18
19
    }
    dependencies {
Mumfrey authored
20
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
21
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
Mumfrey authored
22
        classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
Mumfrey authored
23
24
25
26
    }
}

apply plugin: 'net.minecraftforge.gradle.tweaker-client'
27
apply plugin: 'checkstyle'
Mumfrey authored
28
apply plugin: 'maven'
29
apply plugin: 'com.github.johnrengelman.shadow'
30
31
32
33
apply plugin: 'org.spongepowered.mixin'

// Default tasks
defaultTasks 'build'
34
35

ext {
Mumfrey authored
36
37
    def isJenkins = project.hasProperty("jenkins")
38
    // Artefact details
Mumfrey authored
39
    buildNumber = isJenkins ? System.env.BUILD_NUMBER : (project.hasProperty("buildNumber") ? buildNumber : '0')
40
    buildVersion = project.hasProperty("buildVersion") ? buildVersion : '0.0'
41
    ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
Mumfrey authored
42
    commit = isJenkins ? System.env.GIT_COMMIT : (project.hasProperty("commit") ? commit : 'unknown')
43
44
45
    classifier = project.hasProperty("buildType") ? buildType : 'SNAPSHOT'
    isReleaseBuild = "RELEASE".equals(project.classifier.toUpperCase())
    mavenRepo = project.isReleaseBuild ? "mavenUrl" : "mavenSnapshotUrl"
Mumfrey authored
46
    brand = isJenkins ? "${project.mcVersion}-SNAPSHOT-r${System.env.GIT_COMMIT.take(7).toUpperCase()}-b${System.env.BUILD_NUMBER}-${System.env.BUILD_ID}" : ""
47
48
49
50
51
52
53
54
55

    // Extended project information
    projectName = 'LiteLoader'
    inceptionYear = '2012'
    packaging = 'jar'

    startClass = 'com.mumfrey.liteloader.debug.Start'
    tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker'
}
Mumfrey authored
56
57
58
59
60
61
62
63
64
65

// Basic project information
group = "com.mumfrey"
archivesBaseName = "liteloader"
version = buildVersion + (project.isReleaseBuild ? '' : '-' + project.classifier)

// Minimum version of Java required
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
66
67
68
69
70
71
72
73
repositories {
    maven {
        name = 'sponge'
        url = 'https://repo.spongepowered.org/maven/'
    }
}

dependencies {
Mumfrey authored
74
//    compile 'org.ow2.asm:asm-debug-all:5.0.3'
Mumfrey authored
75
    compile('org.spongepowered:mixin:0.5.6-SNAPSHOT') {
Mumfrey authored
76
77
78
79
80
81
82
        exclude module: 'asm-commons'
        exclude module: 'asm-tree'
        exclude module: 'launchwrapper'
        exclude module: 'guava'
    }
//    compile 'com.google.guava:guava:17.0'
//    compile 'com.google.code.gson:gson:2.2.4'
83
84
}
Mumfrey authored
85
86
87
88
89
90
91
92
minecraft {
    version = project.mcVersion
    mappings = project.mcMappings
    runDir = "run"
    tweakClass = project.tweakClass
}

sourceSets {
93
94
95
    main {
        refMap = "mixins.liteloader.core.refmap.json"
    }
Mumfrey authored
96
97
    client {
        compileClasspath += main.compileClasspath + main.output
98
        refMap = "mixins.liteloader.client.refmap.json"
Mumfrey authored
99
100
101
102
103
104
    }
    debug {
        compileClasspath += client.compileClasspath + client.output
    }
}
105
106
107
108
mixin {
    defaultObfuscationEnv notch
}
109
110
checkstyle {
    configProperties = [
111
112
113
114
        "name"        : project.name,
        "organization": project.organization,
        "url"         : project.url,
        "year"        : project.inceptionYear
115
116
117
118
119
    ]
    configFile = file("checkstyle.xml")
    toolVersion = '6.13'
}
Mumfrey authored
120
121
122
123
124
125
javadoc {
    source sourceSets.client.allJava
    source sourceSets.debug.allJava
}

afterEvaluate {
126
127
    logger.lifecycle '================================================='
    logger.lifecycle '  LiteLoader'
128
    logger.lifecycle '  Copyright (C) 2011-2016 Adam Mummery-Smith'
129
130
131
132
133
134
135
136
137
    logger.lifecycle '  Running in {} mode', (project.isReleaseBuild ? "RELEASE" : "SNAPSHOT")
    logger.lifecycle '================================================='

    makeEclipseCleanRunClient {
        arguments = ""
        jvmArguments = "-Dliteloader.debug=true -Dmixin.debug.verbose=true -Dmixin.debug.verify=true"
    }

    // hacks for run configs
Mumfrey authored
138
139
140
141
142
    def mc = plugins.getPlugin 'net.minecraftforge.gradle.tweaker-client'
    mc.replacer.putReplacement '{RUN_CLIENT_MAIN}', project.startClass
    mc.replacer.putReplacement '{RUN_CLIENT_TWEAKER}', minecraft.tweakClass
}
Mumfrey authored
143
144
145
146
147
148
149
150
processResources {
    inputs.property "brand", project.brand
    from (sourceSets.main.resources.srcDirs) {
        include 'liteloader.properties'
        filter { line -> line.startsWith('brand=') ? line + project.brand : line }
    }
}
Mumfrey authored
151
152
153
154
155
156
157
158
159
160
161
162
// manifest entries for all jars
def jarManifest = {
    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
    )
}

jar {
163
164
165
    doFirst {
        // Seriously forge?
        ant.replace(
Mumfrey authored
166
            file: file("${compileJava.temporaryDir}/${sourceSets.main.refMap}"),
167
168
169
170
            token: "func_72355_a(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;)V",
            value: "initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V"
        )
    }
Mumfrey authored
171
172
173
174
175
176
177
178
    from sourceSets.client.output
    from sourceSets.debug.output
    manifest jarManifest
}

task releaseJar(type: Jar) {
    from sourceSets.main.output
    from sourceSets.client.output
179
180
181
182
183
184

    manifest jarManifest
    classifier = 'staging'
}

shadowJar {
Mumfrey authored
185
    manifest jarManifest
186
187
188
189
190
191
192
193
194
195
196
197
198
199
    dependsOn 'reobfReleaseJar'

    from sourceSets.main.output
    from sourceSets.client.output

    exclude 'META-INF/*.DSA'
    exclude 'META-INF/*.RSA'
    exclude 'dummyThing'
    exclude 'LICENSE.txt'

    dependencies {
        include(dependency('org.spongepowered:mixin'))
    }
Mumfrey authored
200
201
202
    classifier = 'release'
}
203
204
205
206
207
208
209
210
sourceJar {
    dependsOn retromapReplacedDebug
    dependsOn retromapReplacedClient

    from zipTree(tasks.retromapReplacedDebug.out)
    from zipTree(tasks.retromapReplacedClient.out)
}
Mumfrey authored
211
212
213
214
215
216
217
218
219
220
221
222
223
224
task javadocJar(type: Jar, dependsOn: javadoc) {
    from javadoc.destinationDir
    classifier = 'javadoc'
}

// Hey @AbrarSyed why can't we just turn this off >:(
task runClient(type: JavaExec, overwrite: true) {
    doFirst {
        println "Do not use runClient, it is not compatible with Mixin"
        System.exit(-1)
    }
}

tasks.withType(JavaCompile) {
225
226
227
228
    options.compilerArgs += [
        '-Xlint:all',
        '-Xlint:-path',
        '-Xlint:-rawtypes',
229
        '-Xlint:-processing'
230
    ]
Mumfrey authored
231
232
233
234
235
236
237
238
239
240
241
242
243
    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')
    }
}

reobf {
    jar {
244
        mappingType = 'SEARGE'
Mumfrey authored
245
246
    }
    releaseJar {
247
        mappingType = 'NOTCH'
Mumfrey authored
248
        classpath = sourceSets.main.compileClasspath
249
250
    }
    shadowJar {
251
        mappingType = 'NOTCH'
252
        classpath = sourceSets.main.compileClasspath
Mumfrey authored
253
254
255
    }
}
256
257
258
build.dependsOn {[
    'reobfReleaseJar',
    'reobfShadowJar'
259
]}
Mumfrey authored
260
261
262
263
264

artifacts {
    if (project.isReleaseBuild) {
        archives jar
    }
265
    archives shadowJar
Mumfrey authored
266
267
268
269
    archives sourceJar
    archives javadocJar
}
270
271
272
task deploy(type: Copy, dependsOn: build) {
    def libraryDir = new File(new File(System.env.APPDATA), ".minecraft/libraries")
    from shadowJar.outputs.files[0]
Mumfrey authored
273
274
    into new File(libraryDir, sprintf('%1$s%4$s%2$s%4$s%3$s', project.group.replace('.', File.separator), archivesBaseName, version, File.separatorChar)) 
    rename shadowJar.outputs.files[0].name, sprintf("%s-%s.jar", archivesBaseName, version)
275
276
}
Mumfrey authored
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
uploadArchives { 
    repositories {
        mavenDeployer {
            if (project.hasProperty(project.mavenRepo)) {
                repository(url: project.getProperty(project.mavenRepo)) {
                    authentication(userName: project.mavenUsername, password: project.mavenPassword)
                }
            }
            pom {
                groupId = project.group
                version = project.version
                artifactId = project.archivesBaseName
                project {
                    name project.archivesBaseName
                    packaging 'jar'
                    description 'LiteLoader'
                    url 'http://www.liteloader.com/'
                    scm {
                        url 'http://develop.liteloader.com/liteloader/LiteLoader'
                        connection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git'
                        developerConnection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git'
                    }
                    issueManagement {
                        system 'GitLab Issues'
                        url 'http://develop.liteloader.com/liteloader/LiteLoader/issues'
                    }
                }
304
305
306
307
308
309
310
311
312
313
314
315
316
317
                if (!project.isReleaseBuild) {
                    whenConfigured {
                        dependencies = dependencies.findAll {
                            !it.artifactId.contains('mixin')
                        }
                    }
                } else {
                    whenConfigured {
                        withXml {
                            def xmlDeps = asNode().get('dependencies').get(0).children().get(0)
                            def exclusion = xmlDeps.appendNode('exclusions').appendNode('exclusion')
                            exclusion.appendNode('groupId', 'net.minecraft')
                            exclusion.appendNode('artifactId', 'launchwrapper')
                        }   
318
319
                    }
                }
Mumfrey authored
320
321
322
323
            }
        }
    }
}
Mumfrey authored
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
if (!project.isReleaseBuild) {
    install.repositories.mavenInstaller.pom {
        whenConfigured {
            dependencies = dependencies.findAll {
                !it.artifactId.contains('mixin')
            }
        }
    }
} else {
    install.repositories.mavenInstaller.pom {
        whenConfigured {
            withXml {
                def xmlDeps = asNode().get('dependencies').get(0).children().get(0)
                def exclusion = xmlDeps.appendNode('exclusions').appendNode('exclusion')
                exclusion.appendNode('groupId', 'net.minecraft')
                exclusion.appendNode('artifactId', 'launchwrapper')
            }
342
343
344
        }
    }
}
345