forked from Tfarcenim/FabricFastBench
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
108 lines (89 loc) · 3.63 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
plugins {
alias(libs.plugins.loom)
alias(libs.plugins.minotaur)
alias(libs.plugins.cursegradle)
id 'maven-publish'
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
}
final isPublish = System.getenv("GITHUB_EVENT_NAME") == "release"
final isRelease = System.getenv("BUILD_RELEASE")?.toBoolean() ?: false
final isActions = System.getenv("GITHUB_ACTIONS")?.toBoolean() ?: false
final baseVersion = "$projectVersion+mc.${libs.versions.minecraft.version.get()}"
version = isRelease ? baseVersion :
isActions ? "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}" :
"$baseVersion-build.local"
group = project.maven_group
dependencies {
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabric.loader)
compileOnly(libs.bundles.compile)
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version,
"java": java.targetCompatibility.majorVersion,
"minecraftRequired": libs.versions.minecraft.required.get()
}
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import java.nio.charset.StandardCharsets
final ref = System.getenv("GITHUB_REF")
final String _changelog = System.getenv("CHANGELOG") ?:
(ref != null && ref.startsWith("refs/tags/")) ?
"You may view the changelog at https://github.com/Modflower/music-moods/releases/tag/${URLEncoder.encode(ref.substring(10), StandardCharsets.UTF_8)}" :
"No changelog is available. Perhaps poke at https://github.com/Modflower/music-moods for a changelog?"
final type = System.getenv("RELEASE_OVERRIDE") ?:
projectVersion?.contains("alpha") ? "alpha" :
!isRelease || projectVersion.contains('-') ? "beta" :
"release"
final minecraftCompatible = libs.versions.minecraft.compatible.get().split(",").toList()
task curseforge(type: TaskPublishCurseForge) {
apiToken = System.getenv("CURSEFORGE_TOKEN")
final def mainFile = upload(curseforgeId, tasks.remapJar)
mainFile.changelog = _changelog
mainFile.changelogType = "markdown"
mainFile.releaseType = type
mainFile.addJavaVersion("Java " + java.targetCompatibility.majorVersion)
mainFile.addGameVersion(*minecraftCompatible)
mainFile.addEnvironment("Server")
mainFile.addModLoader("Fabric", "Quilt")
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(modrinthId)
versionType.set(type)
changelog.set(_changelog)
uploadFile.set(tasks.remapJar)
gameVersions.set(minecraftCompatible)
loaders.addAll("fabric", "quilt")
}