Essentia/build.gradle.kts
2024-05-26 00:01:26 +02:00

91 lines
2.0 KiB
Plaintext

import java.io.FileOutputStream
import java.net.URL
import java.io.ByteArrayOutputStream
plugins {
id("java")
id("java-library")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("maven-publish")
}
allprojects {
group = "com.alttd.essentia"
version = "Build-" + (System.getenv("BUILD_NUMBER") ?: gitCommit())
description = "Altitude essentials ;)"
}
subprojects {
apply<JavaLibraryPlugin>()
apply(plugin = "maven-publish")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
publishing {
configure<PublishingExtension> {
repositories {
maven {
name = "maven"
url = uri("https://repo.destro.xyz/snapshots/")
credentials(PasswordCredentials::class)
}
}
}
}
}
dependencies {
implementation(project(":api"))
implementation(project(":plugin"))
}
tasks {
shadowJar {
archiveFileName.set("${project.name}.jar")
minimize() {
exclude {
it.moduleName == "api"
}
exclude {
it.moduleName == "plugin"
}
}
listOf(
"xyz.destro.utheo.comet"
).forEach { relocate(it, "${rootProject.group}.lib.${it.substringAfterLast(".")}") }
}
build {
dependsOn(shadowJar)
}
jar {
// enabled = false
// archiveFileName.set("${rootProject.name}.jar")
}
}
dependencies {
compileOnly("com.alttd:Comet-API:1.20.4-R0.1-SNAPSHOT")
}
fun gitCommit(): String {
val os = ByteArrayOutputStream()
project.exec {
isIgnoreExitValue = true
commandLine = "git rev-parse --short HEAD".split(" ")
standardOutput = os
}
return "git-" + String(os.toByteArray()).trim()
}
fun download(link: String, path: String) {
URL(link).openStream().use { input ->
FileOutputStream(File(path)).use { output ->
input.copyTo(output)
}
}
}