-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
245 lines (213 loc) · 7.11 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
import org.jetbrains.gradle.ext.Gradle
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.16'
}
def coremod_plugin_name = 'zone.rong.mixinbooter.MixinBooterPlugin'
version = mod_version
group = 'zone.rong'
archivesBaseName = 'mixinbooter'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
}
// Generate sources and javadocs jars when building and publishing
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
minecraft {
mcVersion = '1.12.2'
extraRunJvmArguments.addAll([
"-ea:${project.group}",
"-Dfml.coreMods.load=${coremod_plugin_name}",
'-Dmixin.checks.interfaces=true',
'-Dmixin.debug.export=true'
])
extraTweakClasses.add('org.spongepowered.asm.launch.MixinTweaker')
injectedTags.put('VERSION', project.version)
injectedTags.put('MOD_ID', project.archivesBaseName)
injectedTags.put('MOD_NAME', project.mod_name)
}
tasks.injectTags.configure {
outputClassName.set("zone.rong.mixinbooter.Tags")
}
sourceSets {
relocate {
compileClasspath += sourceSets.main.compileClasspath
runtimeClasspath += sourceSets.main.runtimeClasspath
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
embed
mixin
implementation.extendsFrom embed
embed.extendsFrom mixin
annotationProcessor.extendsFrom mixin
}
repositories {
maven {
url 'https://jitpack.io'
}
// maven {
// name 'Fabric'
// url 'https://maven.fabricmc.net/'
// }
}
dependencies {
String mixinDep = modUtils.enableMixins('com.github.CleanroomMC:UniMix:5e5211c637')
mixin (mixinDep) {
transitive = false
}
embed 'io.github.llamalad7:mixinextras-common:0.5.0-beta.4'
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
annotationProcessor 'com.google.guava:guava:24.1.1-jre'
annotationProcessor 'com.google.code.gson:gson:2.8.6'
}
processResources {
inputs.property 'mod_version', project.version
inputs.property 'mod_id', project.archivesBaseName
inputs.property 'mod_name', project.mod_name
filesMatching('mcmod.info') {
expand(
'mod_version': project.version,
'mod_id': project.archivesBaseName,
'mod_name': project.mod_name,
)
}
}
tasks.register('properJar', Jar) { jar ->
group 'build'
// Gather all service files, append them under the same file if possible
doFirst {
def serviceDir = file("$buildDir/tmp/services_cleanup/META-INF/services")
serviceDir.deleteDir()
serviceDir.mkdirs()
configurations.embed.each { file ->
zipTree(file).matching {
include 'META-INF/services/*'
}.each { serviceFile ->
new File(serviceDir, serviceFile.name) << serviceFile.getText("UTF-8") << '\n'
}
}
}
// Set output jar name to have an exclamation mark at the front
jar.archiveBaseName.set("!${project.archivesBaseName}")
// Gather all main source/resource files, excluding any META-INF and replaceable files
from sourceSets.main.output
// Gather relocate source set's source files
from sourceSets.relocate.output
// Gather embed dependencies, while excluding any replaceable files and META-INF services
from(provider {
configurations.embed.collect {
if (it.isDirectory()) {
return it
} else {
zipTree(it).matching {
exclude '**/LICENSE*', 'META-INF/**'
}
}
}
})
// Gather earlier bundled service files
from fileTree(file("$buildDir/tmp/services_cleanup/")).matching {
include 'META-INF/services/*'
}
manifest {
def attribute_map = [:]
attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker'
attribute_map['FMLCorePlugin'] = coremod_plugin_name
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
attributes(attribute_map)
}
}
tasks.register('properSourcesJar', Jar) { jar ->
group 'build'
// Sources classifier
jar.archiveClassifier.set('sources')
// Gather all of our own source files
from sourceSets.main.allSource
// Gather all of relocated source files
from sourceSets.relocate.allSource
// Gather sources of embed dependencies
def componentIds = configurations.embed.incoming.resolutionResult.allDependencies.collect { it.selected.id }
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery()
.forComponents(componentIds)
.withArtifacts(JvmLibrary, SourcesArtifact)
.execute()
result.resolvedComponents.each { ComponentArtifactsResult component ->
Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact)
sources.each { ArtifactResult ar ->
if (ar instanceof ResolvedArtifactResult) {
fileTree(ar.file).each { sourceFiles ->
from zipTree(sourceFiles).matching {
include '**/*.java'
}
}
}
}
}
}
idea {
module {
inheritOutputDirs = true
}
project {
settings {
runConfigurations {
"1. Run Client"(Gradle) {
taskNames = ["runClient"]
}
"2. Run Server"(Gradle) {
taskNames = ["runServer"]
}
"3. Run Obfuscated Client"(Gradle) {
taskNames = ["runObfClient"]
}
"4. Run Obfuscated Server"(Gradle) {
taskNames = ["runObfServer"]
}
}
compiler.javac {
afterEvaluate {
javacAdditionalOptions = "-encoding utf8"
moduleJavacAdditionalOptions = [(project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')]
}
}
}
}
}
tasks.named('processIdeaSettings').configure {
dependsOn 'injectTags'
}
publishing {
publications {
mavenJava(MavenPublication) {
// from components.java
groupId project.group
artifactId project.archivesBaseName
artifact tasks.named('properJar')
artifact tasks.named('properSourcesJar')
artifact tasks.named('javadocJar')
}
}
repositories {
maven {
name = 'CleanroomMaven'
url = 'https://repo.cleanroommc.com/releases'
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
}