-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
81 lines (68 loc) · 2.19 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
plugins {
id 'fabric-loom' version "${loomVersion}-SNAPSHOT"
}
def modId = project.modName.toLowerCase()
def repoUrl = "https://github.com/${author}/${modName}"
version = "mc${minMinecraftVersion}+${modVersion}"
group = "com." + project.author
base {
archivesName = modId
}
repositories {
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${minMinecraftVersion}"
mappings "net.fabricmc:yarn:${minMinecraftVersion}+build.${mappingsBuild}:v2"
modImplementation "net.fabricmc:fabric-loader:${minLoaderVersion}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${apiVersion}+${minMinecraftVersion}"
}
processResources {
def propertyMap = [
'modId' : modId,
'modVersion' : modVersion,
'modName' : modName,
'author' : author,
'repoUrl' : repoUrl,
'minJavaVersion' : minJavaVersion,
'minMinecraftVersion': minMinecraftVersion,
'minLoaderVersion' : minLoaderVersion
]
inputs.properties(propertyMap)
filesMatching("fabric.mod.json") {
expand(propertyMap)
}
}
sourceSets {
main {
resources.srcDirs += ['src/main/generated']
java.srcDirs += ['src/main/generated/java']
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release.set(minJavaVersion.toInteger())
}
tasks.register('generateBuildConfig', DefaultTask) {
doLast {
def templateFile = file("$projectDir/gradle/BuildConfig.java.txt")
def configFile = file("$projectDir/src/main/generated/java/com/${author}/${modId}/BuildConfig.java")
configFile.getParentFile().mkdirs()
configFile.text = templateFile.text
.replace('${author}', author)
.replace('${modId}', modId)
.replace('${modName}', modName)
}
}
java {
sourceCompatibility = targetCompatibility = minJavaVersion.toInteger()
}
jar {
from('LICENSE') {
rename { "${it}_${modId}" }
}
compileJava.dependsOn(generateBuildConfig)
}
loom {
accessWidenerPath.set(file("src/main/resources/${modId}.accesswidener"))
}