plugins { id "java" id "application" id "maven-publish" id "idea" id "net.raphimc.class-token-replacer" version "1.1.3" id "xyz.wagyourtail.jvmdowngrader" version "1.1.3" } base { java.toolchain.languageVersion = JavaLanguageVersion.of(17) compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" group = project.maven_group ?: rootProject.maven_group archivesName = project.maven_name ?: rootProject.maven_name version = project.maven_version ?: rootProject.maven_version } configurations { include includeJ8 implementation.extendsFrom include api.extendsFrom include } repositories { mavenCentral() maven { name = "ViaVersion" url = "https://repo.viaversion.com" } maven { name = "Lenni0451" url = "https://maven.lenni0451.net/everything" } maven { name = "OpenCollab Releases" url = "https://repo.opencollab.dev/maven-releases" } maven { name = "OpenCollab Snapshots" url = "https://repo.opencollab.dev/maven-snapshots" } maven { name = "Minecraft Libraries" url = "https://libraries.minecraft.net" content { includeGroup "com.mojang" } } maven { name = "Jitpack" url = "https://jitpack.io" content { includeGroup "com.github.Oryxel" } } } dependencies { include "com.viaversion:viaversion-common:5.0.4-SNAPSHOT" include "com.viaversion:viabackwards-common:5.0.4-SNAPSHOT" include "com.viaversion:viarewind-common:4.0.3-SNAPSHOT" include "net.raphimc:ViaLegacy:3.0.3-SNAPSHOT" include "net.raphimc:viaaprilfools-common:3.0.2-SNAPSHOT" include("net.raphimc:ViaBedrock:0.0.11-SNAPSHOT") { exclude group: "io.netty" exclude group: "io.jsonwebtoken" } include("net.raphimc:ViaLoader:3.0.3-SNAPSHOT") { exclude group: "org.slf4j", module: "slf4j-api" } include "com.google.code.gson:gson:2.11.0" include "com.formdev:flatlaf:3.5.1" include "com.formdev:flatlaf-extras:3.5.1" include "org.apache.commons:commons-lang3:3.17.0" include "commons-io:commons-io:2.16.1" include "net.sf.jopt-simple:jopt-simple:5.0.4" include "org.apache.logging.log4j:log4j-core:2.24.0" include "org.apache.logging.log4j:log4j-slf4j-impl:2.24.0" include "org.fusesource.jansi:jansi:2.4.1" include("com.mojang:authlib:3.16.29") { exclude group: "org.slf4j", module: "slf4j-api" } include "net.lenni0451.classtransform:mixinstranslator:1.14.0" include "net.lenni0451.classtransform:mixinsdummy:1.14.0" include "net.lenni0451.classtransform:additionalclassprovider:1.14.0" include "net.lenni0451:Reflect:1.3.4" include "net.lenni0451:LambdaEvents:2.4.2" include("net.lenni0451:MCPing:1.4.1") { exclude group: "com.google.code.gson", module: "gson" } include "net.lenni0451.commons:swing:1.6.0" include("net.raphimc.netminecraft:all:3.0.0-SNAPSHOT") { exclude group: "com.google.code.gson", module: "gson" } include("net.raphimc:MinecraftAuth:4.1.1-SNAPSHOT") { exclude group: "com.google.code.gson", module: "gson" exclude group: "org.slf4j", module: "slf4j-api" } include("org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR3-SNAPSHOT") { exclude group: "io.netty" } include "gs.mclo:api:4.0.3" include "net.lenni0451:optconfig:1.0.0" includeJ8(compileOnly("xyz.wagyourtail.jvmdowngrader:jvmdowngrader:1.1.3")) includeJ8 "xyz.wagyourtail.jvmdowngrader:jvmdowngrader-java-api:1.1.3:downgraded-8" } sourceSets { main { classTokenReplacer { property("\${version}", project.version) property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash()}") } } } java { withSourcesJar() } application { mainClass = "net.raphimc.viaproxy.ViaProxy" } jar { dependsOn configurations.include from { duplicatesStrategy = DuplicatesStrategy.EXCLUDE configurations.include.collect { zipTree(it) } } { exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA" } manifest { attributes( "Main-Class": application.mainClass, "Multi-Release": "true", "Launcher-Agent-Class": application.mainClass ) } from("LICENSE") { rename { "${it}_${project.name ?: rootProject.name}" } } } publishing { repositories { maven { name = "Via" url = "https://repo.viaversion.com/" credentials(PasswordCredentials) authentication { basic(BasicAuthentication) } } } publications { maven(MavenPublication) { groupId = project.maven_group artifactId = project.maven_name version = project.maven_version from components.java pom { name = "ViaProxy" description = "Standalone proxy which allows players to join EVERY Minecraft server version (Classic, Alpha, Beta, Release, Bedrock)" url = "https://github.com/ViaVersion/ViaProxy" licenses { license { name = "GPL-3.0 License" url = "https://github.com/ViaVersion/ViaProxy/blob/main/LICENSE" } } developers { developer { id = "RK_01" } } scm { connection = "scm:git:git://github.com/ViaVersion/ViaProxy.git" developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaProxy.git" url = "https://github.com/ViaVersion/ViaProxy.git" } } } } } idea { module { ["run"].each { excludeDirs << file("$it") } } } downgradeJar { dependsOn configurations.includeJ8 from { duplicatesStrategy = DuplicatesStrategy.EXCLUDE configurations.includeJ8.collect { zipTree(it) } } { exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA" } downgradeTo = JavaVersion.VERSION_1_8 ignoreWarningsIn.add("net/lenni0451/commons/httpclient/executor/HttpClientExecutor") archiveClassifier = null archiveVersion = project.version + "+java8" } build.finalizedBy("downgradeJar") String latestCommitHash() { def stdout = new ByteArrayOutputStream() exec { commandLine "git", "rev-parse", "--short", "HEAD" standardOutput = stdout } return stdout.toString().trim() }