2021-07-16 12:03:07 +02:00
|
|
|
// todo migrate this code to kotlin
|
2022-01-26 13:05:18 +01:00
|
|
|
import com.google.gson.JsonParser
|
|
|
|
|
|
|
|
import java.nio.file.Files
|
2022-01-26 21:22:09 +01:00
|
|
|
import java.util.stream.Collectors
|
|
|
|
import java.util.stream.IntStream
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
// Stolen https://github.com/FabricMC/fabric/blob/1.17/build.gradle
|
|
|
|
plugins {
|
|
|
|
id "java"
|
|
|
|
id "maven-publish"
|
2024-03-15 14:37:08 +01:00
|
|
|
id "org.ajoberstar.grgit" version "5.2.2"
|
2024-05-18 15:05:13 +02:00
|
|
|
id "com.matthewprenger.cursegradle" version "1.4.0" // This repository is archived on GH
|
2023-12-05 20:35:11 +01:00
|
|
|
id "com.modrinth.minotaur" version "2.8.7"
|
2024-04-13 22:44:59 +02:00
|
|
|
id "fabric-loom" version "1.6-SNAPSHOT" apply false
|
2024-07-07 20:03:14 +02:00
|
|
|
id "legacy-looming" version "1.6-SNAPSHOT" apply false // Version = fabric-loom
|
2024-02-03 22:55:55 +01:00
|
|
|
id "com.github.ben-manes.versions" version "0.51.0"
|
2024-06-17 19:11:10 +02:00
|
|
|
id "xyz.wagyourtail.jvmdowngrader" version "0.7.1"
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def ENV = System.getenv()
|
|
|
|
|
2022-01-26 21:22:09 +01:00
|
|
|
group = "com.viaversion.fabric"
|
2021-05-02 19:13:07 +02:00
|
|
|
description = "Client-side and server-side ViaVersion implementation for Fabric"
|
2024-08-05 16:31:46 +02:00
|
|
|
version = "0.4.15+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
|
2021-05-14 02:05:30 +02:00
|
|
|
logger.lifecycle("Building ViaFabric: $version")
|
2021-05-02 16:01:46 +02:00
|
|
|
|
|
|
|
def getBranch() {
|
|
|
|
def ENV = System.getenv()
|
2023-03-14 20:52:50 +01:00
|
|
|
def branch = "unknown"
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2023-03-14 20:52:50 +01:00
|
|
|
if (ENV.GITHUB_REF) {
|
|
|
|
branch = ENV.GITHUB_REF
|
|
|
|
} else if (grgit != null) {
|
|
|
|
branch = grgit.branch.current().name
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return branch.substring(branch.lastIndexOf("/") + 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
apply plugin: "maven-publish"
|
|
|
|
apply plugin: "fabric-loom"
|
2024-07-07 20:03:14 +02:00
|
|
|
apply plugin: "legacy-looming"
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2022-04-23 12:17:36 +02:00
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
// lwjgl2 works with Adoptium
|
2024-04-21 17:08:42 +02:00
|
|
|
languageVersion = JavaLanguageVersion.of(21)
|
2022-04-23 12:17:36 +02:00
|
|
|
vendor = JvmVendorSpec.ADOPTIUM
|
|
|
|
}
|
|
|
|
withSourcesJar()
|
|
|
|
}
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
tasks.withType(JavaCompile).configureEach {
|
2021-11-06 21:28:11 +01:00
|
|
|
it.options.release.set(8)
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
2022-04-23 12:17:36 +02:00
|
|
|
tasks.withType(JavaExec).configureEach {
|
|
|
|
it.javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
|
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2021-09-19 00:19:46 +02:00
|
|
|
version = rootProject.version
|
2022-01-26 21:22:09 +01:00
|
|
|
group = rootProject.group
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven { url = "https://repo.viaversion.com/" }
|
|
|
|
maven { url = "https://maven.fabricmc.net/" }
|
|
|
|
maven { url = "https://maven.legacyfabric.net/" }
|
2021-10-23 16:55:23 +02:00
|
|
|
maven { url = "https://maven.terraformersmc.com/releases/" }
|
2022-01-26 13:05:18 +01:00
|
|
|
maven { url = "https://jitpack.io/" }
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-09-24 23:23:06 +02:00
|
|
|
// transitive = false because Guava is conflicting on runClient
|
2022-01-26 21:22:09 +01:00
|
|
|
implementation("com.viaversion:viaversion:${rootProject.viaver_version}") { transitive = false }
|
2021-09-24 23:23:06 +02:00
|
|
|
|
2022-01-26 21:22:09 +01:00
|
|
|
modImplementation("net.fabricmc:fabric-loader:${rootProject.loader_version}")
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
processResources {
|
|
|
|
filesMatching("fabric.mod.json") {
|
2022-01-26 13:05:18 +01:00
|
|
|
it.expand(rootProject.properties)
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
subprojects {
|
2024-09-18 00:18:23 +02:00
|
|
|
loom {
|
|
|
|
runs {
|
|
|
|
named("client") {
|
|
|
|
client()
|
|
|
|
ideConfigGenerated(true)
|
|
|
|
runDir("run")
|
|
|
|
}
|
|
|
|
named("server") {
|
|
|
|
server()
|
|
|
|
ideConfigGenerated(true)
|
|
|
|
runDir("run")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-10 01:34:48 +02:00
|
|
|
dependencies {
|
2024-09-18 00:18:23 +02:00
|
|
|
implementation(project(path: ":", configuration: "namedElements")) {
|
2022-06-11 22:47:10 +02:00
|
|
|
exclude group: "net.fabricmc", module: "fabric-loader" // prevent duplicate fabric-loader on run
|
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
2021-11-25 23:26:02 +01:00
|
|
|
from components.java
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setupRepositories(repositories)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
2022-01-26 21:22:09 +01:00
|
|
|
from components.java
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setupRepositories(repositories)
|
|
|
|
}
|
|
|
|
|
2021-11-06 21:28:11 +01:00
|
|
|
static void setupRepositories(RepositoryHandler repositories) {
|
2021-05-02 16:01:46 +02:00
|
|
|
//repositories.mavenLocal() // uncomment for testing
|
|
|
|
def ENV = System.getenv()
|
|
|
|
if (ENV.MAVEN_URL) {
|
|
|
|
repositories.maven {
|
|
|
|
url ENV.MAVEN_URL
|
|
|
|
credentials {
|
|
|
|
username ENV.MAVEN_USERNAME
|
|
|
|
password ENV.MAVEN_PASSWORD
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-21 10:43:22 +01:00
|
|
|
subprojects.each {
|
|
|
|
remapJar.dependsOn("${it.path}:remapJar")
|
|
|
|
}
|
|
|
|
|
2024-06-01 01:57:28 +02:00
|
|
|
configurations {
|
|
|
|
includeJ8
|
|
|
|
}
|
|
|
|
|
|
|
|
jvmdg.dg(configurations.includeJ8)
|
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
dependencies {
|
2021-11-06 21:50:53 +01:00
|
|
|
// dummy version
|
2024-07-10 13:33:19 +02:00
|
|
|
minecraft("com.mojang:minecraft:1.13.2")
|
|
|
|
mappings("net.legacyfabric:yarn:1.13.2+build.541:v2")
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2024-06-01 01:57:28 +02:00
|
|
|
includeJ8("com.viaversion:viaversion:${rootProject.viaver_version}")
|
2024-01-21 10:38:51 +01:00
|
|
|
}
|
2021-05-02 17:01:24 +02:00
|
|
|
|
2024-01-21 10:38:51 +01:00
|
|
|
remapJar {
|
2024-06-01 01:57:28 +02:00
|
|
|
nestedJars.from configurations.includeJ8
|
2024-01-21 10:38:51 +01:00
|
|
|
afterEvaluate {
|
|
|
|
subprojects.each {
|
2024-01-21 10:43:22 +01:00
|
|
|
nestedJars.from project("${it.path}").tasks.named("remapJar")
|
2024-01-21 10:38:51 +01:00
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 13:05:18 +01:00
|
|
|
processResources {
|
|
|
|
filesMatching("assets/*/lang/*.lang") {
|
|
|
|
HashMap<String, String> langMap = new HashMap<>()
|
|
|
|
Files.list(rootProject.file("src/main/resources/assets/viafabric/lang").toPath())
|
|
|
|
.filter(path -> path.toString().endsWith(".json"))
|
|
|
|
.forEach(path -> {
|
|
|
|
String legacyFile = "\n" + String.join("\n", JsonParser
|
|
|
|
.parseReader(Files.newBufferedReader(path)).asJsonObject.entrySet().stream()
|
|
|
|
.map(entry -> entry.key + "=" + entry.value.asString)
|
|
|
|
.toArray(String[]::new))
|
|
|
|
langMap.put(path.getFileName().toString().replace(".json", ""), legacyFile)
|
|
|
|
})
|
|
|
|
it.expand(langMap)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-14 20:52:50 +01:00
|
|
|
List<String> mcReleases = Arrays.stream(rootProject.publish_mc_versions.toString().split(","))
|
|
|
|
.map({ it -> it.trim() })
|
|
|
|
.collect(Collectors.toList())
|
2024-06-01 18:56:38 +02:00
|
|
|
List<String> javaVersions = IntStream.rangeClosed(8, 22)
|
2022-01-26 21:22:09 +01:00
|
|
|
.mapToObj { n -> (String) "Java $n" }
|
2022-05-22 18:12:13 +02:00
|
|
|
.collect(Collectors.toList())
|
|
|
|
String changelogMsg = "A changelog can be found at https://github.com/ViaVersion/ViaFabric/commits"
|
|
|
|
String versionNameMsg = "[${getBranch()}] ViaFabric " + rootProject.version
|
2022-01-26 21:22:09 +01:00
|
|
|
|
2021-05-02 16:01:46 +02:00
|
|
|
curseforge {
|
|
|
|
if (ENV.CURSEFORGE_API_KEY) {
|
|
|
|
apiKey = ENV.CURSEFORGE_API_KEY
|
|
|
|
}
|
|
|
|
|
|
|
|
project {
|
|
|
|
id = "391298"
|
2022-05-22 18:12:13 +02:00
|
|
|
changelog = changelogMsg
|
2024-03-05 22:50:17 +01:00
|
|
|
releaseType = "beta" // alpha is hidden by default
|
2022-01-26 21:22:09 +01:00
|
|
|
|
2022-05-22 18:12:13 +02:00
|
|
|
mcReleases.forEach { ver -> addGameVersion(ver) }
|
2022-06-03 22:43:45 +02:00
|
|
|
if (!rootProject.curseforge_mc_snapshot.isEmpty()) addGameVersion(rootProject.curseforge_mc_snapshot)
|
2022-05-22 18:12:13 +02:00
|
|
|
javaVersions.forEach(v -> addGameVersion(v))
|
|
|
|
addGameVersion("Fabric")
|
2021-05-02 16:01:46 +02:00
|
|
|
|
2021-11-26 23:02:09 +01:00
|
|
|
mainArtifact(remapJar) {
|
2022-05-22 18:12:13 +02:00
|
|
|
displayName = versionNameMsg
|
2021-05-02 17:01:24 +02:00
|
|
|
relations {
|
2024-07-07 19:23:45 +02:00
|
|
|
optionalDependency("legacy-fabric-api")
|
2021-05-02 17:01:24 +02:00
|
|
|
}
|
2021-05-02 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
uploadTask.dependsOn("remapJar")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
forgeGradleIntegration = false
|
|
|
|
}
|
|
|
|
}
|
2021-05-02 17:01:24 +02:00
|
|
|
|
2022-05-22 18:56:30 +02:00
|
|
|
modrinth {
|
|
|
|
token.set(ENV.MODRINTH_TOKEN)
|
|
|
|
projectId.set("YlKdE5VK")
|
2023-09-18 12:23:07 +02:00
|
|
|
versionType.set("alpha")
|
2022-05-22 18:56:30 +02:00
|
|
|
versionNumber.set(rootProject.version)
|
|
|
|
versionName.set(versionNameMsg)
|
|
|
|
changelog.set(changelogMsg)
|
2022-05-22 18:12:13 +02:00
|
|
|
|
2022-05-22 18:56:30 +02:00
|
|
|
uploadFile.set(remapJar)
|
2022-05-22 18:12:13 +02:00
|
|
|
|
2022-05-22 18:56:30 +02:00
|
|
|
List<String> mcs = new ArrayList<>(mcReleases)
|
2023-03-14 20:52:50 +01:00
|
|
|
if (!rootProject.modrinth_mc_snapshot.isEmpty()) mcs.add(rootProject.modrinth_mc_snapshot.toString())
|
2022-05-22 18:56:30 +02:00
|
|
|
gameVersions.set(mcs)
|
|
|
|
loaders.set(["fabric"])
|
2022-05-22 18:12:13 +02:00
|
|
|
|
|
|
|
dependencies {
|
2024-07-07 19:23:45 +02:00
|
|
|
optional.project "9CJED7xi" // legacy fabric api
|
2024-07-07 19:35:48 +02:00
|
|
|
embedded.project "P1OZGk5p" // viaversion
|
2022-05-22 18:12:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-22 19:23:17 +02:00
|
|
|
defaultTasks("clean", "build")
|