-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.gradle
238 lines (204 loc) · 7.41 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
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'scala'
apply plugin: 'idea'
ext.configFile = file "build.properties"
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
version = config.mod_ver
group = config.mod_group
archivesBaseName = config.mod_name
if(System.getenv()['BRANCH']!=null && System.getenv()['BRANCH']!='master')
{
archivesBaseName+=("-"+System.getenv()['BRANCH'])
ext.subver=System.getenv()['TRAVIS_COMMIT'][0..6]
version+=('-'+ext.subver)
}
ext.usr = "$System.env.USR"
ext.pswd = "$System.env.PSWD"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
compileJava.options.encoding = "UTF-8"
compileScala.options.encoding = "UTF-8"
minecraft {
version = "1.12.2-14.23.4.2705"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20180814"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// Replacing stuff in the source
// Currently stale, see mySourcesJava task
replace "@VERSION@", config.mod_ver
replace "@LAMBDA_LIB_VERSION@", config.lambdalib_ver
replace "@MC_VERSION@", config.mc_ver
}
repositories {
mavenCentral()
mavenLocal()
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven"
}
maven {
name = "private"
//url = "http://139.199.206.70:8081/nexus/content/groups/public"
url = "http://git.project-gearbox.net:9010/content/repositories/thirdparty"
}
maven {
name = "ic2"
url = "http://maven.ic2.player.to"
}
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "http://dvs1.progwml6.com/files/maven"
}
maven {
name = "CoFH Maven"
url = "http://maven.covers1624.net"
}
maven {
// The main host of CraftTweaker related libs
name = "jared"
url = "http://maven.blamejared.com"
}
}
configurations {
provided
shade
deobfCompile.extendsFrom shade
}
// sourceSets.main.compileClasspath += [configurations.provided]
idea {
module{
scopes.PROVIDED.plus += [configurations.provided]
}
}
dependencies {
// Shade dependencies
shade "cn.lambdalib2:LambdaLib2:${config.lambdalib_ver}"
// Optional dependencies
deobfCompile "codechicken:CodeChickenLib:1.12.2-${config.ccl_ver}:universal"
deobfCompile "mezz.jei:jei_1.12.2:4.8.0.119"
//deobfCompile "codechicken:NotEnoughItems:1.12.2-${config.nei_ver}:universal"
deobfCompile "cofh:RedstoneFlux:1.12-2.0.0.1:universal"
deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.9.6"
deobfCompile "CraftTweaker2:CraftTweaker2-API:4.1.9.6"
deobfCompile "CraftTweaker2:ZenScript:4.1.9.6"
deobfCompile "net.industrial-craft:industrialcraft-2:2.8.90-ex112"
// shade "org.apache.httpcomponents:httpclient:4.3.3"
// shade "org.apache.httpcomponents:httpcore:4.3.2" // dependency of httpclient
// shade "commons-logging:commons-logging:1.1.3" // dependency of httpclient
// shade "commons-codec:commons-codec:1.6" // dependency of commons-logging
}
//sourceSets.main.compileClasspath += [configurations.provided]
sourceSets.main {
java.srcDirs = []
scala.srcDirs = ['src/main/scala', 'build/tempSourcesJava']
}
idea {
module{
scopes.PROVIDED.plus += [configurations.provided]
sourceDirs = [file('src/main/java'), file('src/main/scala')]
}
}
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
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
compileJava.options.encoding = "UTF-8"
compileScala.options.encoding = "UTF-8"
task deobfJar(type: Jar, dependsOn: 'jar') {
classifier 'dev'
from sourceSets.main.output
manifest {
attributes 'FMLCorePluginContainsFMLMod' : 'true'
attributes 'FMLCorePlugin' : 'cn.lambdalib2.CorePlugin'
}
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
exclude 'mcmod.info'
exclude 'pack.mcmeta'
}
}
manifest {
attributes 'FMLCorePluginContainsFMLMod' : 'true'
attributes 'FMLCorePlugin' : 'cn.lambdalib2.CorePlugin'
}
}
// http://www.minecraftforge.net/forum/topic/36791-trying-to-shade-dependencies-into-jar/
reobf {
jar {
// WARN: You can't shade apache httplib for several reasons
// 1. it introduces some transitive dependencies, including logging, which is no good
// 2. logging exploits a bug for srg (all .class calls' package names aren't transformed at all)
// extraLines "PK: org/apache/commons/codec cn/academy/shade/org/apache/commons/codec"
// extraLines "PK: org/apache/http cn/academy/shade/org/apache/http"
// extraLines "PK: org/apache/commons/logging cn/academy/shade/org/apache/commons/logging"
}
}
import org.apache.tools.ant.filters.ReplaceTokens
// see: https://stackoverflow.com/questions/30038540/replace-token-in-file-before-building-but-keep-token-in-sources
// Currently scala compilation task doesn't respect minecraft.replace options. We have to manually replace the tokens by ourselves.
// That also mean currently minecraft { replace ... } are all useless, but they are kept for future reference.
task mySourcesJava(type: Copy) {
from 'src/main/java'
into 'build/tempSourcesJava'
filteringCharset = 'UTF-8'
filter(ReplaceTokens, tokens: [VERSION: config.mod_ver])
filter(ReplaceTokens, tokens: [LAMBDA_LIB_VERSION: "[" + config.lambdalib_ver + "]"])
filter(ReplaceTokens, tokens: [MC_VERSION: config.mc_ver])
}
compileScala.dependsOn mySourcesJava
retromapReplacedMain.dependsOn compileScala
extractRangemapReplacedMain.dependsOn compileScala
artifacts {
archives deobfJar
}
uploadArchives {
repositories {
maven {
url "http://git.project-gearbox.net:9010/content/repositories/thirdparty"
credentials {
username usr
password pswd
}
}
}
}