-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
294 lines (252 loc) · 8.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
289
290
291
292
293
294
import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.apache.commons.io.FileUtils
import org.apache.commons.io.filefilter.FileFilterUtils
import org.apache.commons.io.filefilter.TrueFileFilter
import java.nio.file.Files
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+'
}
}
plugins {
id("maven-publish")
id "com.github.johnrengelman.shadow" version "6.1.0"
id 'com.matthewprenger.cursegradle' version "1.4.0"
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
def mcVersion = '1.12.2'
version = '1.1.5'
group = 'team.cappcraft.icheme'
archivesBaseName = 'immersive-chemical-engineering'
sourceCompatibility = targetCompatibility = 1.8
minecraft {
mappings channel: 'snapshot', version: '20171003-1.12'
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
}
server {
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
}
}
}
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven {
name = 'ModMaven'
url 'https://modmaven.dev'
}
maven {
name = 'CoFH Maven'
url = 'http://maven.covers1624.net/'
}
maven {
name = 'ChickenBones Maven'
url = "http://chickenbones.net/maven/"
}
maven {
name = 'JEI Maven'
url = 'http://dvs1.progwml6.com/files/maven'
}
maven {
name = 'Immersive Maven'
url = 'http://maven.blamejared.com'
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
dependencies {
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'
implementation 'mezz.jei:jei_1.12.2:4.+'
implementation 'cofh:RedstoneFlux:1.12-2.+:deobf'
implementation 'mcjty.theoneprobe:TheOneProbe-1.12:1.12-1.+'
implementation 'CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.+'
implementation fg.deobf('blusunrize:ImmersiveEngineering:0.12-92-559')
//noinspection GradlePackageUpdate
implementation 'org.jgrapht:jgrapht-core:1.4.0'
shadow 'org.jgrapht:jgrapht-core:1.4.0'
testImplementation(platform('org.junit:junit-bom:5.7.1'))
testImplementation('org.junit.jupiter:junit-jupiter:5.8.1')
runtimeOnly('curse.maven:nbtEdit-247580:2448708')
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
jar {
manifest {
attributes([
"Specification-Title" : "immersive-chemical-engineering",
"Specification-Vendor" : "Cappcraft Team",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "Cappcraft Team",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
class MakeATsTask extends DefaultTask {
@Input
FileCollection runtimeLibraries
@OutputDirectories
File dirATs
String FILENAME_AT = "accesstransformer.cfg"
MakeATsTask() {
runtimeLibraries = project.configurations["runtimeClasspath"].filter {
!it.name.startsWith("forge")
}
dirATs = new File("$project.buildDir/generatedATs")
}
@TaskAction
def makeAT() {
project.delete(dirATs)//Clean first
runtimeLibraries.forEach {
project.zipTree(it).filter { content ->
content.name.endsWith("_at.cfg")
}.forEach { at ->
println("Found AccessTransFormer: ${at.name} in ${it.name}")
project.copy {
from(at)
into(project.file("$dirATs/${at.name.substring(0, at.name.lastIndexOf("."))}"))
rename {
FILENAME_AT
}
}
}
}
}
}
task transformAccessTransformer(type: MakeATsTask) {
group = "access_transformer"
if (dirATs.exists())
minecraft.accessTransformers.addAll(FileUtils.listFiles(
dirATs,
FileFilterUtils.nameFileFilter(FILENAME_AT),
TrueFileFilter.INSTANCE))
}
task generateSources(type: Copy) {
inputs.properties("version": version)
group = "build"
from compileJava.source
into "$buildDir/generatedSrc"
expand "version": version
}
compileJava {
source = tasks.generateSources.outputs
dependsOn(tasks.generateSources)
}
processResources {
inputs.properties(
"version": version,
"mcversion": mcVersion
)
from(sourceSets.main.resources.srcDirs)
copy {
from(sourceSets.main.resources.srcDirs)
into("$buildDir/classes/java/main")
filesMatching("mcmod.info") {
expand("version": version, "mcversion": mcVersion)
}
}
filesMatching("mcmod.info") {
expand("version": version, "mcversion": mcVersion)
}
}
task sourceJar(type: Jar) {
group = "build"
archiveClassifier.set 'sources'
from sourceSets.main.allSource
}
shadowJar {
classifier = "deobf"
configurations = [project.configurations.shadow]
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
Properties properties = new Properties()
def file = new File("${projectDir}/local.properties")
if (file.exists()) {
properties.load(Files.newInputStream(file.toPath()))
curseforge {
apiKey = properties.getProperty("curse-api")
project {
id = '463438'
changelog = 'Support Comparator'
releaseType = 'beta'
mainArtifact shadowJar//Will be replaced in afterEvaluate
addArtifact shadowJar
addArtifact sourceJar
addGameVersion("Java 8")
addGameVersion("1.12.2")
relations {
requiredDependency("immersive-engineering")
}
}
}
afterEvaluate {
task shadowReobfedJar(type: ShadowJar) { shadow ->
shadow.group = "build"
shadow.description = 'Create a combined JAR of reobfed and runtime dependencies'
shadow.archiveClassifier.set("shadowed")//Set classifier
shadow.manifest.inheritFrom project.tasks.jar.manifest
def libsProvider = project.provider { -> [project.tasks.jar.manifest.attributes.get('Class-Path')] }
def files = project.objects.fileCollection().from { ->
project.configurations.findByName(ShadowBasePlugin.CONFIGURATION_NAME)
}
shadow.doFirst {
if (!files.empty) {
def libs = libsProvider.get()
libs.addAll files.collect { "${it.name}" }
manifest.attributes 'Class-Path': libs.findAll { it }.join(' ')
}
//Take re-Obf Jar as input
shadow.from(tasks.reobfJar.getInput())
}
shadow.configurations = [project.configurations.shadow]
shadow.exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'module-info.class')
shadow.dependsOn(tasks.reobfJar)
tasks.reobfJar.finalizedBy(shadow)
}
tasks.curseforge463438.mainArtifact.artifact = shadowReobfedJar
publishing {
publications {
uploadhMod(MavenPublication) {
artifactId = project.archivesBaseName
artifact sourceJar
artifact shadowJar
artifact shadowReobfedJar
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/CappCraft-Team/Immersive-Chemical-Engineering")
credentials {
username = properties.getProperty("gpr.user") ?: System.getenv("USERNAME")
password = properties.getProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
}
}
}