forked from RandomMcSomethin/fallingleaves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
148 lines (123 loc) · 4.2 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
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version '2.+'
}
version = "${project.mod_version}+${project.minecraft_version}"
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
maven { url 'https://maven.shedaniel.me/' }
maven { url 'https://maven.terraformersmc.com/' }
maven { url 'https://jitpack.io' }
mavenCentral()
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}"))
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modCompileOnly "com.github.Fourmisain:fabric-seasons:jitpack-SNAPSHOT"
}
processResources {
// expand all properties from gradle.properties
def stringProperties = providers.gradlePropertiesPrefixedBy('').get()
stringProperties.each { inputs.property(it.key, it.value) }
['fabric.mod.json', "${project.mod_id}.mixins.json"].each {
filesMatching(it) {
expand(stringProperties) {
escapeBackslash = true
}
}
}
}
tasks.withType(JavaCompile).configureEach {
it.options.compilerArgs.add('-Xlint:deprecation')
it.options.release = project.java_version as Integer
}
java {
targetCompatibility = sourceCompatibility = project.java_version as Integer
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.mod_id}" }
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
def changesMd = file('changes.md').getText('UTF-8')
def toList = (String s) -> s.split(',').collect{ it.trim() }
def gameVersionList = toList(project.game_version_list)
modrinth {
def MODRINTH_TOKEN = System.getenv('MODRINTH_TOKEN')
if (MODRINTH_TOKEN != null) {
token = MODRINTH_TOKEN
projectId = project.modrinth_id
versionName = project.mod_version
versionNumber = project.version
versionType = 'release'
uploadFile = remapJar
changelog = changesMd
gameVersions = gameVersionList
loaders = ['fabric']
dependencies {
toList(project.modrinth_dependencies).each{ required.project(it) }
toList(project.modrinth_optional_dependencies).each{ optional.project(it) }
}
}
}
curseforge {
def CURSEFORGE_TOKEN = System.getenv('CURSEFORGE_TOKEN')
if (CURSEFORGE_TOKEN != null) {
apiKey = CURSEFORGE_TOKEN
project {
id = project.curseforge_id
releaseType = 'release'
changelogType = 'markdown'
changelog = changesMd
addGameVersion 'Fabric'
gameVersionList.each{ addGameVersion(it) }
relations {
toList(project.curseforge_dependencies).each{ requiredDependency(it) }
toList(project.curseforge_optional_dependencies).each{ optionalDependency(it) }
}
mainArtifact(remapJar.archiveFile.get().asFile) {
displayName = "${project.mod_version} [${versionRange(gameVersionList)}]"
}
afterEvaluate {
uploadTask.dependsOn('build')
}
}
options {
forgeGradleIntegration = false
javaVersionAutoDetect = false
}
}
}
static String versionRange(List<String> gameVersions) {
if (gameVersions.size() == 1)
return gameVersions[0]
def v0 = gameVersions.first()
def v1 = gameVersions.last()
def m0 = v0.split('[.]')[1]
def m1 = v1.split('[.]')[1]
if (m0 == m1)
return v1
return "${v0} - ${v1}"
}