plugins { id "java-library" id "maven-publish" id "io.papermc.hangar-publish-plugin" version "0.1.2" } 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 dependencies { compileOnly "com.viaversion:viaversion-api:4.10.0" 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() } publishing { publications { maven(MavenPublication) { from(components.java) } } } tasks.withType(JavaCompile) { options.encoding = "UTF-8" } tasks.withType(Javadoc) { options.encoding = "UTF-8" } // ----------------------------------------------------- // 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 branchName() { def byteOut = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' 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()}" def branch = branchName() def isMainBranch = branch == "master" hangarPublish { publications.register("plugin") { version.set(suffixedVersion) id.set("ViaRewindLegacySupport") channel.set(isRelease ? "Release" : isMainBranch ? "Snapshot" : "Alpha") changelog.set(changelogContent) apiKey.set(System.getenv("HANGAR_TOKEN")) 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) } } } } }