-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
170 lines (143 loc) · 5.72 KB
/
Copy pathbuild.gradle
File metadata and controls
170 lines (143 loc) · 5.72 KB
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
buildscript {
repositories {
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
// Make sure this version matches the one included in Kotlin for Forge
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
// OPTIONAL Gradle plugin for Kotlin Serialization
classpath "org.jetbrains.kotlin:kotlin-serialization:1.5.21"
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'kotlin'
apply plugin: 'kotlinx-serialization'
version = '0.1.3'
group = 'oggvik.mods.configurablezombieai'
archivesBaseName = 'configurablezombieai'
// Forge 1.16.5 userdev launches reliably on JDK 17, but the mod itself should
// still target Java 8 bytecode for runtime compatibility.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
tasks.withType(JavaCompile).configureEach {
options.release = 8
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = '1.8'
}
def generatedMixinRefmap = layout.buildDirectory.file("tmp/compileJava/compileJava-refmap.json")
def java17Launcher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
tasks.withType(JavaExec).configureEach {
// The game run tasks must match the JDK version Forge userdev expects.
javaLauncher.set(java17Launcher)
}
tasks.named('processResources').configure {
dependsOn tasks.named('compileJava')
exclude '.cache/**'
// MixinGradle writes the generated refmap into build/tmp/compileJava with a
// task-derived filename, so the jar task will miss it unless resources
// explicitly pick it up and rename it to match the mixin config.
from(generatedMixinRefmap) {
rename { "${archivesBaseName}.refmap.json" }
}
}
minecraft {
// Change to your preferred mappings
mappings channel: 'official', version: '1.16.5'
// Add your AccessTransformer
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED', '--add-opens=java.base/java.util.jar=ALL-UNNAMED'
mods {
configurablezombieai {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED', '--add-opens=java.base/java.util.jar=ALL-UNNAMED'
mods {
configurablezombieai {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
jvmArgs '--add-exports=java.base/sun.security.util=ALL-UNNAMED', '--add-opens=java.base/java.util.jar=ALL-UNNAMED'
args '--mod', 'configurablezombieai', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
mods {
configurablezombieai {
source sourceSets.main
}
}
}
}
}
mixin {
// Kotlin owns most of the gameplay code, but the actual injections are Java
// mixins and still need a generated refmap.
add sourceSets.main, "${archivesBaseName}.refmap.json"
config "${archivesBaseName}.mixins.json"
}
// Include assets and data from data generators
sourceSets.main.resources { srcDirs 'src/generated/resources/' }
repositories {
maven {
name = 'Sponge'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
}
}
dependencies {
// Use the latest version of Minecraft Forge
minecraft 'net.minecraftforge:forge:1.16.5-36.2.42'
// Use the latest version of KotlinForForge
implementation 'thedarkcolour:kotlinforforge:1.14.0'
compileOnly 'org.spongepowered:mixin:0.8.5'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
jar {
duplicatesStrategy = org.gradle.api.file.DuplicatesStrategy.EXCLUDE
archiveClassifier = 'dev'
manifest {
attributes([
"Specification-Title": "configurablezombieai",
"Specification-Vendor": "Oggvik",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"Oggvik",
"MixinConfigs": "${archivesBaseName}.mixins.json",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
tasks.register('syncReleaseJar', Copy) {
dependsOn tasks.named('reobfJar')
from(layout.buildDirectory.file('reobfJar/output.jar'))
into(layout.buildDirectory.dir('libs'))
rename { "${archivesBaseName}-${version}.jar" }
}
// Dev runs use deobfuscated names, so keep that jar clearly marked. The
// release artifact copied back into build/libs is the reobfuscated jar that
// should be distributed to normal Forge launchers.
jar.finalizedBy('reobfJar')
tasks.named('assemble').configure {
dependsOn tasks.named('syncReleaseJar')
}