Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
143 lines (119 loc) · 3.61 KB
/
Copy pathbuild.gradle
File metadata and controls
143 lines (119 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.yaml:snakeyaml:2.4'
}
}
plugins {
id 'java'
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
mavenCentral()
maven { url 'https://maven.fabricmc.net/' } // Fabric repository for dependencies
}
loom {
splitEnvironmentSourceSets()
mods {
"block4block-mod" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
// Run configurations
runs {
client {
runDir = "run"
}
server {
runDir = "run"
}
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation 'org.yaml:snakeyaml:2.4'
include "org.yaml:snakeyaml:2.4"
}
processResources {
inputs.property "version", project.version
from('src/main/resources') {
include 'block_lists.yml'
include 'config.yml'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
filesMatching("fabric.mod.json") {
expand "version": inputs.properties.version
}
from('src/client/resources') {
include 'block4block-mod.client.mixins.json'
into 'resources' // Copy to the resources directory in the JAR
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
it.options.compilerArgs += ["-Xlint:unchecked"]
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
inputs.property "archivesName", project.base.archivesName
from("LICENSE") {
rename { "${it}_${inputs.properties.archivesName}" }
}
from(sourceSets.client.output.classesDirs) {
into "hasjamon/block4block/mixin/client"
}
}
// --- Task to Download Remote Config and Generate Resource Files ---
tasks.register('downloadAndFillResourceFiles') {
doLast {
println "Downloading remote config.yml from GitHub..."
// URL of the remote config file on GitHub
def configUrl = 'https://raw.githubusercontent.com/Block4Block/Block4Block/master/src/main/resources/config.yml'
try {
// Download and parse the remote YAML
def remoteYaml = new org.yaml.snakeyaml.Yaml()
def remoteConfig = remoteYaml.load(new URL(configUrl).openStream())
// Default config if remote config doesn't have display settings
def defaultDisplay = [
'useAdvancedTooltip': true,
'useLore': false,
'blockForBlockText': "§cBlock for Block",
'freeToBreakText': "§aFree to Break",
'freeInClaimsText': "§bFree in Claims"
]
// Use the default config if no display is found in the remote config
def displayConfig = remoteConfig?.display ?: defaultDisplay
def config = [display: displayConfig]
// File path for the generated config.yml
def configFilePath = 'src/main/resources/config.yml'
// Call Java method to generate YAML
com.example.block4block.YamlHelper.generateConfigYaml(config, configFilePath)
println "Generated config.yml in resources from remote config."
} catch (Exception e) {
println "Error downloading or processing the remote config.yml: ${e.message}"
}
}
}
// Ensure the resource files are generated before processing resources and creating the source JAR.
processResources.dependsOn downloadAndFillResourceFiles
tasks.named("sourcesJar") {
dependsOn(downloadAndFillResourceFiles)
}
build.dependsOn(downloadAndFillResourceFiles)