-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
244 lines (215 loc) · 7.8 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
// For those who want the bleeding edge
plugins {
id 'maven-publish'
id 'net.minecraftforge.gradle' version '6.0.+'
id 'wtf.gofancy.fancygradle' version '1.1.+'
// See hack in settings.gradle for why this works
id 'org.spongepowered.mixin' version '0.7.+'
id 'eclipse'
}
// Strip Java 9-specific info from dependencies so Forge doesn't excrete bricks
apply from: 'java8ify.gradle'
version = project.modVersion
group = "leviathan143.loottweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "LootTweaker"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
ext.MIXIN_LOADER_CLASS = 'leviathan143.loottweaker.common.MixinLoader'
def mixins(runConfig) {
runConfig.jvmArg "-Dfml.coreMods.load=$MIXIN_LOADER_CLASS"
runConfig.jvmArg '-Dmixin.hotSwap=true'
}
minecraft {
mappings channel: 'stable', version: project.mappingsVersion
runs {
client {
taskName "$archivesBaseName-Client"
workingDirectory project.file('run/client')
mixins(it)
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'saddle.disable', 'true'
environment 'MC_VERSION', project.minecraftVersion
}
server {
taskName "$archivesBaseName-Server"
mixins(it)
workingDirectory project.file('run/server')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'saddle.disable', 'true'
environment 'MC_VERSION', project.minecraftVersion
}
testClient {
parent runs.client
taskName "$archivesBaseName-Client-Tests"
mixins(it)
workingDirectory project.file('test/client')
property 'saddle.disable', 'false'
property 'saddle.exitOnTestCompletion', 'true'
args '--mixin.config', 'loottweaker_test.mixins.json'
}
testServer {
parent runs.server
taskName "$archivesBaseName-Server-Tests"
mixins(it)
workingDirectory project.file('test/server')
property 'saddle.disable', 'false'
property 'saddle.exitOnTestCompletion', 'true'
args '--mixin.config', 'loottweaker_test.mixins.json'
}
}
}
fancyGradle {
patches {
resources
coremods
}
}
mixin {
add sourceSets.main, 'mixins.loottweaker.refmap.json'
config 'loottweaker.mixins.json'
}
configurations {
//Jars to package using ContainedDeps
containedDep {
transitive = false
}
}
// FancyGradle isn't quite enough
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module('net.minecraftforge:legacydev') using module('net.minecraftforge:legacydev:0.2.4.+') because 'Fixes ATs'
}
}
}
repositories
{
mavenCentral()
maven
{
name "Jared"
url "https://maven.blamejared.com"
}
maven
{
name 'JitPack'
url 'https://jitpack.io'
}
maven
{
name 'Su5ed LegacyDev Fork'
url = 'https://maven.su5ed.dev/releases'
}
maven {
url = 'https://repo.spongepowered.org/repository/maven-public/'
content { includeGroup 'org.spongepowered' }
}
}
dependencies
{
minecraft "net.minecraftforge:forge:${project.minecraftVersion}-${project.forgeVersion}"
implementation "CraftTweaker2:ZenScript:${project.crafttweakerVersion}"
implementation fg.deobf("CraftTweaker2:CraftTweaker2-API:${project.crafttweakerVersion}")
implementation fg.deobf("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${project.crafttweakerVersion}")
implementation(containedDep(project(':Daomephsta Loot Shared')))
implementation "org.spongepowered:mixin:0.8.4-SNAPSHOT"
annotationProcessor "org.spongepowered:mixin:0.8.4-SNAPSHOT:processor"
testImplementation 'com.github.Daomephsta:Saddle:0.0.3'
testImplementation 'org.assertj:assertj-core:3.13.2'
// Use JUnit test framework
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.5.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
}
if (file("per-machine.properties").exists()) {
def perMachine = new Properties()
file("per-machine.properties").withInputStream(perMachine.&load)
tasks.register('deploy', Copy) {
group 'build'
description 'Copies the JAR into a production environment specified in per-dev.properties'
dependsOn 'build'
mustRunAfter 'build'
from jar.archiveFile
into file(perMachine.deployDirectory)
}
}
import java.util.jar.*
boolean hasContainedDepMetadata(File file)
{
def jar = new JarFile(file)
if (jar.manifest == null) return;
def hasMetadata = jar.manifest.mainAttributes.containsKey(new Attributes.Name('Maven-Artifact'))
jar.close()
return hasMetadata
}
task generateDependencyMetaFiles {doLast{
//Delete any previous meta files
file("${buildDir}/dependencyMeta").deleteDir()
//Generate new meta files
configurations.containedDep.resolvedConfiguration.resolvedArtifacts.each {
//Ignore files that define the dependency metadata themselves
if (hasContainedDepMetadata(it.file)) return;
def metaFile = file("${buildDir}/dependencyMeta/${it.file.name}.meta")
metaFile.parentFile.mkdirs()
//The newline is very important
metaFile.text = "Maven-Artifact: ${it.moduleVersion.id}\n"
}
}}
jar {
archiveVersion = provider {
def dlsMajorVersion = (project(':Daomephsta Loot Shared').version =~ /^\d+/)[0]
return "${project.version}+MC${project.minecraftVersion}-DLS${dlsMajorVersion}"
}
manifest {
attributes([
"Specification-Title": "LootTweaker",
"Specification-Vendor": "Daomephsta",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "loottweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"FMLCorePlugin": MIXIN_LOADER_CLASS,
"FMLCorePluginContainsFMLMod": "true",
"ForceLoadAsMod": true,
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
//Add contained dependencies to the manifest
'ContainedDeps': fileTree("${buildDir}/dependencyMeta").collect {
it.name[0..<it.name.lastIndexOf('.')]
}
.join(' ')
])
}
//Package contained dependencies
into('/META-INF/libraries') {
from configurations.containedDep, file("${buildDir}/dependencyMeta")
}
dependsOn generateDependencyMetaFiles
finalizedBy('reobfJar')
}
processResources {
inputs.property 'version', project.modVersion
filesMatching('mcmod.info') {
expand 'version': project.modVersion
}
}
import org.apache.tools.ant.filters.ReplaceTokens
task processSource(type: Sync) {
from sourceSets.main.java
inputs.property 'version', project.modVersion
filesMatching('leviathan143/loottweaker/common/LootTweaker.java') {
filter(ReplaceTokens, tokens: ['VERSION': project.modVersion])
}
into "$buildDir/src"
}
compileJava {
source = processSource.outputs
}
//When Forge 1.12 loads mods from a directory that's been put on the classpath, it expects to find resources in the same directory.
//Default Gradle behavior puts resources in ./build/resources/main instead of ./build/classes/main/java. Let's change that.
sourceSets.all { it.output.resourcesDir = it.output.classesDirs.getFiles().iterator().next() }