|
3 | 3 | import org.apache.tools.ant.taskdefs.condition.Os |
4 | 4 |
|
5 | 5 | plugins { |
6 | | - id("fabric-loom") version "1.10.0-bta" |
7 | | - id("java") |
| 6 | + id("fabric-loom") |
| 7 | + java |
8 | 8 | } |
9 | 9 |
|
10 | | -val lwjglVersion = "3.3.4" |
11 | | - |
| 10 | +val lwjglVersion = providers.gradleProperty("lwjgl_version") |
12 | 11 | val lwjglNatives = when { |
13 | 12 | Os.isFamily(Os.FAMILY_UNIX) && !Os.isFamily(Os.FAMILY_MAC) -> "natives-linux" |
14 | 13 | Os.isFamily(Os.FAMILY_WINDOWS) -> "natives-windows" |
15 | 14 | Os.isFamily(Os.FAMILY_MAC) -> "natives-macos${if (Os.isArch("aarch64")) "-arm64" else ""}" |
16 | 15 | else -> error("Unsupported OS") |
17 | 16 | } |
18 | 17 |
|
19 | | -val mod_group: String by project |
20 | | -val mod_name: String by project |
21 | | -val mod_version: String by project |
| 18 | +val modVersion = providers.gradleProperty("mod_version") |
| 19 | +val modGroup = providers.gradleProperty("mod_group") |
| 20 | +val modName = providers.gradleProperty("mod_name") |
| 21 | + |
| 22 | +val btaChannel = providers.gradleProperty("bta_channel") |
| 23 | +val btaVersion = providers.gradleProperty("bta_version") |
22 | 24 |
|
23 | | -val bta_channel: String by project |
24 | | -val bta_version: String by project |
| 25 | +val loaderVersion = providers.gradleProperty("loader_version") |
25 | 26 |
|
26 | | -val loader_version: String by project |
| 27 | +val halplibeVersion = providers.gradleProperty("halplibe_version") |
| 28 | +val modMenuVersion = providers.gradleProperty("mod_menu_version") |
27 | 29 |
|
28 | | -val halplibe_version: String by project |
29 | | -val mod_menu_version: String by project |
| 30 | +val slf4jApiVersion = providers.gradleProperty("slf4j_api_version") |
| 31 | +val log4jVersion = providers.gradleProperty("log4j_version") |
| 32 | +val guavaVersion = providers.gradleProperty("guava_version") |
| 33 | +val gsonVersion = providers.gradleProperty("gson_version") |
| 34 | +val commonsLang3Version = providers.gradleProperty("commons_lang3_version") |
30 | 35 |
|
31 | | -group = mod_group |
32 | | -base.archivesName.set(mod_name) |
33 | | -version = mod_version |
| 36 | +val javaVersion = providers.gradleProperty("java_version") |
| 37 | + |
| 38 | +group = modGroup.get() |
| 39 | +base.archivesName = modName.get() |
| 40 | +version = modVersion.get() |
34 | 41 |
|
35 | 42 | loom { |
36 | 43 | noIntermediateMappings() |
37 | | - customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/$bta_channel/v$bta_version/manifest.json") |
| 44 | + customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/v${btaVersion.get()}/manifest.json") |
38 | 45 | } |
39 | 46 |
|
40 | 47 | repositories { |
41 | 48 | mavenCentral() |
42 | | - maven { url = uri("https://jitpack.io") } |
43 | | - maven { |
44 | | - name = "Babric" |
45 | | - url = uri("https://maven.glass-launcher.net/babric") |
46 | | - } |
47 | | - maven { |
48 | | - name = "Fabric" |
49 | | - url = uri("https://maven.fabricmc.net/") |
50 | | - } |
51 | | - maven { |
52 | | - name = "SignalumMavenInfrastructure" |
53 | | - url = uri("https://maven.thesignalumproject.net/infrastructure") |
54 | | - } |
55 | | - maven { |
56 | | - name = "SignalumMavenReleases" |
57 | | - url = uri("https://maven.thesignalumproject.net/releases") |
58 | | - } |
59 | | - ivy { |
60 | | - url = uri("https://github.com/Better-than-Adventure") |
61 | | - patternLayout { |
62 | | - artifact("[organisation]/releases/download/v[revision]/[module].jar") |
63 | | - } |
| 49 | + maven("https://jitpack.io") |
| 50 | + maven("https://maven.glass-launcher.net/babric") { name = "Babric" } |
| 51 | + maven("https://maven.fabricmc.net/") { name = "Fabric" } |
| 52 | + maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" } |
| 53 | + maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" } |
| 54 | + ivy("https://github.com/Better-than-Adventure") { |
| 55 | + patternLayout { artifact("[organisation]/releases/download/v[revision]/[module].jar") } |
64 | 56 | metadataSources { artifact() } |
65 | 57 | } |
66 | | - ivy { |
67 | | - url = uri("https://downloads.betterthanadventure.net/bta-client/$bta_channel/") |
68 | | - patternLayout { |
69 | | - artifact("/v[revision]/client.jar") |
70 | | - } |
| 58 | + ivy("https://downloads.betterthanadventure.net/bta-client/${btaChannel.get()}/") { |
| 59 | + patternLayout { artifact("/v[revision]/client.jar") } |
71 | 60 | metadataSources { artifact() } |
72 | 61 | } |
73 | | - ivy { |
74 | | - url = uri("https://downloads.betterthanadventure.net/bta-server/$bta_channel/") |
75 | | - patternLayout { |
76 | | - artifact("/v[revision]/server.jar") |
77 | | - } |
| 62 | + ivy("https://downloads.betterthanadventure.net/bta-server/${btaChannel.get()}/") { |
| 63 | + patternLayout { artifact("/v[revision]/server.jar") } |
78 | 64 | metadataSources { artifact() } |
79 | 65 | } |
80 | | - ivy { |
81 | | - url = uri("https://piston-data.mojang.com") |
82 | | - patternLayout { |
83 | | - artifact("v1/[organisation]/[revision]/[module].jar") |
84 | | - } |
| 66 | + ivy("https://piston-data.mojang.com") { |
| 67 | + patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") } |
85 | 68 | metadataSources { artifact() } |
86 | 69 | } |
87 | 70 | } |
88 | 71 |
|
89 | 72 | dependencies { |
90 | | - minecraft("::${bta_version}") |
| 73 | + minecraft("::${btaVersion.get()}") |
91 | 74 | mappings(loom.layered {}) |
92 | 75 |
|
93 | | - modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45") // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar |
94 | | - modImplementation("net.fabricmc:fabric-loader:$loader_version") |
95 | | - |
96 | | - // Helper library |
97 | | - // If you do not need Halplibe you can comment this line out or delete this line |
98 | | - modImplementation("turniplabs:halplibe:$halplibe_version") |
99 | | - |
100 | | - modImplementation("turniplabs:modmenu-bta:$mod_menu_version") |
101 | | - |
102 | | - implementation("org.slf4j:slf4j-api:1.8.0-beta4") |
103 | | - implementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0") |
104 | | - |
105 | | - implementation("com.google.guava:guava:33.0.0-jre") |
106 | | - implementation("com.google.code.gson:gson:2.10.1") |
107 | | - |
108 | | - val log4jVersion = "2.20.0" |
109 | | - implementation("org.apache.logging.log4j:log4j-core:$log4jVersion") |
110 | | - implementation("org.apache.logging.log4j:log4j-api:$log4jVersion") |
111 | | - implementation("org.apache.logging.log4j:log4j-1.2-api:$log4jVersion") |
112 | | - |
113 | | - implementation("org.apache.commons:commons-lang3:3.12.0") |
114 | | - include("org.apache.commons:commons-lang3:3.12.0") |
115 | | - |
116 | | - modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5") |
117 | | - implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion")) |
118 | | - |
119 | | - runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives") |
120 | | - runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives") |
121 | | - runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives") |
122 | | - runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives") |
123 | | - runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives") |
124 | | - runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives") |
125 | | - implementation("org.lwjgl:lwjgl:$lwjglVersion") |
126 | | - implementation("org.lwjgl:lwjgl-assimp:$lwjglVersion") |
127 | | - implementation("org.lwjgl:lwjgl-glfw:$lwjglVersion") |
128 | | - implementation("org.lwjgl:lwjgl-openal:$lwjglVersion") |
129 | | - implementation("org.lwjgl:lwjgl-opengl:$lwjglVersion") |
130 | | - implementation("org.lwjgl:lwjgl-stb:$lwjglVersion") |
131 | | -} |
132 | | - |
133 | | -java { |
134 | | - sourceCompatibility = JavaVersion.VERSION_1_8 |
135 | | - targetCompatibility = JavaVersion.VERSION_1_8 |
136 | | - withSourcesJar() |
137 | | -} |
138 | | - |
139 | | -tasks.compileJava { |
140 | | - options.release.set(8) |
| 76 | + // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar |
| 77 | + modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45") |
| 78 | + // If you do not need Halplibe you can comment out or delete this line. |
| 79 | + modImplementation("turniplabs:halplibe:${halplibeVersion.get()}") |
| 80 | + modImplementation("turniplabs:modmenu-bta:${modMenuVersion.get()}") |
| 81 | + modImplementation("net.fabricmc:fabric-loader:${loaderVersion.get()}") |
| 82 | + modImplementation("com.github.Better-than-Adventure:legacy-lwjgl3:1.0.5") |
| 83 | + |
| 84 | + implementation(platform("org.lwjgl:lwjgl-bom:${lwjglVersion.get()}")) |
| 85 | + implementation("org.slf4j:slf4j-api:${slf4jApiVersion.get()}") |
| 86 | + |
| 87 | + implementation("com.google.guava:guava:${guavaVersion.get()}") |
| 88 | + implementation("com.google.code.gson:gson:${gsonVersion.get()}") |
| 89 | + |
| 90 | + implementation("org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion.get()}") |
| 91 | + implementation("org.apache.logging.log4j:log4j-core:${log4jVersion.get()}") |
| 92 | + implementation("org.apache.logging.log4j:log4j-api:${log4jVersion.get()}") |
| 93 | + implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion.get()}") |
| 94 | + |
| 95 | + implementation("org.apache.commons:commons-lang3:${commonsLang3Version.get()}") |
| 96 | + include("org.apache.commons:commons-lang3:${commonsLang3Version.get()}") |
| 97 | + |
| 98 | + implementation("org.lwjgl:lwjgl:${lwjglVersion.get()}") |
| 99 | + implementation("org.lwjgl:lwjgl-assimp:${lwjglVersion.get()}") |
| 100 | + implementation("org.lwjgl:lwjgl-glfw:${lwjglVersion.get()}") |
| 101 | + implementation("org.lwjgl:lwjgl-openal:${lwjglVersion.get()}") |
| 102 | + implementation("org.lwjgl:lwjgl-opengl:${lwjglVersion.get()}") |
| 103 | + implementation("org.lwjgl:lwjgl-stb:${lwjglVersion.get()}") |
| 104 | + |
| 105 | + runtimeOnly("org.lwjgl:lwjgl::$lwjglNatives") |
| 106 | + runtimeOnly("org.lwjgl:lwjgl-assimp::$lwjglNatives") |
| 107 | + runtimeOnly("org.lwjgl:lwjgl-glfw::$lwjglNatives") |
| 108 | + runtimeOnly("org.lwjgl:lwjgl-openal::$lwjglNatives") |
| 109 | + runtimeOnly("org.lwjgl:lwjgl-opengl::$lwjglNatives") |
| 110 | + runtimeOnly("org.lwjgl:lwjgl-stb::$lwjglNatives") |
141 | 111 | } |
142 | 112 |
|
143 | | -tasks.jar { |
144 | | - from("LICENSE") { |
145 | | - rename { "${it}_${base.archivesName.get()}" } |
146 | | - } |
147 | | -} |
148 | | - |
149 | | -configurations.configureEach { |
150 | | - // Removes LWJGL2 dependencies |
151 | | - exclude(group = "org.lwjgl.lwjgl") |
152 | | -} |
153 | | - |
154 | | -tasks.processResources { |
155 | | - inputs.property("version", version) |
156 | | - filesMatching("fabric.mod.json") { |
157 | | - expand("version" to version) |
158 | | - } |
| 113 | +tasks { |
| 114 | + withType<JavaCompile>().configureEach { |
| 115 | + options.encoding = "UTF-8" |
| 116 | + sourceCompatibility = javaVersion.get() |
| 117 | + targetCompatibility = javaVersion.get() |
| 118 | + if (javaVersion.get().toInt() > 8) options.release = javaVersion.get().toInt() |
| 119 | + } |
| 120 | + withType<JavaExec>().configureEach { defaultCharacterEncoding = "UTF-8" } |
| 121 | + withType<Javadoc>().configureEach { options.encoding = "UTF-8" } |
| 122 | + withType<Test>().configureEach { defaultCharacterEncoding = "UTF-8" } |
| 123 | + named<Jar>("jar") { |
| 124 | + val rootLicense = layout.projectDirectory.file("LICENSE") |
| 125 | + val parentLicense = layout.projectDirectory.file("../LICENSE") |
| 126 | + val licenseFile = when { |
| 127 | + rootLicense.asFile.exists() -> { |
| 128 | + logger.lifecycle("Using LICENSE from project root: ${rootLicense.asFile}") |
| 129 | + rootLicense |
| 130 | + } |
| 131 | + parentLicense.asFile.exists() -> { |
| 132 | + logger.lifecycle("Using LICENSE from parent directory: ${parentLicense.asFile}") |
| 133 | + parentLicense |
| 134 | + } |
| 135 | + else -> { |
| 136 | + logger.warn("No LICENSE file found in project or parent directory.") |
| 137 | + null |
| 138 | + } |
| 139 | + } |
| 140 | + licenseFile?.let { |
| 141 | + from(it) { |
| 142 | + rename { original -> "${original}_${archiveBaseName.get()}" } |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + processResources { |
| 147 | + val stringModVersion = modVersion.get() |
| 148 | + val stringLoaderVersion = loaderVersion.get() |
| 149 | + val stringJavaVersion = javaVersion.get() |
| 150 | + val stringHalplibeVersion = halplibeVersion.get() |
| 151 | + val stringModMenuVersion = modMenuVersion.get() |
| 152 | + inputs.property("modVersion", stringModVersion) |
| 153 | + inputs.property("loaderVersion", stringLoaderVersion) |
| 154 | + inputs.property("javaVersion", stringJavaVersion) |
| 155 | + inputs.property("HalplibeVersion", stringHalplibeVersion) |
| 156 | + inputs.property("modMenuVersion", stringModMenuVersion) |
| 157 | + filesMatching("fabric.mod.json") { |
| 158 | + expand( |
| 159 | + mapOf( |
| 160 | + "version" to stringModVersion, |
| 161 | + "fabricloader" to stringLoaderVersion, |
| 162 | + "halplibe" to stringHalplibeVersion, |
| 163 | + "java" to stringJavaVersion, |
| 164 | + "modmenu" to stringModMenuVersion |
| 165 | + ) |
| 166 | + ) |
| 167 | + } |
| 168 | + filesMatching("*.mixins.json") { expand(mapOf("java" to stringJavaVersion)) } |
| 169 | + } |
| 170 | + java { |
| 171 | + toolchain.languageVersion = JavaLanguageVersion.of(javaVersion.get()) |
| 172 | + sourceCompatibility = JavaVersion.toVersion(javaVersion.get().toInt()) |
| 173 | + targetCompatibility = JavaVersion.toVersion(javaVersion.get().toInt()) |
| 174 | + withSourcesJar() |
| 175 | + } |
159 | 176 | } |
| 177 | +// Removes LWJGL2 dependencies |
| 178 | +configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") } |
0 commit comments