Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-29 01:20:15 +01:00
e356a35aa7
Don't create runnable platform jars anymore, since all they really do is increase build time. Also fix texts and Gradle deprecations. Also also publish common with its shadowed configuration, not the plain java components.
56 Zeilen
1.5 KiB
Kotlin
56 Zeilen
1.5 KiB
Kotlin
import org.gradle.api.Project
|
|
import org.gradle.api.plugins.JavaPluginExtension
|
|
import org.gradle.api.publish.PublishingExtension
|
|
import org.gradle.api.publish.maven.MavenPublication
|
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
|
import org.gradle.kotlin.dsl.configure
|
|
import org.gradle.kotlin.dsl.get
|
|
import org.gradle.kotlin.dsl.named
|
|
import java.io.ByteArrayOutputStream
|
|
|
|
fun Project.publishShadowJar() {
|
|
configurePublication {
|
|
artifact(tasks["shadowJar"])
|
|
artifact(tasks["sourcesJar"])
|
|
}
|
|
}
|
|
|
|
fun Project.publishJavaComponents() {
|
|
configurePublication {
|
|
from(components["java"])
|
|
}
|
|
}
|
|
|
|
private fun Project.configurePublication(configurer: MavenPublication.() -> Unit) {
|
|
extensions.configure<PublishingExtension> {
|
|
publications.named<MavenPublication>("mavenJava") {
|
|
apply(configurer)
|
|
}
|
|
}
|
|
}
|
|
|
|
fun Project.latestCommitHash(): String {
|
|
return runGitCommand(listOf("rev-parse", "--short", "HEAD"))
|
|
}
|
|
|
|
fun Project.latestCommitMessage(): String {
|
|
return runGitCommand(listOf("log", "-1", "--pretty=%B"))
|
|
}
|
|
|
|
fun Project.branchName(): String {
|
|
return runGitCommand(listOf("rev-parse", "--abbrev-ref", "HEAD"))
|
|
}
|
|
|
|
fun Project.runGitCommand(args: List<String>): String {
|
|
val byteOut = ByteArrayOutputStream()
|
|
exec {
|
|
commandLine = listOf("git") + args
|
|
standardOutput = byteOut
|
|
}
|
|
return byteOut.toString(Charsets.UTF_8.name()).trim()
|
|
}
|
|
|
|
fun JavaPluginExtension.javaTarget(version: Int) {
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of(version))
|
|
}
|