forked from MinecraftFreecam/Freecam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
213 lines (176 loc) · 7.79 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import net.fabricmc.loom.task.RemapJarTask
import net.xolt.freecam.gradle.BumpVersionTask
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.tasks.BaseChangelogTask
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "com.hypherionmc.modutils.modpublisher" version "2.0.5" apply false
id "com.github.johnrengelman.shadow" version "7.1.2" apply false
id "org.jetbrains.changelog" version "2.2.0"
}
tasks.named('wrapper') {
// Use "all" so we get sources and javadoc too
distributionType = "all"
}
// Helper task that bumps the version number
tasks.register("bumpVersion", BumpVersionTask) {
group = "version"
input = file("gradle.properties")
key = "mod_version"
}
// Move the changelog tasks to the "version" group
tasks.withType(BaseChangelogTask).configureEach {
group = "version"
}
// Don't need these on the root project
afterEvaluate {
tasks.jar.enabled = false
tasks.sourcesJar.enabled = false
}
architectury {
minecraft = rootProject.minecraft_version
}
changelog {
// Use the mod_version in gradle.properties as the release version/tag.
// Build tag/diff links using the github repo URL.
version = project.mod_version
repositoryUrl = project.source_code_url
// Title & intro are printed right at the start of the changelog.
// The values here will replace whatever exists in the file when patching.
title = "Changelog"
introduction = """
All notable changes to this project will be documented in this file.
This file is formatted as per [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
and Freecam's versioning is based on [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
""".stripIndent()
// Group sub-headings added to the "unreleased" section when patching the changelog.
// Other sub-headings can still be added manually, if required.
groups = [
"Added",
"Changed",
"Removed",
"Fixed",
]
// Regex used to find versions in headings.
// The default regex only supports semantic versions, this one is more lenient.
headerParserRegex = ~/(\d+(?:\.\d+)+)/
}
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
version = "${project.mod_version}+mc${project.minecraft_version}"
group = rootProject.maven_group
base {
// Format archive names, e.g. 'freecam-fabric-1.2.3+mc1.20.4.jar'
archivesName = rootProject.name + project.path.replaceAll(':', '-')
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
maven { url "https://maven.parchmentmc.org/" }
maven { url "https://maven.neoforged.net/releases/" }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}
java {
withSourcesJar()
}
jar {
from "LICENSE"
}
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
accessWidenerPath = project(":common").file "src/main/resources/freecam.accesswidener"
runs {
client {
// Pretty run-config name
// Note: we can't disable the (:path) suffix
// https://github.com/architectury/architectury-loom/blob/5b3e7c72b665f7eb38c23ceb677027acdc867398/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java#L117
configName "Run"
}
remove server // We only need client runs
}
silentMojangMappingsLicense()
}
dependencies {
def parchmentAppendix = rootProject.parchment_version.split('-')[0]
def parchmentVersion = rootProject.parchment_version.split('-')[1]
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchmentAppendix}:${parchmentVersion}@zip")
}
}
if (rootProject.enabled_platforms.split(',').contains project.name) {
apply plugin: "com.hypherionmc.modutils.modpublisher"
// Ensure this task exists, since we need to publish its output
tasks.maybeCreate("remapModrinthJar", RemapJarTask)
publisher {
curseID = "557076"
modrinthID = "XeEZ3fK2"
// Format display name "[Fabric] Freecam 1.2.2 for MC 1.20.4"
displayName = "[${project.name.capitalize()}] ${rootProject.name.capitalize()} ${rootProject.mod_version} for MC ${rootProject.minecraft_version}"
version = project.version
versionType = rootProject.release_type
curseEnvironment = "client"
loaders = [ project.name ]
javaVersions = ["Java ${project.java.targetCompatibility.getMajorVersion()}"]
// Get the changelog entry using the changelog plugin
changelog = provider {
def plugin = rootProject.changelog
def version = rootProject.mod_version
if (!plugin.has(version)) {
logger.warn "No changelog for \"${version}\". Using \"unreleased\" instead."
}
def logEntry = (plugin.getOrNull(version) ?: plugin.getUnreleased())
.withHeader(false)
.withLinks(false)
.withEmptySections(false)
.withSummary(true)
return plugin.renderItem(logEntry, Changelog.OutputType.MARKDOWN)
}
// List the current `minecraft_version`, everything in `supported_mc_versions`, &
// everything in the current mod loader's `*_supported_mc_versions` as a supported version
gameVersions = provider {
String prop = "supported_mc_versions"
String primary = rootProject.property("minecraft_version")
String common = rootProject.findProperty(prop) ?: ""
String specific = rootProject.findProperty("${project.name}_${prop}") ?: ""
return (common.split(",") + specific.split(",") + [ primary ])
.findAll { it != null }
.findAll { it != "" }
.collect { it.trim() }
.unique()
}
artifact = tasks.remapJar
setPlatformArtifact "modrinth", tasks.remapModrinthJar
[ curseDepends, modrinthDepends ].each {
it.embedded "cloth-config"
}
def dummy = "default"
apiKeys {
curseforge findProperty("curseforge_token") ?: System.getenv("CURSEFORGE_TOKEN") ?: dummy
modrinth findProperty("modrinth_token") ?: System.getenv("MODRINTH_TOKEN") ?: dummy
}
debug = [ apiKeys.curseforge, apiKeys.modrinth ].contains dummy
}
tasks.publish.dependsOn tasks.publishMod
}
}