Skip to content

Commit

Permalink
Edit build.gradle file to work for cross platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
beatricecst committed Sep 24, 2023
1 parent 92062a4 commit a9f45ea
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'org.openjfx.javafxplugin' version '0.0.13'

}

repositories {
Expand All @@ -12,23 +13,37 @@ repositories {
dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'

// String javaFxVersion = '17.0.7'
// //String javaFxVersion = '11.0.2'
//
// implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
// implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
// implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
// implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
// implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
// implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
// implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
// implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
// implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
// implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
// implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
// implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'

def platforms = ["win", "linux", "mac"]
def javafxDependency = ["javafx-graphics", "javafx-controls", "javafx-fxml"]

String javaFxVersion = '17.0.7'

implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
for (plt in platforms) {
for (dep in javafxDependency) {
runtimeOnly "org.openjfx:$dep:$javafx.version:$plt"
}
}
}




test {
useJUnitPlatform()

Expand All @@ -47,17 +62,18 @@ application {
mainClass.set("duke.Launcher")
}

shadowJar {
javafx {
version = '17.0.7'
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml', 'javafx.graphics']
}

shadowJar{
archiveBaseName = "duke"
archiveClassifier = null
dependsOn("distZip", "distTar")
archiveFileName = 'duke.jar'
}

javafx {
version = "17.0.7"
modules = [ 'javafx.controls' , 'javafx.fxml' ]
}


run{
Expand Down

0 comments on commit a9f45ea

Please sign in to comment.