forked from SpongePowered/SpongeForge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
305 lines (265 loc) · 8.88 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
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
304
305
// Gradle repositories and dependencies
buildscript {
repositories {
mavenCentral()
maven {
name = 'sonatype-nexus-public'
url = 'https://oss.sonatype.org/content/repositories/public/'
}
maven {
name = 'forge-repo'
url = 'http://files.minecraftforge.net/maven/'
}
jcenter()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
}
}
// for multiproject fun
evaluationDependsOn('Mixin')
evaluationDependsOn('SpongeAPI')
// Default tasks
defaultTasks 'build', 'licenseFormat'
// Apply plugin
apply plugin: 'forge'
apply plugin: 'license'
apply plugin: 'maven'
apply plugin: 'checkstyle'
apply plugin: 'com.github.johnrengelman.shadow'
// Basic project information
group = 'org.spongepowered'
archivesBaseName = 'sponge'
// Version -> Minecraft-MinecraftForge-Ours(If any?)
version = '1.8-11.14.0.1290-SNAPSHOT'
// Define variables
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
// Minimum version of Java required
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
repositories {
mavenCentral()
maven {
name = 'sonatype-nexus'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
// MinecraftForge version
minecraft {
version = "1.8-11.14.0.1290-1.8"
}
configurations {
deployerJars // maven deployment
}
// Project dependencies
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.0-beta9'
compile 'com.google.inject:guice:4.0-beta5'
compile project('Mixin')
compile project('SpongeAPI')
testCompile 'junit:junit:4.11'
checkstyle 'com.puppycrawl.tools:checkstyle:6.1.1'
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.7'
}
task mixin {
ext.srg = "${tasks.mixin.temporaryDir}" + File.separator + 'mixins.srg'
ext.refMap = "${tasks.mixin.temporaryDir}" + File.separator + 'mixins.sponge.refmap.json';
}
shadowJar {
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
exclude 'GradleStart**'
dependencies {
include(dependency('org.slf4j:slf4j-api'))
include(dependency('org.apache.logging.log4j:log4j-slf4j-impl'))
include(dependency('com.google.inject:guice'))
include(dependency('javax.inject:javax.inject'))
include(dependency('org.slf4j:slf4j-api'))
include(dependency('com.flowpowered:flow-math'))
include(dependency('aopalliance:aopalliance'))
include(project('SpongeAPI'))
include(project('Mixin'))
}
classifier = ''
from tasks.mixin.ext.refMap
}
build.dependsOn(shadowJar)
// Filter, process, and include resources
processResources {
inputs.property "version", version
inputs.property "mcversion", project.minecraft.version
// Include in final JAR
from 'LICENSE.txt'
// Replace variables
from('src/main/resources/mcmod.info') {
expand 'modid': project.name.toLowerCase(),
'name': project.name,
'description': project.description,
'version': version,
'buildNumber': buildNumber,
'mcversion': minecraft.version,
'url': url,
'authorList': organization
}
}
// License header formatting
license {
ext.name = project.name
ext.organization = project.organization
ext.url = project.url
ext.year = project.inceptionYear
exclude "**/*.info"
exclude "**/*.json"
exclude "**/*_at.cfg"
exclude "assets/**"
header new File(project("SpongeAPI").getProjectDir(), "HEADER.txt")
sourceSets = project.sourceSets
ignoreFailures false
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
}
checkstyle {
configFile = project('SpongeAPI').file('checkstyle.xml')
configProperties = [
"name" : project.name,
"organization" : project.organization,
"url" : project.url,
"year" : project.inceptionYear,
"suppressions": project('SpongeAPI').file('checkstyle-suppressions.xml')
]
}
tasks.reobf.dependsOn "check"
if (!minecraft.mappingsSet && minecraft.version.startsWith("1.8")) {
// Default mappings, normally if mappings are not specified then the plugin will set this
// default value internally, unfortunately this happens too late for the compile step below
// which needs the correct value to pass to the annotation processor.
minecraft.mappings = "snapshot_20141001"
}
reobf {
reobf(shadowJar.archivePath) {
spec -> spec.classpath = configurations.compile
}
}
reobf.dependsOn shadowJar
reobf.addExtraSrgFile tasks.mixin.ext.srg
// Source compiler configuration
tasks.withType(JavaCompile) {
options.compilerArgs += [ '-Xlint:all', '-Xlint:-path', '-Xlint:-processing',
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${tasks.mixin.ext.srg}",
"-AoutRefMapFile=${tasks.mixin.ext.refMap}" ]
options.deprecation = true
options.encoding = 'utf8'
}
// Copy the current srgs to the build dir so the user doesn't have to go hunting for them
task copySrgs(type: Copy) {
doFirst {
delete 'build/srgs'
}
include '**/*.srg'
from tasks.reobf.srg.parentFile
into 'build/srgs'
}
setupDecompWorkspace.dependsOn copySrgs
def manifestEntries = [
"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,
"FMLCorePlugin": "org.spongepowered.mod.SpongeCoremod",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": "10000"
]
jar {
// Jar shading and packaging configuration
from { project("Mixin").sourceSets.main.output }
from { project("SpongeAPI").sourceSets.main.output }
// JAR manifest configuration
manifest.mainAttributes(manifestEntries)
// classifier
classifier = 'release'
}
javadoc {
source = [
project("Mixin").sourceSets.main.java,
project("SpongeAPI").sourceSets.main.java,
sourceSets.main.java,
"src/example/java"
]
}
task deobfJar(type: Jar) {
from { project("Mixin").sourceSets.main.output }
from { project("SpongeAPI").sourceSets.main.output }
from sourceSets.main.output
}
task sourceJar(type: Jar, dependsOn: sourceMainJava) {
from "build/sources/java"
from "build/resources/main/java"
from project("Mixin").sourceSets.main.java
from project("Mixin").sourceSets.main.resources
from project("SpongeAPI").sourceSets.main.java
from project("SpongeAPI").sourceSets.main.resources
classifier = "sources"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
from project("Mixin").tasks.javadoc.destinationDir
from project("SpongeAPI").tasks.javadoc.destinationDir
classifier = "javadoc"
dependsOn "Mixin:javadoc"
dependsOn "SpongeAPI:javadoc"
}
artifacts {
archives deobfJar
archives sourceJar
archives javadocJar
}
uploadArchives {
dependsOn reobf
repositories {
mavenDeployer {
configuration = configurations.deployerJars
if (project.hasProperty("chRepo"))
{
repository(url: project.chRepo) {
authentication(userName: project.chUsername, password: project.chPassword)
}
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Sponge'
url 'http://www.spongepowered.org/'
scm {
url 'https://github.com/SpongePowered/SpongeAPI'
connection 'scm:git:git://github.com/SpongePowered/Sponge.git'
developerConnection 'scm:git:[email protected]:SpongePowered/Sponge.git'
}
issueManagement {
system 'youtrack'
url 'https://issues.spongepowered.org/'
}
licenses {
license {
name 'MIT license'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
}
}
}
}
}