-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.gradle
190 lines (161 loc) · 4.24 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
import static aurorasdeco.Constants.*
plugins {
id 'aurorasdeco.common'
id 'com.modrinth.minotaur' version '2.+'
id 'com.matthewprenger.cursegradle' version '1.4.+'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
group = project.maven_group
version = "${project.mod_version}+${MINECRAFT_VERSION.version()}"
base.archivesName = project.archives_base_name
if (!(System.getenv("CURSEFORGE_TOKEN") || System.getenv("MODRINTH_TOKEN"))) {
version += "-local"
}
logger.lifecycle("Preparing version ${version}...")
boolean isMCVersionNonRelease() {
return MINECRAFT_VERSION.version().matches('^\\d\\dw\\d\\d[a-z]$')
|| MINECRAFT_VERSION.version().matches('\\d+\\.\\d+-(pre|rc)(\\d+)')
}
String parseReadme() {
def linkRegex = /!\[([A-z_ ]+)]\((images\/[A-z.\/_]+)\)/
def readme = (String) file('README.md').text
readme = readme.replaceAll(linkRegex, '![$1](https://lambdaurora.dev/AurorasDecorations/$2)')
return readme
}
String fetchChangelog() {
def changelogText = file('CHANGELOG.md').text
def regexVersion = ((String) project.mod_version).replace('.', '\\.').replace('+', '\\+')
def changelogRegex = ~"###? ${regexVersion}(?: - .+)?\\n\\n(( *- .+\\n)+)"
def matcher = changelogText =~ changelogRegex
if (matcher.find()) {
String changelogContent = matcher.group(1)
def changelogLines = changelogText.split('\n')
def linkRefRegex = ~'^\\[([A-z\\d _\\-/+.]+)]: '
for (int i = changelogLines.length - 1; i > 0; i--) {
def line = changelogLines[i]
if ((line =~ linkRefRegex).find())
changelogContent += '\n' + line
else break
}
return changelogContent
} else {
return null
}
}
String getVersionType() {
if (isMCVersionNonRelease() || version.contains("-alpha.")) {
return "alpha"
} else if (version.contains("-beta.")) {
return "beta"
} else {
return "release"
}
}
javafx {
version = '17'
modules = [ 'javafx.media', 'javafx.swing' ]
}
aurorasdeco {
hasEmi = true
hasTrinkets = true
entrypoints {
init {
values = [
entrypoint("dev.lambdaurora.aurorasdeco.AurorasDeco")
]
}
client_init {
values = [
entrypoint("dev.lambdaurora.aurorasdeco.client.AurorasDecoClient"),
entrypoint("dev.lambdaurora.aurorasdeco.hook.TrinketsHooks", hasTrinkets.get())
]
}
emi {
values = [
entrypoint("dev.lambdaurora.aurorasdeco.hook.EmiHooks")
]
enabled.set(hasEmi.get())
}
}
finalizeConfiguration()
}
jar {
from('LICENSE') {
rename { "${it}_${base.archivesName.get()}" }
}
}
modrinth {
projectId = project.modrinth_id
versionName = "Aurora's Decorations ${project.mod_version} (${MINECRAFT_VERSION.version()})"
gameVersions = MINECRAFT_VERSION.all()
loaders = ["quilt"]
versionType = this.getVersionType()
uploadFile = tasks.remapJar
syncBodyFrom = parseReadme()
dependencies {
required.project "qsl"
optional.project "trinkets"
optional.project "emi"
}
// Changelog fetching
def changelogContent = fetchChangelog()
if (changelogContent) {
changelog = changelogContent
} else {
afterEvaluate {
tasks.modrinth.setEnabled(false)
}
}
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
curseforge {
if (System.getenv("CURSEFORGE_TOKEN")) {
apiKey = System.getenv("CURSEFORGE_TOKEN")
}
project {
id = project.curseforge_id
releaseType = this.getVersionType()
MINECRAFT_VERSION.all().forEach {
addGameVersion it
}
addGameVersion "Quilt"
addGameVersion "Java 17"
addGameVersion "Java 18"
// Changelog fetching
def changelogContent = fetchChangelog()
if (changelogContent) {
changelogType = "markdown"
changelog = "Changelog:\n\n${changelogContent}"
} else {
afterEvaluate {
uploadTask.setEnabled(false)
}
}
mainArtifact(remapJar) {
displayName = "Aurora's Decorations ${project.mod_version} (${MINECRAFT_VERSION.version()})"
relations {
requiredDependency "qsl"
optionalDependency "trinkets"
optionalDependency "emi"
}
}
afterEvaluate {
uploadTask.setGroup("publishing")
uploadTask.dependsOn("remapJar")
}
}
}
tasks.curseforge.setGroup("publishing")
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}