-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
127 lines (103 loc) · 3.61 KB
/
build.gradle.kts
File metadata and controls
127 lines (103 loc) · 3.61 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
119
120
121
122
123
124
125
126
127
plugins {
`maven-publish`
id("hytale-mod") version "0.+"
}
group = "cool.bot"
version = "1.0.0"
val javaVersion = 25
repositories {
mavenCentral()
maven("https://maven.hytale-modding.info/releases") {
name = "HytaleModdingReleases"
}
}
dependencies {
compileOnly(libs.jetbrains.annotations)
compileOnly(libs.jspecify)
}
hytale {
// uncomment if you want to add the Assets.zip file to your external libraries;
// ⚠️ CAUTION, this file is very big and might make your IDE unresponsive for some time!
//
addAssetsDependency = true
// uncomment if you want to develop your mod against the pre-release version of the game.
//
// updateChannel = "pre-release"
}
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 findProperty("plugin_version"),
"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"),
"plugin_author" to findProperty("plugin_author")
)
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())
}
}
publishing {
repositories {
// This is where you put repositories that you want to publish to.
// Do NOT put repositories for your dependencies here.
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
val syncAssets = tasks.register<Copy>("syncAssets") {
group = "hytale"
description = "Automatically syncs assets from Build back to Source after server stops."
// Take from the temporary build folder (Where the game saved changes)
from(layout.buildDirectory.dir("resources/main"))
// Copy into your actual project source (Where your code lives)
into("src/main/resources")
// IMPORTANT: Protect the manifest template from being overwritten
exclude("manifest.json")
// If a file exists, overwrite it with the new version from the game
duplicatesStrategy = DuplicatesStrategy.INCLUDE
doLast {
println("✅ Assets successfully synced from Game to Source Code!")
}
}
afterEvaluate {
// Now Gradle will find it, because the plugin has finished working
val targetTask = tasks.findByName("runServer") ?: tasks.findByName("server")
if (targetTask != null) {
targetTask.finalizedBy(syncAssets)
logger.lifecycle("✅ specific task '${targetTask.name}' hooked for auto-sync.")
} else {
logger.warn("⚠️ Could not find 'runServer' or 'server' task to hook auto-sync into.")
}
}