import org.gradle.internal.os.OperatingSystem plugins { id 'java' id 'application' id 'com.github.johnrengelman.shadow' version '7.0.0' id "maven-publish" id "de.undercouch.download" version "4.1.1" } group 'io.gitlab.jfronny' version '0.1' + (project.hasProperty('pipeline') ? "+" + project.getProperty('pipeline') : "") application { mainClass = 'io.gitlab.jfronny.inceptum.Inceptum' } repositories { mavenCentral() } ext { lwjglVersion = '3.2.3' imguiVersion = '1.84.1.3' log4jVersion = '2.14.1' flavorProp = project.hasProperty('flavor') ? project.getProperty('flavor') : 'custom' flavor = flavorProp isPublicMaven = project.hasProperty('publicMaven') } if (flavor == 'custom') { 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 filter { line -> line.replace("@flavor@", project.ext.flavorProp) } } } shadowJar { archiveClassifier.set(flavorProp) } 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.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() }