ViaRewind-Legacy-Support/build.gradle

112 lines
2.8 KiB
Groovy
Raw Normal View History

2023-09-25 16:43:07 +02:00
import io.papermc.hangarpublishplugin.model.Platforms
2023-09-22 13:59:37 +02:00
plugins {
id "java-library"
id "maven-publish"
2023-09-25 16:43:07 +02:00
id "io.papermc.hangar-publish-plugin" version "0.1.0"
2023-09-22 13:59:37 +02:00
}
repositories {
mavenLocal()
maven {
url = uri("https://repo.viaversion.com")
}
maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}
version = project.maven_version
group = project.maven_group
2023-09-22 13:59:37 +02:00
dependencies {
2024-03-06 14:43:14 +01:00
compileOnly "com.viaversion:viaversion-api:4.9.3"
2023-09-22 13:59:37 +02:00
compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
processResources {
inputs.property "version", project.version
filesMatching("plugin.yml") {
expand "version": project.version
}
}
java {
withSourcesJar()
}
2023-09-22 13:59:37 +02:00
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Javadoc) {
options.encoding = "UTF-8"
}
2023-09-25 16:43:07 +02:00
// -----------------------------------------------------
// Publishing
def latestCommitHash() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}
def latestCommitMessage() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--pretty=%B'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}
def baseVersion = project.maven_version
def isRelease = !baseVersion.contains('-')
def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
def commitHash = latestCommitHash()
def changelogContent = "[${commitHash}](https://github.com/ViaVersion/iaRewind-Legacy-Support/commit/${commitHash}) ${latestCommitMessage()}"
hangarPublish {
publications.register("plugin") {
version.set(suffixedVersion)
id.set("ViaRewindLegacySupport")
channel.set(isRelease ? "Release" : "Snapshot")
changelog.set(changelogContent)
apiKey.set(System.getenv("HANGAR_TOKEN"))
platforms {
register(Platforms.PAPER) {
jar.set(tasks.jar.archiveFile)
platformVersions.set([property('mcVersionRange') as String])
dependencies.hangar("ViaVersion") {
required.set(true)
}
dependencies.hangar("ViaBackwards") {
required.set(false)
}
dependencies.hangar("ViaRewind") {
required.set(false)
}
}
}
}
}