forked from GregTechCE/GregTech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
224 lines (187 loc) · 5.85 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
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'
}
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 = "http://maven.ic2.player.to/"
}
maven { //JEI
name = "Progwml6 maven"
url = "http://dvs1.progwml6.com/files/maven/"
}
maven {
name = "tterrag maven"
url = "http://maven.tterrag.com/"
}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven {
name = "ChickenBones maven"
url = "http://chickenbones.net/maven/"
}
maven {
name = "CoFH Maven"
url = "http://maven.covers1624.net"
}
maven {
name = "tehnut maven"
url = "http://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 "baubles:Baubles:${shortVersion}:${config.baubles.version}"
deobfCompile "cofh:ThermalDynamics:${config.minecraft.version}-${config.thermaldynamics.version}:deobf"
deobfCompile "thaumcraft:Thaumcraft:${config.minecraft.version}:${config.thaumcraft.version}"
}
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'
}
artifacts {
archives jar
archives source
}
idea {
module {
inheritOutputDirs = true
}
}
task ciWriteBuildNumber doLast {
def file = file("src/main/java/gregtech/GregTechVersion.java")
def bn = System.getenv("BUILD_NUMBER") ?: 0
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 getVersionFromJava(File file) {
String major = "0"
String minor = "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]
}
}
def branchName = System.getenv("CI_COMMIT_REF_NAME")
if (branchName != null && branchName != "master") {
return "$major.$minor.0-$branchName"
}
String build = System.getenv("BUILD_NUMBER") ?: 0
return "$major.$minor.$build"
}
curseforge {
if (!System.getenv('CURSE_API_KEY')) {
return
}
apiKey = System.getenv('CURSE_API_KEY')
project {
id = '293327'
changelog = file('CHANGELOG.md')
changelogType = 'markdown'
releaseType = 'beta'
relations {
requiredLibrary 'codechicken-lib-1-8'
optionalLibrary 'forge-multipart-cbe'
optionalLibrary 'crafttweaker'
optionalLibrary 'jei'
optionalLibrary 'the-one-probe'
}
addArtifact source
}
}