-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathbuild.gradle
318 lines (257 loc) · 7.8 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
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
* OpenPeripheralCore build file.
* @author Arkan <arkan@emberwalker.cc>
*/
//================================================
// Pre-execute
buildscript {
repositories {
// General deps
mavenCentral()
// Minecraft Forge
maven {
name = 'Forge'
url = 'http://files.minecraftforge.net/maven'
}
// Sonatype (for SpecialSource in 1.7+)
maven {
name = "Sonatype Nexus"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name 'OpenMods Third Party'
url 'http://repo.openmods.info/artifactory/simple/thirdparty'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'net.thesilkminer.gradle.translationchecker:TranslationChecker:1.1'
}
}
apply plugin: 'forge'
apply plugin: 'java'
apply plugin: "maven"
repositories {
maven {
name = "OC repo"
url = "http://maven.cil.li/"
}
}
configurations {
apiReleaseCompile
compile.extendsFrom apiReleaseCompile
}
dependencies {
compile project(":OpenModsLib")
// apiCompile "info.computercraft:ComputerCraft-API:???"
apiReleaseCompile "li.cil.oc:OpenComputers:MC1.7.10-1.5.0.5:api"
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile "org.mockito:mockito-core:1.10.19"
}
//================================================
// Jar data
// Grab system env
ext.env = System.getenv()
version = mc_ver + "-" + mod_version
ext.in_jenkins = false
// Get Jenkins metadata
ext.jenkinsManifest = manifest {
if (env.BUILD_TAG != null) { // If this works, we'll assume we're in Jenkins atleast.
attributes("Jenkins-Build": "true", "Jenkins-Tag": env.BUILD_TAG, "Jenkins-ID": env.BUILD_ID)
in_jenkins = true
} else {
attributes("Jenkins-Build": "false")
}
}
def branch = null
def hash = null
def proc1 = "git rev-parse --short HEAD".execute()
proc1.in.eachLine { line -> hash = line }
proc1.err.eachLine { line -> println line }
proc1.waitFor()
if (!in_jenkins) {
def proc2 = "git rev-parse --abbrev-ref HEAD".execute()
proc2.in.eachLine { line -> branch = line }
proc2.err.eachLine { line -> println line }
proc2.waitFor()
} else { // In Jenkins
branch = env.GIT_BRANCH.minus("origin/")
}
// If not on master, add branch to jar name
if (branch != null && !branch.equals("master")) {
version += "-" + branch
} else {
//version += "-" + hash
}
// Version tag for jar file name
if (env.BUILD_NUMBER != null) {
version += "-snapshot-" + env.BUILD_NUMBER
}
// Get Git metadata (if in Jenkins)
ext.gitManifest = manifest {
if (env.GIT_BRANCH != null) {
attributes("Git-Branch": branch, "Git-Hash": hash)
}
}
// Setup Forge plugin
minecraft {
version = mc_ver + "-" + forge_ver
runDir = 'eclipse/assets'
replaceIn "openperipheral/ModInfo.java"
replaceIn "openperipheral/api/ApiAccess.java"
replace '$VERSION$', mod_version
replace '$OP-API-VERSION$', api_version
replace '$LIB-VERSION$', project(':OpenModsLib').mod_version
replace '$NEXT-LIB-VERSION$', project(':OpenModsLib').next_mod_version
}
processResources {
inputs.property "version", rootProject.mod_version
// Process mcmod.info
from(sourceSets.main.resources.srcDirs) {
include '**/*.info'
expand 'version':mod_version,'MCVersion':mc_ver
}
// Copy anything else directly
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.info'
}
}
javadoc {
include 'openperipheral/api/**'
if (JavaVersion.current().isJava8Compatible()) {
options.addBooleanOption('Xdoclint:accessibility,html,syntax', true)
}
}
//================================================
// Jar tasks
// Generate FML Coremod manifest
ext.fmlManifest = manifest {}
// Merge Jenkins and Git manifests to form final manifest in final release jar
jar {
manifest {
from jenkinsManifest, gitManifest, fmlManifest
}
}
// Dev jar
task deobfJar(type: Jar) {
classifier 'deobf'
from sourceSets.main.output
manifest {
from jenkinsManifest, gitManifest, fmlManifest
}
}
ext.sourcesPath = new File(new File(buildDir, "sources"), "java")
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourcesPath
manifest {
from jenkinsManifest, gitManifest
}
}
def API_NAME = "OpenPeripheralCore-API"
task apiJar(type: Jar) {
baseName API_NAME
version api_version
from sourceSets.main.output
from sourcesPath
include 'openperipheral/api/**'
manifest {
from jenkinsManifest, gitManifest
}
}
task apiSrcJar(type: Jar) {
baseName API_NAME
version api_version
classifier 'sources'
from sourcesPath
include 'openperipheral/api/**'
manifest {
from jenkinsManifest, gitManifest
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
baseName API_NAME
version api_version
classifier 'javadoc'
from 'build/docs/javadoc'
manifest {
from jenkinsManifest, gitManifest
}
}
artifacts {
archives deobfJar
archives sourcesJar
archives apiJar
archives apiSrcJar
archives javadocJar
}
task updateTranslations(type: net.thesilkminer.gradle.plugin.translationchecker.tasks.TranslationCheckTask) {
modId = "openperipheracore"
}
task checkTranslations(type: net.thesilkminer.gradle.plugin.translationchecker.tasks.TranslationCheckTask) {
modId = "openperipheracore"
dryRun = true
}
task wrapper (type: Wrapper) {
gradleVersion = "2.12"
}
uploadArchives {
repositories.mavenDeployer {
dependsOn 'build'
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
addFilter('api') {artifact, file ->
artifact.name == API_NAME
}
pom('api') {
groupId = "info.openmods"
version = api_version
artifactId = API_NAME
scopeMappings.mappings.clear()
scopeMappings.addMapping(0, configurations.apiReleaseCompile, Conf2ScopeMappingContainer.COMPILE)
project {
name API_NAME
packaging 'jar'
description 'OpenPeripheralCore API'
url 'https://github.com/OpenMods/OpenPeripheral'
scm {
url 'https://github.com/OpenMods/OpenPeripheral'
connection 'scm:git:git@github.com:OpenMods/OpenPeripheral.git'
developerConnection 'scm:git:git@github.com:OpenMods/OpenPeripheral.git'
}
issueManagement {
system 'github'
url 'https://github.com/OpenMods/OpenPeripheral/issues'
}
licenses {
license {
name 'MIT'
url 'https://github.com/OpenMods/OpenPeripheral/blob/master/LICENSE'
distribution 'repo'
}
}
developers {
developer {
id 'boq'
name 'boq'
roles { role 'developer' }
}
developer {
id 'mikemoo'
name 'Mikemoo'
roles { role 'developer' }
}
developer {
id 'sinz'
name 'SinZ'
roles { role 'developer' }
}
developer {
id 'theoriginalbit'
name 'theoriginalbit'
roles { role 'developer' }
}
}
}
}
}
}