forked from GregTechCE/GregTech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
288 lines (244 loc) · 7.7 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
import org.ajoberstar.grgit.Grgit
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.1.0'
id 'maven-publish'
id "com.jfrog.bintray" version "1.8.4"
id "org.ajoberstar.grgit" version "2.2.0"
}
apply plugin: 'net.minecraftforge.gradle.forge'
file "build.properties" withReader {
def prop = new Properties()
prop.load(it)
ext.config = new ConfigSlurper().parse prop
}
def mod_version = getVersionFromJava(file("src/main/java/gregtech/GregTechVersion.java"))
version = "${config.minecraft.version}-${mod_version}"
group = "gregtech"
archivesBaseName = "gregtech"
minecraft {
version = "${config.minecraft.version}-${config.forge.version}"
mappings = "snapshot_20170928"
runDir = "run"
useDepAts = true
}
configurations {
provided
embedded
compile.extendsFrom provided, embedded
}
repositories {
maven {
name = "ic2, forestry"
url = "https://maven.ic2.player.to/"
}
maven { //JEI
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven { //JEI fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
maven {
name = "tterrag maven"
url = "https://maven.tterrag.com/"
}
maven {
name = "ChickenBones maven"
url = "https://chickenbones.net/maven/"
}
maven {
name = "CoFH Maven"
url = "https://maven.covers1624.net"
}
maven {
name = "tehnut maven"
url = "https://tehnut.info/maven/"
}
maven {
name = "CraftTweaker Maven"
url = "https://maven.blamejared.com/"
}
}
String mcVersion = config.minecraft.version
String shortVersion = mcVersion.substring(0, mcVersion.lastIndexOf('.'))
String strippedVersion = shortVersion.replace(".", "") + "0"
dependencies {
deobfCompile("net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}") {
transitive = false
}
deobfCompile "codechicken:ChickenASM:${shortVersion}-${config.chickenasm.version}"
deobfCompile "codechicken:CodeChickenLib:${config.minecraft.version}-${config.ccl.version}:deobf"
deobfCompile "codechicken:ForgeMultipart:${config.minecraft.version}-${config.multipart.version}:deobf"
deobfCompile "CraftTweaker2:CraftTweaker2-MC${strippedVersion}-Main:${config.crafttweaker.version}"
deobfCompile "mezz.jei:jei_${config.minecraft.version}:${config.jei.version}:api"
deobfCompile "mcjty.theoneprobe:TheOneProbe-${shortVersion}:${shortVersion}-${config.top.version}"
deobfCompile "cofh:ThermalDynamics:${config.minecraft.version}-${config.thermaldynamics.version}:deobf"
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.encoding = "UTF-8"
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", mod_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':mod_version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
// access transformer
rename '(.+_at.cfg)', 'META-INF/$1'
}
jar {
manifest {
attributes 'FMLAT': 'gregtech_at.cfg'
}
}
task source(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task dev(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
}
task energyApi(type: Jar) {
from(sourceSets.main.allSource)
from(sourceSets.main.output)
include "gregtech/api/capability/IElectricItem.*"
include "gregtech/api/capability/IEnergyContainer.*"
include "gregtech/api/capability/GregtechCapabilities.*"
classifier = 'energy-api'
}
artifacts {
archives jar
archives source
archives energyApi
}
idea {
module {
inheritOutputDirs = true
}
}
task ciWriteBuildNumber doLast {
def file = file("src/main/java/gregtech/GregTechVersion.java")
def bn = getBuildNumber()
def outfile = ""
def ln = "\n" //Linux line endings because we're on git!
println "Build number: $bn"
file.eachLine { String s ->
if (s.matches("^ {4}public static final int BUILD = [\\d]+;\$"))
s = " public static final int BUILD = ${bn};"
outfile += (s + ln)
}
file.write(outfile)
}
String getBuildNumber() {
def grgit = Grgit.open(dir: '.')
def commits = grgit.log {
range('c795901d796fba8ce8d3cb87d0172c59f56f3c9b', 'HEAD')
}
return commits.size()
}
String getVersionFromJava(File file) {
String major = "0"
String minor = "0"
String revision = "0"
String prefix = "public static final int"
file.eachLine { String s ->
s = s.trim()
if (s.startsWith(prefix)) {
s = s.substring(prefix.length(), s.length() - 1)
s = s.replace('=', ' ').replaceAll(" +", " ").trim()
String[] pts = s.split(" ")
if (pts[0] == "MAJOR") major = pts[pts.length - 1]
else if (pts[0] == "MINOR") minor = pts[pts.length - 1]
else if (pts[0] == "REVISION") revision = pts[pts.length - 1]
}
}
def branchNameOrTag = System.getenv("CI_COMMIT_REF_NAME")
if (branchNameOrTag != null && !branchNameOrTag.startsWith('v') && branchNameOrTag != "master") {
return "$major.$minor.$revision-$branchNameOrTag"
}
String build = getBuildNumber()
return "$major.$minor.$revision.$build"
}
curseforge {
if (!System.getenv('CURSE_API_KEY')) {
println 'Skipping curseforge task as there is no api key in the environment'
return
}
apiKey = System.getenv('CURSE_API_KEY')
project {
id = '293327'
changelog = file('CHANGELOG.md')
changelogType = 'markdown'
releaseType = 'beta'
relations {
requiredDependency 'codechicken-lib-1-8'
optionalDependency 'forge-multipart-cbe'
optionalDependency 'crafttweaker'
optionalDependency 'jei'
optionalDependency 'the-one-probe'
}
addArtifact source
addArtifact energyApi
}
}
publishing {
publications {
GTCEPublication(MavenPublication) {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
artifact jar
artifact source
artifact energyApi
}
}
}
bintray {
def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayApiKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
if (!bintrayUser || !bintrayApiKey) {
println 'Skipping bintrayUpload task as there is no api key or user in the environment'
return
}
user = bintrayUser
key = bintrayApiKey
publications = ['GTCEPublication']
publish = true
pkg {
repo = 'dev'
name = 'GregTechCE'
userOrg = 'gregtech'
licenses = ['LGPL-3.0']
vcsUrl = 'https://github.com/GregTechCE/GregTech.git'
version {
name = project.version
released = new Date()
}
}
}