-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
149 lines (126 loc) · 4.98 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
import java.nio.file.Files
import java.nio.file.StandardCopyOption
plugins {
id "architectury-plugin" version "${architectury_plugin_version}"
id "dev.architectury.loom" version "${architectury_loom_version}" apply false
id "me.shedaniel.unified-publishing" version "${unified_publishing_version}" apply false
}
architectury {
minecraft = rootProject.minecraft_version
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.16.5+build.10:v2"
// Loom (Fabric / Quilt / Architectury )
}
tasks.withType(ProcessResources) {
processResources {
outputs.upToDateWhen { false }
def p1 = 'git rev-parse HEAD'.execute()
p1.waitFor()
project.setProperty("github_commit_hash", p1.text.trim())
filesMatching([rootProject.forge_config, rootProject.fabric_config, "pack.mcmeta", "data/kubejsoffline/html/js/constants.js"]) {
expand project.properties
}
}
}
// // Before runClient task clear version specific kubejs scripts
// tasks.register("beforeRunClient") {
// // Clear the forge and fabric kubejs scripts directories
// doFirst {
// println("Clearing existing kubejs scripts to prevent different versions from conflicting")
// var scriptDir = ["run/kubejs/server_scripts", "run/kubejs/startup_scripts", "run/kubejs/client_scripts"]
// scriptDir.forEach { sdir ->
// var pat = project.projectDir.toPath().resolve(sdir)
//
// if (pat.toFile().deleteDir()) {
// println "Deleted ${pat}"
// } else {
// println "Failed to delete ${pat}"
// }
// }
// }
// }
//
// tasks.getByName("runClient") {
// dependsOn "beforeRunClient"
// }
}
allprojects {
ext.ENV = System.getenv()
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
group = rootProject.maven_group
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.
maven {
// Shedaniel's maven (Architectury API)
url = "https://maven.architectury.dev"
content {
includeGroup "me.shedaniel"
}
}
maven {
// saps.dev Maven (KubeJS and Rhino)
url = "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
}
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}
java {
withSourcesJar()
}
}
class MoveDocumentationFiles extends DefaultTask {
// Store references to the forge and fabric html file directories
private final File forgeHtmlDir = new File("${project.projectDir}/forge/run/kubejs/documentation/index.html")
private final File fabricHtmlDir = new File("${project.projectDir}/fabric/run/kubejs/documentation/index.html")
// Store references to the forge and fabric output directories
private final File forgeOutputDir = new File("${project.projectDir}/docs/${project.minecraft_version}/forge/index.html")
private final File fabricOutputDir = new File("${project.projectDir}/docs/${project.minecraft_version}/fabric/index.html")
@TaskAction
def moveFiles() {
// If the forge file exists, move it to the forge output directory
if (forgeHtmlDir.exists()) {
Files.move(forgeHtmlDir.toPath(), forgeOutputDir.toPath(), StandardCopyOption.REPLACE_EXISTING)
println "Moved Forge documentation file to ${forgeOutputDir}"
} else {
println "Forge documentation file does not exist!"
}
// If the fabric file exists, move it to the fabric output directory
if (fabricHtmlDir.exists()) {
Files.move(fabricHtmlDir.toPath(), fabricOutputDir.toPath(), StandardCopyOption.REPLACE_EXISTING)
println "Moved Fabric documentation file to ${fabricOutputDir}"
} else {
println "Fabric documentation file does not exist!"
}
}
@TaskAction
def greet() {
moveFiles()
}
}
task updateDocumentation(type: MoveDocumentationFiles) {
group = 'documentation'
description = 'Moves the documentation files to the docs directory'
}