Skip to content

Instantly share code, notes, and snippets.

@1-alex98
Created May 20, 2020 17:53
Show Gist options
  • Save 1-alex98/9e85054a82da53285cd9e0d282db8f93 to your computer and use it in GitHub Desktop.
Save 1-alex98/9e85054a82da53285cd9e0d282db8f93 to your computer and use it in GitHub Desktop.
Build.gradle for javafx application java 11
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
repositories {
mavenCentral()
}
int javafxVersion=11
String javafxPlatform ="undefined"
if (javafxPlatform == "undefined") {
switch (org.gradle.internal.os.OperatingSystem.current()) {
case org.gradle.internal.os.OperatingSystem.LINUX:
javafxPlatform = "linux"
break
case org.gradle.internal.os.OperatingSystem.MAC_OS:
javafxPlatform = "mac"
break
case org.gradle.internal.os.OperatingSystem.WINDOWS:
javafxPlatform = "win"
break
}
}
println "Platform is: $javafxPlatform"
dependencies {
implementation("com.squareup.okhttp3:okhttp:4.3.1")
implementation 'com.google.code.gson:gson:2.8.6'
compile("org.openjfx:javafx-base:${javafxVersion}:$javafxPlatform")
compile("org.openjfx:javafx-controls:${javafxVersion}:$javafxPlatform")
compile("org.openjfx:javafx-graphics:${javafxVersion}:${javafxPlatform }")
compile("org.openjfx:javafx-fxml:${javafxVersion}:${javafxPlatform }")
}
javafx {
version = "${javafxVersion}"
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml', 'javafx.graphics']
/**
* https://github.com/openjfx/javafx-gradle-plugin
* JavaFX modules require native binaries for each platform. The plugin only includes binaries for the platform
* running the build. By declaring the dependency configuration compileOnly, the native binaries will not be
* included. You will need to provide those separately during deployment for each target platform.
*/
configuration = 'compileOnly'
}
mainClassName = 'org.voc5.javafxclient.Main'
group = 'org.voc5'
description = 'javafx-client'
sourceCompatibility = '11'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes 'Main-Class': 'org.voc5.javafxclient.Main'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment