Inceptum/build.gradle
2021-10-30 19:26:59 +02:00

106 lines
3.2 KiB
Groovy

import org.gradle.internal.os.OperatingSystem
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id "de.undercouch.download" version "4.1.1"
}
group 'io.gitlab.jfronny'
version '1.0'
application {
mainClass = 'io.gitlab.jfronny.inceptum.Inceptum'
}
repositories {
mavenCentral()
}
ext {
lwjglVersion = '3.2.3'
imguiVersion = '1.84.1.3'
log4jVersion = '2.14.1'
flavor = project.hasProperty('flavor') ? project.getProperty('flavor') : 'auto'
}
if (flavor == 'auto') {
switch (OperatingSystem.current()) {
case OperatingSystem.WINDOWS:
project.ext.flavor = 'windows'
break
case OperatingSystem.LINUX:
project.ext.flavor = 'linux'
break
case OperatingSystem.MAC_OS:
project.ext.flavor = 'macos'
break
}
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'ch.qos.logback:logback-classic:1.2.6'
implementation 'net.freeutils:jlhttp:2.6'
implementation 'org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r'
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
['', '-opengl', '-glfw'].each {
implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
if (flavor == 'windows' || flavor == 'fat') implementation "org.lwjgl:lwjgl$it::natives-windows"
if (flavor == 'linux' || flavor == 'fat') implementation "org.lwjgl:lwjgl$it::natives-linux"
if (flavor == 'macos' || flavor == 'fat') implementation "org.lwjgl:lwjgl$it::natives-macos"
}
implementation "io.github.spair:imgui-java-binding:$imguiVersion" // https://github.com/SpaiR/imgui-java
implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion"
if (flavor == 'windows' || flavor == 'fat') implementation "io.github.spair:imgui-java-natives-windows:$imguiVersion"
if (flavor == 'linux' || flavor == 'fat') implementation "io.github.spair:imgui-java-natives-linux:$imguiVersion"
if (flavor == 'macos' || flavor == 'fat') implementation "io.github.spair:imgui-java-natives-macos:$imguiVersion"
}
processResources {
inputs.property "version", project.version
filesMatching("version.json") {
expand "version": project.version
}
}
shadowJar {
archiveClassifier.set(flavor)
}
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