99 lines
2.8 KiB
Plaintext
99 lines
2.8 KiB
Plaintext
import java.io.FileOutputStream
|
|
import de.undercouch.gradle.tasks.download.Download
|
|
|
|
plugins {
|
|
java
|
|
application
|
|
`maven-publish`
|
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
|
id("de.undercouch.download") version "5.1.0"
|
|
}
|
|
|
|
application {
|
|
mainClass.set("io.gitlab.jfronny.inceptum.WrapperStrap")
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
setUrl("https://gitlab.com/api/v4/projects/35745143/packages/maven")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation("ch.qos.logback:logback-classic:${rootProject.extra["logbackVersion"]}")
|
|
implementation("io.gitlab.jfronny:commons:${rootProject.extra["jfCommonsVersion"]}")
|
|
implementation("io.gitlab.jfronny:commons-gson:${rootProject.extra["jfCommonsVersion"]}")
|
|
implementation("io.gitlab.jfronny:commons-slf4j:${rootProject.extra["jfCommonsVersion"]}")
|
|
}
|
|
|
|
tasks.processResources {
|
|
inputs.property("version", project.version)
|
|
|
|
filesMatching("version.json") {
|
|
expand(
|
|
"version" to project.version,
|
|
"flavor" to rootProject.extra["flavorProp"],
|
|
"isPublic" to rootProject.extra["isPublic"],
|
|
"isRelease" to rootProject.extra["isRelease"],
|
|
"jvm" to project.java.targetCompatibility
|
|
)
|
|
}
|
|
}
|
|
|
|
abstract class FileOutput : DefaultTask() {
|
|
@get:OutputFile
|
|
abstract var output: File
|
|
}
|
|
val bootstrapVersion = "0.2.1"
|
|
val bootstrapArch = "i686"
|
|
|
|
val downloadBootstrap by tasks.registering(Download::class) {
|
|
src("https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe")
|
|
dest(project.buildDir)
|
|
}
|
|
|
|
val nativeExe by tasks.registering(FileOutput::class) {
|
|
dependsOn(downloadBootstrap)
|
|
dependsOn(tasks.shadowJar)
|
|
|
|
output = file("${buildDir}-${project.version}.exe")
|
|
outputs.upToDateWhen { false }
|
|
|
|
doFirst {
|
|
output.delete()
|
|
}
|
|
|
|
doLast {
|
|
output.createNewFile()
|
|
FileOutputStream(output).use { w ->
|
|
w.write(downloadBootstrap.get().outputFiles.first().readBytes())
|
|
w.write(tasks.shadowJar.get().archiveFile.get().asFile.readBytes())
|
|
}
|
|
}
|
|
}
|
|
|
|
if (rootProject.extra["flavor"] == "windows") tasks.build.get().dependsOn(nativeExe)
|
|
|
|
publishing {
|
|
publications {
|
|
create<MavenPublication>("mavenJava") {
|
|
artifact(tasks.shadowJar) {
|
|
builtBy(tasks.shadowJar)
|
|
}
|
|
}
|
|
}
|
|
|
|
if (rootProject.extra["isPublic"] == true) {
|
|
repositories.maven {
|
|
url = uri("https://gitlab.com/api/v4/projects/30862253/packages/maven")
|
|
name = "gitlab"
|
|
|
|
credentials(HttpHeaderCredentials::class) {
|
|
name = "Job-Token"
|
|
value = System.getenv().get("CI_JOB_TOKEN")
|
|
}
|
|
}
|
|
}
|
|
repositories.mavenLocal()
|
|
} |