Files
LiquidBounce/build.gradle
1zuna 591c5793a9 feat(ScriptAPI): Implement GraalJS JIT with call target remapping (#4368)
Improves ScriptAPI by enabling GraalJS JIT while addressing Minecraft's obfuscation. Previously, non-JIT mode allowed remapping; however, this new approach applies a call target remapping strategy, overcoming bugs with overloaded names.

Also, GraalVM is now the default JDK on LiquidLauncher.

---------

Co-authored-by: Senk Ju <18741573+SenkJu@users.noreply.github.com>
2024-11-06 04:33:08 +01:00

298 lines
9.3 KiB
Groovy

/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2024 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id "fabric-loom"
id "org.jetbrains.kotlin.jvm"
id "com.gorylenko.gradle-git-properties" version "2.4.2"
id "io.gitlab.arturbosch.detekt" version "1.23.6"
id "com.github.node-gradle.node" version "7.1.0"
id "org.jetbrains.dokka" version "1.9.10"
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
configurations {
includeDependency
includeModDependency
include.extendsFrom includeModDependency
modImplementation.extendsFrom includeModDependency
modCompileOnlyApi.extendsFrom includeModDependency
}
repositories {
mavenCentral()
mavenLocal()
maven { url = "https://maven.fabricmc.net/" }
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
maven {
name = "ViaVersion"
url = "https://repo.viaversion.com/"
}
maven {
name = "modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
name = "OpenCollab Snapshots"
url = "https://repo.opencollab.dev/maven-snapshots/"
}
maven {
name = "Lenni0451"
url = "https://maven.lenni0451.net/everything"
}
}
loom {
accessWidenerPath = file("src/main/resources/liquidbounce.accesswidener")
}
dependencies {
// Minecraft
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
// Fabric
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
// Recommended mods (on IDE)
modRuntimeOnly "com.terraformersmc:modmenu:${project.mod_menu_version}"
modImplementation "maven.modrinth:sodium:${project.sodium_version}"
modCompileOnly "de.florianmichael:ViaFabricPlus:${project.viafabricplus_version}"
// Minecraft Authlib
includeDependency ("com.github.CCBlueX:mc-authlib:${project.mc_authlib_version}") {
exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.apache.logging.log4j", module: "log4j-core"
exclude group: "org.apache.logging.log4j", module: "log4j-api"
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "com.mojang", module: "authlib"
}
// JCEF Support
includeModDependency "com.github.CCBlueX:mcef:1.1.5-1.21.1"
includeDependency "org.apache.commons:commons-exec:1.3"
includeDependency ("com.github.CCBlueX:netty-httpserver:2.1.0") {
exclude group: "io.netty", module: "netty-all"
}
// Discord RPC Support
includeDependency "com.github.CCBlueX:DiscordIPC:4.0.0"
// ScriptAPI
includeDependency "net.fabricmc:tiny-mappings-parser:0.3.0+build.17"
includeDependency "org.graalvm.polyglot:polyglot:24.0.2"
includeDependency "org.graalvm.polyglot:js-community:24.0.2"
// SOCKS5 Proxy Support (to stay compatible with ViaFabricPlus)
includeDependency "io.netty:netty-handler-proxy:4.1.114.Final"
// Update Checker
includeDependency "com.vdurmont:semver4j:3.1.0"
// Test libraries
testImplementation "org.junit.jupiter:junit-jupiter:5.11.3"
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
afterEvaluate {
configurations.includeDependency.incoming.resolutionResult.allDependencies.each {
dependencies.include(dependencies.implementation(dependencies.compileOnlyApi(it.requested.toString()) {
transitive = false
}))
}
}
}
processResources {
inputs.property "version", project.version
inputs.property "minecraft_version", minecraft_version
inputs.property "fabric_version", fabric_version
inputs.property "loader_version", loader_version
inputs.property "min_loader_version", min_loader_version
inputs.property "fabric_kotlin_version", fabric_kotlin_version
inputs.property "viafabricplus_version", viafabricplus_version
filesMatching("fabric.mod.json") {
expand([
version : project.version,
minecraft_version : minecraft_version,
fabric_version : fabric_version,
loader_version : loader_version,
min_loader_version : min_loader_version,
fabric_kotlin_version: fabric_kotlin_version,
viafabricplus_version: viafabricplus_version
])
}
}
// The following code will include the theme into the build
tasks.register("npmInstallTheme", NpmTask) {
workingDir = file("src-theme")
args = ["i"]
doLast {
println "Successfully installed dependencies for theme"
}
inputs.files("src-theme/package.json", "src-theme/package-lock.json")
outputs.dir("src-theme/node_modules")
}
tasks.register("buildTheme", NpmTask) {
dependsOn "npmInstallTheme"
workingDir = file("src-theme")
args = ["run", "build"]
doLast {
println "Successfully build theme"
}
inputs.files(
"src-theme/package.json",
"src-theme/package-lock.json",
"src-theme/bundle.cjs",
"src-theme/rollup.config.js"
)
inputs.dir("src-theme/src")
outputs.dir("src-theme/dist")
}
tasks.register("bundleTheme", NodeTask) {
dependsOn "buildTheme"
workingDir = file("src-theme")
script = file("src-theme/bundle.cjs")
doLast {
println "Successfully attached theme to build"
}
// Incremental stuff
inputs.files(
"src-theme/package.json",
"src-theme/package-lock.json",
"src-theme/bundle.cjs",
"src-theme/rollup.config.js"
)
inputs.dir("src-theme/src")
inputs.dir("src-theme/public")
inputs.dir("src-theme/dist")
outputs.files("src-theme/resources/assets/liquidbounce/default_theme.zip")
}
sourceSets {
main {
resources {
srcDirs "src-theme/resources"
}
}
}
processResources.dependsOn bundleTheme
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// Minecraft 1.20.5 upwards uses Java 17.
it.options.release = 21
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
dependsOn(tasks.named("genSources"))
}
detekt {
config.setFrom(file("${rootProject.projectDir}/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
baseline = file("${rootProject.projectDir}/config/detekt/baseline.xml")
}
task detektProjectBaseline(type: io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
description = "Overrides current baseline."
ignoreFailures.set(true)
parallel.set(true)
buildUponDefaultConfig.set(true)
setSource(files(rootDir))
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
baseline.set(file("$rootDir/config/detekt/baseline.xml"))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
compileKotlin {
compilerOptions {
suppressWarnings = true
jvmTarget = JvmTarget.JVM_21
}
}
jar {
// Rename the project"s license file to LICENSE_<project_name> to avoid conflicts
from("LICENSE") {
rename {
"${it}_${project.archives_base_name}"
}
}
from(configurations.mappings.collect { zipTree(it) }) {
include "mappings/mappings.tiny"
}
}
tasks.register("copyZipInclude", Copy) {
from "zip_include/"
into "build/libs/zip"
}
sourcesJar.dependsOn bundleTheme
build.dependsOn copyZipInclude