Inceptum/wrapper/build.gradle

87 lines
2.3 KiB
Groovy

plugins {
id 'java'
id 'application'
id "de.undercouch.download" version "4.1.1"
id 'com.github.johnrengelman.shadow'
id "maven-publish"
}
application {
mainClass = 'io.gitlab.jfronny.inceptum.WrapperStrap'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'ch.qos.logback:logback-classic:1.2.10'
}
processResources {
inputs.property "version", project.version
filesMatching("version.json") {
expand "version": project.version
filter { line -> line.replace("@flavor@", rootProject.ext.flavorProp) }
filter { line -> line.replace("@public@", "$rootProject.ext.isPublic") }
filter { line -> line.replace("@jvm@", "$rootProject.sourceCompatibility") }
}
}
class FileOutput extends DefaultTask {
@OutputFile
File output
}
def bootstrapVersion = "0.2.1"
def bootstrapArch = "i686"
task downloadBootstrap(type: Download) {
src "https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe"
dest project.buildDir
}
task nativeExe(dependsOn: [downloadBootstrap, shadowJar], type: FileOutput) {
output = file("${projectDir}/build/libs/${archivesBaseName}-${project.version}.exe")
outputs.upToDateWhen { false }
doFirst {
output.delete()
}
doLast {
output.createNewFile()
output.setBytes downloadBootstrap.outputFiles.first().readBytes()
output.append shadowJar.archiveFile.get().getAsFile().readBytes()
}
}
if (flavor == 'windows') build.dependsOn nativeExe
publishing {
publications {
mavenJava(MavenPublication) {
artifact(shadowJar) {
builtBy shadowJar
}
}
}
if (rootProject.ext.isPublic) {
repositories.maven {
url = "https://gitlab.com/api/v4/projects/30862253/packages/maven"
name = "gitlab"
credentials(HttpHeaderCredentials) {
name = "Job-Token"
value = System.getenv().CI_JOB_TOKEN
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
repositories.mavenLocal()
}