ViaLegacy/build.gradle
2024-10-30 19:25:03 +01:00

136 lines
3.6 KiB
Groovy

plugins {
id "java-library"
id "maven-publish"
id "idea"
id "net.raphimc.class-token-replacer" 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
}
repositories {
mavenCentral()
maven {
name = "ViaVersion"
url = "https://repo.viaversion.com"
}
}
dependencies {
compileOnly "com.viaversion:viaversion-common:5.1.1-SNAPSHOT"
compileOnly "com.google.guava:guava:33.3.1-jre"
compileOnly "io.netty:netty-handler:4.1.114.Final"
}
sourceSets {
main {
classTokenReplacer {
property("\${version}", project.version)
property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash()}")
}
}
}
java {
withSourcesJar()
}
jar {
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 = "ViaLegacy"
description = "ViaVersion addon to add support for EVERY Minecraft server version (Classic, Alpha, Beta, Release)"
url = "https://github.com/ViaVersion/ViaLegacy"
licenses {
license {
name = "GPL-3.0 License"
url = "https://github.com/ViaVersion/ViaLegacy/blob/main/LICENSE"
}
}
developers {
developer {
id = "RK_01"
}
}
scm {
connection = "scm:git:git://github.com/ViaVersion/ViaLegacy.git"
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaLegacy.git"
url = "https://github.com/ViaVersion/ViaLegacy.git"
}
}
}
}
}
idea {
module {
["run"].each {
excludeDirs << file("$it")
}
}
}
tasks.register("runViaProxy", JavaExec) {
dependsOn tasks.jar
def viaProxyConfiguration = configurations.create("viaProxy")
viaProxyConfiguration.dependencies.add(dependencies.create("net.raphimc:ViaProxy:3.3.5-SNAPSHOT") {
transitive = false
})
mainClass = "net.raphimc.viaproxy.ViaProxy"
classpath = viaProxyConfiguration
workingDir = file("run")
jvmArgs = ["-DskipUpdateCheck"]
doFirst {
def jarsDir = file("$workingDir/jars")
jarsDir.mkdirs()
file("$jarsDir/${project.name}.jar").bytes = tasks.jar.archiveFile.get().asFile.bytes
}
doLast {
file("$workingDir/jars/${project.name}.jar").delete()
file("$workingDir/logs").deleteDir()
}
}
String latestCommitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}