-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
193 lines (164 loc) · 6.16 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
// Attach plugins
plugins {
id 'net.minecraftforge.gradle' version '5.+'
id 'java-library'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
}
// Standard Project Information
version = "$project.minecraftVersion-$project.modSpecVer.$project.modImplVer"
group = project.userGroup
archivesBaseName = project.modId
// Sets the toolchain to compile against OpenJDK 8
java.toolchain {
languageVersion = JavaLanguageVersion.of(8)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
// Add generated source set and attach to main source set
sourceSets {
api
generated
main{
java {
srcDirs += sourceSets.api.java.srcDirs
}
resources {
srcDirs += sourceSets.api.resources.srcDirs
srcDirs += sourceSets.generated.resources.srcDirs
exclude '.cache/'
}
}
}
minecraft {
// The mappings can be changed at any time, and must be in the following format:
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly
// stable # Stables are built at the discretion of the MCP team
// official MCVersion Official field/method names from Mojang mapping files
//
// You must be aware of the Mojang license when using the 'official' mappings
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Use non-default mappings at your own risk. they may not always work
// Simply re-run your setup task after changing the mappings to update your workspace
mappings channel: project.mappingsType, version: project.mappingsVersion
// Exposes fields, methods, constructors, and classes for use within the mod
// Set modTransformer to 'true' within gradle.properties to enable
if (project.hasProperty('modTransformer') && project.getProperty('modTransformer').toBoolean())
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations
// These can be tweaked, removed, or duplicated as needed
runs {
// Client run configuration
client {
// Directory for the project to run in
workingDirectory file('run/client')
// Add mixin configuration argument
arg '-mixin.config=' + project.modId + '.mixins.json'
// Set the console logging level
property 'forge.logging.console.level', 'debug'
// Attach the sources to the run
mods.create(project.modId).source(sourceSets.main)
}
// Server run configuration
server {
workingDirectory file('run/server')
arg '-mixin.config=' + project.modId + '.mixins.json'
property 'forge.logging.console.level', 'debug'
mods.create(project.modId).source(sourceSets.main)
}
// Data run configuration
data {
workingDirectory file('run/data')
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources
args '--mod', project.modId,
'--all',
'--output', sourceSets.generated.resources.srcDirs[0],
'--existing', sourceSets.main.resources.srcDirs[0]
mods.create(project.modId).source(sourceSets.main)
}
}
}
repositories {
maven {
name 'Registrate'
url 'https://maven.tterrag.com/'
}
/*maven {
name 'Thiakil Mappings'
url 'https://maven.thiakil.com'
content {
includeGroup 'de.oceanlabs.mcp'
includeGroup 'net.minecraft'
}
}*/
maven {
name 'Just Enough Items'
url 'https://dvs1.progwml6.com/files/maven/'
}
maven {
name 'Titanium'
url 'https://maven.blamejared.com/'
}
flatDir {
dir 'libs'
}
}
configurations {
shade
}
dependencies {
// Include MinecraftForge as a dependency
minecraft group: 'net.minecraftforge', name: 'forge', version: "$project.minecraftVersion-$project.forgeVersion"
// Add exp4j as shaded library for string expression evaluation
def exp4j = 'net.objecthunter:exp4j:latest.release'
implementation exp4j
shade exp4j
// Add Registrate as shaded library
def registrate = "com.tterrag.registrate:Registrate:MC$project.minecraftVersion-$project.registrateVersion"
implementation fg.deobf(registrate)
shade registrate
// Add JEI
compileOnly fg.deobf("mezz.jei:jei-$project.minecraftVersion:$project.jeiVersion:api")
runtimeOnly fg.deobf("mezz.jei:jei-$project.minecraftVersion:$project.jeiVersion")
// Add JUnit for testing
testImplementation "org.junit.jupiter:junit-jupiter-api:$project.junitVersion"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:'
// Add Titanium
implementation fg.deobf("com.hrznstudio:titanium:$project.minecraftVersion-$project.titaniumVersion-10")
// Add DynamicRegistries
implementation fg.deobf('net.ashwork:dynamicregistries:0.1.3')
}
test {
useJUnitPlatform()
}
shadowJar {
configurations = [project.configurations.shade]
relocate 'net.objecthunter.exp4j', "${project.userGroup}.${project.modId}.repack.exp4j"
relocate 'com.tterrag.registrate', "${project.userGroup}.${project.modId}.repack.registrate"
finalizedBy 'reobfShadowJar'
}
// Set attributes of the jar
jar {
finalizedBy 'reobfJar'
// Set manifest information
// Add mixin to jar manifest
manifest.attributes([
'Specification-Title': project.modName,
'Specification-Vendor': project.userName,
'Specification-Version': project.modSpecVer,
'Implementation-Title': project.modName,
'Implementation-Version': project.version,
'Implementation-Vendor': project.userName,
'Implementation-Timestamp': new Date().format('yyyy-MM-dd\'T\'HH:mm:ssZ'),
'MixinConfigs': "${project.modId}.mixins.json"
])
}
// Setup mixin reference map
mixin {
add sourceSets.main, "${project.modId}.refmap.json"
}
reobf {
shadowJar {}
}