forked from Electrical-Age/ElectricalAge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
293 lines (249 loc) · 8.5 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
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'de.undercouch:gradle-download-task:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id 'com.matthewprenger.cursegradle' version '1.0.8'
}
apply plugin: 'forge'
apply plugin: 'de.undercouch.download'
apply plugin: 'java'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply from: 'gradle.properties'
group = GROUP
archivesBaseName = ARCHIVE_NAME
version = MAJORVERSION + "." + MINORVERSION + "." + REVISION
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
sourceSets {
main {
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/resources']
resources.excludes = ['*']
kotlin.srcDirs = ['src/main/java']
}
}
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
// TODO(Baughn): After moving to 1.10, this should be replaced with the shadow plugin,
// e.g. as used in https://github.com/Emberwalker/Laundarray/blob/master/build.gradle
srgExtra "PK: org/apache/commons/math3 mods/eln/libs/org/apache/commons/math3"
srgExtra "PK: kotlin mods/eln/libs/kotlin"
srgExtra "PK: org/jetbrains/annotations mods/eln/libs/annotations"
replaceIn "Version.java"
replace "@VERSION@", project.version
replace "@MAJORVERSION@", MAJORVERSION
replace "@MINORVERSION@", MINORVERSION
replace "@REVISION@", REVISION
}
configurations {
external
compile.extendsFrom external
shade
compile.extendsFrom shade
}
repositories {
mavenCentral()
maven {
name = "codechicken"
url = "http://chickenbones.net/maven"
}
maven {
name = "mobiusstrip"
url = "http://default.mobiusstrip.eu/maven/"
}
}
dependencies {
external files("libs/commons-math3-3.3.jar")
shade "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "mcp.mobius.waila:Waila:1.5.11-RC2-NONEI_1.7.10:dev"
}
jar {
manifest {
attributes 'Built-By': 'Electrical-Age Team'
attributes 'Build-Date': new Date().format("yyyy-MM-dd HH:mm:ss")
attributes 'Built-JDK': System.getProperty('java.version')
attributes 'Implementation-Title': project.name
attributes 'Implementation-URL': 'https://github.com/Electrical-Age'
attributes 'Implementation-Vendor': 'Electrical-Age Team'
attributes 'Implementation-Vendor-Id': 'net.electricalage.eln'
attributes 'Project-Url': 'https://electrical-age.net/'
attributes 'Source-Compatibility': project.sourceCompatibility
attributes 'Target-Compatibility': project.targetCompatibility
}
// Copy libs jar files
from { configurations.external.collect { it.isDirectory() ? it : zipTree(it) } }
exclude(['dan200/**', 'ic2/**', 'li/**', 'buildcraft/**'])
// Add README and LICENSE to the release jar
from(['README.md', 'LICENSE.md'])
// Asset whitelist to copy the required asset files into the release jar.
// Ignore files not used in Minecraft to reduce the release jar size.
// Copy main files
from('src/main/resources/assets/eln/') {
include 'logo.png'
include 'sounds.json'
into 'assets/eln/'
}
// Copy language files
from('src/main/resources/assets/eln/lang') {
include '*.lang'
into 'assets/eln/lang'
}
// Copy model
from('src/main/resources/assets/eln/model') {
exclude '_Common'
exclude '_TEMPLATES'
exclude 'export_*.png'
include '**/*.mtl'
include '**/*.obj'
include '**/*.txt'
include '**/*.png'
into 'assets/eln/model'
}
// Copy sounds
from('src/main/resources/assets/eln/sounds') {
include '*.ogg'
into 'assets/eln/sounds'
}
// Copy sprites
from('src/main/resources/assets/eln/sprites') {
include '**/*.png'
include '**/*.xcf'
into 'assets/eln/sprites'
}
// Copy sprites
from('src/main/resources/assets/eln/textures') {
include '**/*.png'
into 'assets/eln/textures'
}
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
}
}
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
}
}
clean {
// Clean generated/built files. Saves are NOT deleted.
delete("${minecraft.runDir}/logs")
delete("${minecraft.runDir}/crash-reports")
}
def getMinecratfDir() {
String outDir = ""
final String osName = System.getProperty("os.name").toLowerCase()
if (osName.contains('windows'))
outDir = System.getenv("APPDATA") + "/.minecraft"
else if (osName.contains('os x'))
outDir = System.getProperty("user.home") + "/Library/Application Support/minecraft"
else if (osName.contains('linux'))
outDir = System.getProperty("user.home") + "/.minecraft"
return outDir
}
// Custom task to build and copy the mod Jar to the default local Minecraft folder
task buildAndCopyJar(dependsOn: 'build', type: Copy) {
group = 'ELN'
description = 'Build and copy the mod Jar to the default local Minecraft folder.'
outputs.upToDateWhen { false } // Force to run this task
duplicatesStrategy = DuplicatesStrategy.INCLUDE // Overwrite the file if exists
from("build/libs")
into(getMinecratfDir() + "/mods")
include("*.jar")
}
import de.undercouch.gradle.tasks.download.Download
// Download the tutorial map as a zip file to the local 'run/saves' folder
task downloadTutoMap(type: Download) {
group = 'ELN'
description = 'Download the tutorial map as a zip file to the local \'run/saves\' folder.'
src(MAPURL)
dest(new File(minecraft.runDir + "/saves", MAPURL.substring(MAPURL.lastIndexOf("/") + 1, MAPURL.length())))
overwrite true
}
// Unzip the local tutorial map after downloading it. Overwrite the map content if already exist
task unzipTutoMap(dependsOn: downloadTutoMap, type: Copy) {
group = 'ELN'
description = 'Unzip the local tutorial map after downloading it.'
outputs.upToDateWhen { false } // Force to run this task
from zipTree(downloadTutoMap.dest)
into(minecraft.runDir + "/saves")
}
// Update the master language file
task updateMasterLanguageFile(type: JavaExec, dependsOn: 'classes') {
group = 'ELN'
description = 'Generate or update the master language file.'
main = 'mods.eln.i18n.LanguageFileUpdater'
classpath = sourceSets.main.runtimeClasspath
args = ['./src', './src/main/resources/assets/eln/lang/en_US.lang']
}
jar.dependsOn(updateMasterLanguageFile)
publishing {
publications {
mod(MavenPublication) {
from components.java
groupId GROUP
artifactId ARCHIVE_NAME
version project.version
}
}
}
bintrayUpload {}.dependsOn(build)
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
publications = ['mod']
pkg {
repo = 'eln'
name = 'ElectricalAge'
userOrg = 'electrical-age'
licenses = ['LGPL V3.0', 'CC BY-NC-SA 3.0']
vcsUrl = 'https://github.com/Electrical-Age/ElectricalAge.git'
version {
name = project.version
}
}
}
curseforge {
// Put this in ~/.gradle/gradle.properties, absolutely not in the repository.
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ""
project {
id = '253045'
changelogType = 'markdown'
changelog = file('changelog.md')
releaseType = 'release'
addGameVersion "1.7.10"
mainArtifact(jar) {
displayName = "Electrical Age $project.version"
}
// addArtifact(sourcesJar) {
// displayName = "Electrical Age $project.version Sources"
// }
}
}
idea { module { inheritOutputDirs = true } }