generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
287 lines (250 loc) · 9.01 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
import org.jetbrains.gradle.ext.Gradle
plugins {
id 'java'
id 'scala'
id 'java-library'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.8'
id 'com.gtnewhorizons.retrofuturagradle' version '1.4.1'
}
version = "1.12.2-${mod_version}"
group = project.maven_group
base {
archivesName = archives_base_name
}
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
}
// Generate sources and javadocs jars when building and publishing
withSourcesJar()
// withJavadocJar()
}
compileJava {
sourceCompatibility = 8 // for the IDE support
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
configurations {
embed
implementation.extendsFrom(embed)
}
minecraft {
mcVersion = '1.12.2'
// MCP Mappings
mcpMappingChannel = 'stable'
mcpMappingVersion = '39'
// Set username here, the UUID will be looked up automatically
username = 'Developer'
// Add any additional tweaker classes here
// extraTweakClasses.add('org.spongepowered.asm.launch.MixinTweaker')
// Add various JVM arguments here for runtime
def args = ["-ea:${project.group}"]
if (project.use_coremod.toBoolean()) {
args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
}
if (project.use_mixins.toBoolean()) {
args << '-Dmixin.hotSwap=true'
args << '-Dmixin.checks.interfaces=true'
args << '-Dmixin.debug.export=true'
}
extraRunJvmArguments.addAll(args)
// Include and use dependencies' Access Transformer files
useDependencyAccessTransformers = true
// Add any properties you want to swap out for a dynamic value at build time here
// Any properties here will be added to a class at build time, the name can be configured below
// Example:
injectedTags.put('VERSION', project.version)
injectedTags.put('MOD_ID', project.mod_id)
injectedTags.put("MOD_VERSION", project.mod_version)
}
tasks.injectTags.outputClassName.set("${maven_group}.${project.mod_id}.Tags")
repositories {
flatDir { dir 'libs' }
maven {
url 'https://maven.minecraftforge.net'
metadataSources {
artifact()
}
}
maven {
url 'https://repo.papermc.io/'
}
maven {
name 'CleanroomMC Maven'
url 'https://maven.cleanroommc.com'
}
maven {
name 'SpongePowered Maven'
url 'https://repo.spongepowered.org/maven'
}
maven {
name 'CurseMaven'
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url = 'https://maven.blamejared.com'
name = 'BlameJared Maven'
}
mavenCentral() // Must be last for caching to work
}
dependencies {
if (project.use_assetmover.toBoolean()) {
implementation 'com.cleanroommc:assetmover:2.5'
}
if (project.use_mixins.toBoolean()) {
implementation 'zone.rong:mixinbooter:9.1'
}
// Example of deobfuscating a dependency
// implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
if (project.use_mixins.toBoolean()) {
// Change your mixin refmap name here:
String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.5', "mixins.${project.mod_id}.refmap.json")
api(mixin) {
transitive = false
}
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
annotationProcessor 'com.google.code.gson:gson:2.8.6'
annotationProcessor(mixin) {
transitive = false
}
}
implementation "com.google.guava:guava:33.0.0-jre"
embed 'org.scala-lang:scala-actors-migration_2.11:1.1.0'
embed 'org.scala-lang:scala-compiler:2.11.1'
// We change the version so old installs don't break, as our clone of the jar is different the maven central
embed 'org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2_mc'
embed 'org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2_mc'
embed 'org.scala-lang:scala-library:2.11.1'
embed 'org.scala-lang:scala-parser-combinators_2.11:1.0.1'
embed 'org.scala-lang:scala-reflect:2.11.1'
embed 'org.scala-lang:scala-swing_2.11:1.0.1'
embed 'org.scala-lang:scala-xml_2.11:1.0.2'
embed 'com.typesafe.akka:akka-actor_2.11:2.3.3'
embed 'com.typesafe:config:1.2.1'
}
// Adds Access Transformer files to tasks
if (project.use_access_transformer.toBoolean()) {
for (File at : sourceSets.getByName("main").resources.files) {
if (at.name.toLowerCase().endsWith("_at.cfg")) {
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
}
}
}
processResources {
// This will ensure that this task is redone when the versions change
inputs.property 'version', project.mod_version
inputs.property 'mcversion', '1.12.2'
// Replace various properties in mcmod.info and pack.mcmeta if applicable
filesMatching(['mcmod.info']) { fcd ->
// Replace version and mcversion
fcd.expand(
'mod_version': project.mod_version,
'minecraft_version': "1.12.2"
)
}
if (project.use_access_transformer.toBoolean()) {
rename '(.+_at.cfg)', 'META-INF/$1' // Make sure Access Transformer files are in META-INF folder
}
}
tasks.register('generateMetaFiles') {
// Code for execution after the whole buildscript was parsed and loaded
doLast {
// Clear the dependencyMeta directory since we don't want old dependencies to still be listed in there
file("${buildDir}/dependencyMeta/").deleteDir()
configurations.embed.resolvedConfiguration.resolvedArtifacts.each {
// Create a meta file for each dependency in a specified directory
def metaFile = file("${buildDir}/dependencyMeta/${it.file.name}.meta")
metaFile.parentFile.mkdirs()
// Use the Gradle notation provided by the API ('group:artifact:version') for the meta file...
def artifactRef = it.moduleVersion.toString()
// ...and append the classifier if present
if (it.classifier != null) {
artifactRef += ":${it.classifier}"
}
// Write the artifact information to the meta file, to be used by the
metaFile.text = "Maven-Artifact: $artifactRef"
}
}
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
into('/') {
// Add all of the dependency JARs to the main JAR for later extraction
from configurations.embed
// Also include all dependency meta files
from "${buildDir}/dependencyMeta/"
}
doFirst{
manifest {
def attribute_map = [:]
attribute_map['ContainedDeps'] = configurations.embed.collect { it.name }.join(' ')
attribute_map['NonModDeps'] = true
attribute_map['ModType'] = 'CRL'
if (project.use_coremod.toBoolean()) {
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
if (project.include_mod.toBoolean()) {
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
}
}
if (project.use_access_transformer.toBoolean()) {
attribute_map['FMLAT'] = project.mod_id + '_at.cfg'
}
attributes(attribute_map)
}
// Add all embedded dependencies into the jar
//from(provider { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } })
}
dependsOn generateMetaFiles
}
tasks.register('apiJar', Jar){
archiveClassifier = "api"
manifest {
attributes([
'Specification-Title': mod_id,
'Specification-Vendor': "kappa-maintainer",
'Specification-Version': '1', // We are version 1 of ourselves
'FMLCorePlugin': project.coremod_plugin_class_name
])
}
from sourceSets.main.output
}
artifacts {
archives jar
archives apiJar
}
tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}
publishing {
repositories {
maven {
name = "outlands"
url = "https://maven.outlands.top/releases"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
publications {
maven(MavenPublication) {
artifact apiJar
groupId = project.maven_group
artifactId = project.mod_id
version = project.mod_version
from components.java
}
}
}