-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
118 lines (95 loc) · 3.09 KB
/
build.gradle.kts
File metadata and controls
118 lines (95 loc) · 3.09 KB
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.text.SimpleDateFormat
import java.util.*
plugins {
`maven-publish`
alias(libs.plugins.hytale)
alias(libs.plugins.shadow)
}
val javaVersion = 25
val buildTime = Date()
val buildNumber: Int = providers.environmentVariable("BUILD_NUMBER").map { it.toInt() }.orElse(0).get()
val runningOnCI = providers.environmentVariable("CI").orNull.toBoolean()
group = "dev.upcraft.ht"
version = SimpleDateFormat("YY.M.d").format(buildTime)
hytale {
}
repositories {
mavenCentral()
maven("https://maven.hytale-mods.dev/releases")
}
dependencies {
compileOnly(libs.jetbrains.annotations)
compileOnly(libs.jspecify)
shadow(libs.guava)
implementation(libs.guava)
// this mod is optional, but is included so you can preview your mod icon
// in the in-game mod list via the /modlist command
runtimeOnly(libs.bettermodlist)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
withSourcesJar()
}
tasks.named<ProcessResources>("processResources") {
var replaceProperties = mapOf(
"plugin_group" to findProperty("plugin_group"),
"plugin_maven_group" to project.group,
"plugin_name" to project.name,
"plugin_version" to "${project.version}+${buildNumber}",
"server_version" to findProperty("server_version"),
"plugin_description" to findProperty("plugin_description"),
"plugin_website" to findProperty("plugin_website"),
"plugin_main_entrypoint" to findProperty("plugin_main_entrypoint")
)
filesMatching("manifest.json") {
expand(replaceProperties)
}
inputs.properties(replaceProperties)
}
tasks.withType<Jar> {
manifest {
attributes["Specification-Title"] = rootProject.name
attributes["Specification-Version"] = version
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] =
providers.environmentVariable("COMMIT_SHA_SHORT")
.map { "${version}-${it}" }
.getOrElse(version.toString())
}
}
tasks.jar {
archiveClassifier = "slim"
}
val shadowJar = tasks.named<ShadowJar>("shadowJar") {
archiveClassifier = null
configurations = project.configurations.shadow.map { listOf(it) }
}
tasks.assemble.configure {
dependsOn(shadowJar)
}
publishing {
repositories {
maven("https://maven.hytale-mods.dev/releases") {
credentials {
username = providers.environmentVariable("HM_RELEASES_MAVEN_USER").orNull
password = providers.environmentVariable("HM_RELEASES_MAVEN_TOKEN").orNull
}
}
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
suppressPomMetadataWarningsFor("runtimeElements")
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
isDownloadSources = !runningOnCI
isDownloadJavadoc = !runningOnCI
}
}