-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
174 lines (141 loc) · 4.89 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
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Copyright © 2024-2025 Jaxydog
*
* This file is part of Lodestone.
*
* Lodestone is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* Lodestone is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Lodestone. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id "fabric-loom" version "1.10-SNAPSHOT"
id "maven-publish"
id "com.modrinth.minotaur" version "2.+"
id "com.github.breadmoirai.github-release" version "2.+"
}
version = project.mod_version
group = project.maven_group
base { archivesName = project.archives_base_name }
repositories {}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") { expand "version": project.version }
}
tasks.withType(JavaCompile).configureEach { it.options.release = 21 }
tasks.githubRelease.dependsOn(tasks.build)
tasks.modrinth.dependsOn(tasks.build, tasks.modrinthSyncBody)
tasks.register("release") { it.dependsOn(tasks.githubRelease, tasks.modrinth) }
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
repositories {
maven { url 'https://jitpack.io' }
}
}
if (System.getenv("GITHUB_GRADLE_TOKEN") != null) {
githubRelease {
token = System.getenv("GITHUB_GRADLE_TOKEN")
owner = "Jaxydog"
repo = "Lodestone"
tagName = mod_version
releaseName = "Lodestone ${mod_version}"
prerelease = !currentVersionType.equalsIgnoreCase("release")
body = currentChangelog
draft = false
releaseAssets = files(
remapJar.destinationDirectory.getAsFileTree().matching {
it.include("lodestone-${mod_version}*.jar")
}
)
dryRun = publish_debug.equalsIgnoreCase("true")
}
}
if (System.getenv("MODRINTH_TOKEN") != null) {
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinth_id
versionName = "Lodestone ${project.mod_version}"
versionType = currentVersionType
changelog = currentChangelog
gameVersions = [ "1.21.4",
"1.21.3",
"1.21.2",
"1.21.1",
"1.21",
"1.20.6",
"1.20.5",
"1.20.4",
"1.20.3",
"1.20.2",
"1.20.1",
"1.20",
"1.19.4",
"1.19.3",
"1.19.2",
"1.19.1",
"1.19",
"1.18.2",
"1.18.1",
"1.18" ]
uploadFile = remapJar
additionalFiles = [ remapSourcesJar, javadocJar ]
syncBodyFrom = rootProject.file("README.md").text
debugMode = project.publish_debug.equalsIgnoreCase("true")
dependencies {
required.project "fabric-api"
}
}
}
@SuppressWarnings('ChangeToOperator')
String getCurrentVersionType() {
final String[] parts = project.mod_version.split("-")
if (parts.length == 1 || parts[ 1 ].matches("release")) return "release"
if (parts.length == 2 && parts[ 1 ].matches("beta|rc\\d")) return "beta"
if (parts.length == 2 && parts[ 1 ].matches("alpha")) return "alpha"
throw new IllegalArgumentException("Invalid version number: %s".formatted(project.mod_version))
}
String getCurrentChangelog() {
final File file = file "docs/CHANGELOG.md"
if (!file.exists()) throw new IOException("Missing changelog file")
String changelog = ""
boolean shouldCapture = false
boolean shouldStop = false
file.eachLine { String line ->
if (shouldStop) return void
if (shouldCapture) {
if (line.startsWith("---")) {
shouldStop = true
} else {
changelog += line + '\n'
}
} else {
shouldCapture = line.startsWith("# ") && line.contains("${project.version}")
}
return void
}
return changelog.trim()
}