Inceptum/wrapper/build.gradle
2021-10-31 17:30:51 +01:00

74 lines
1.8 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.Wrapper'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
}
class FileOutput extends DefaultTask {
@OutputFile
File output
}
def bootstrapVersion = "0.1.6"
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 (project.parent.ext.isPublicMaven) {
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()
}