https://kotlinlang.org logo
g

geepawhill

10/31/2020, 4:48 PM
Or, asked another way, is there a reference project, gradle based, that has the most up-to-date open JDK+JFX+Tornado?
a

altavir

11/01/2020, 6:54 AM
You can use my demo-project: https://github.com/altavir/fx-demo. It is not the most up to date, but it works both for JVM 8 and JVM 9+. Sadly, as always with openjfx plugin, it will work only on the same platform you build it on.
👍 1
m

Marshall

11/01/2020, 2:11 PM
I didn't know you could do conditional plugins
Copy code
if(JavaVersion.current().isJava11Compatible) {
        id("org.openjfx.javafxplugin") version "0.0.8"
    }
I was wondering how you dealt with FX not included in Java 9+
a

altavir

11/01/2020, 2:15 PM
You just download it from maven. The problem is the postfix should be chosen based on the target platform, not the one you develop in. The solution is to use compile-only dependency an then create a start-script that downlowads necessary jmods. Sadly, I hata bash and never got to actually writing it.
m

Marshall

11/01/2020, 2:17 PM
I meant, for JDK8 you don't use that plugin and you don't specify "openjfx" section among others but in your build you use conditionals to handle it
a

altavir

11/01/2020, 2:17 PM
yep.
openjfx won't work for Java8. More importantly, it will crush the build
m

Marshall

11/01/2020, 2:18 PM
I did run across a gradle plugin that will bootstrap JDK, download the JDK version and everything by creating custom gradlew files
a

altavir

11/01/2020, 2:19 PM
I do not think it makes and sense. I was talking about application start scripts. We can manage to create development environment, but user environment on the target machine is a different topic.
m

Marshall

11/01/2020, 2:21 PM
I use the "badass runtime" plugin that downloads the jdk for each target platform and creates a zip that packages the runtime and your app for each platform, it only works with JDK9+ though
a

altavir

11/01/2020, 2:22 PM
It won't help you with javafx, because you need custom jafaFX jmods as well.
m

Marshall

11/01/2020, 2:22 PM
for distributing to users I've started using jpackage and building on each platform which works the best in my opinion
it works fine with javafx
I build mac and windows builds for my coworkers from my linux machine
a

altavir

11/01/2020, 2:23 PM
I mean you still need to build on each platform
m

Marshall

11/01/2020, 2:23 PM
not if you do the runtime zip
a

altavir

11/01/2020, 2:24 PM
It has some kind of customization for openjfx? Because otherwise, only JVM itself will be platform-specific
m

Marshall

11/01/2020, 2:27 PM
you can specify javafx platform in dependencies:
Copy code
// Include java fx libraries for each platform
    runtimeOnly 'org.openjfx:javafx-graphics:$javafx.version:linux'
    runtimeOnly 'org.openjfx:javafx-graphics:$javafx.version:win'
    runtimeOnly 'org.openjfx:javafx-graphics:$javafx.version:mac'
I haven't looked to see if the badass runtime plugin only includes the target platform when it creates the runtime zip
Looks like it includes a number of platform specific files
Looks like he specifies the platform javafx files like this:
Copy code
JavaFXPlatform.values().forEach {platform ->
        val cfg = configurations.create("javafx_" + platform.classifier)
        JavaFXModule.getJavaFXModules(javaFXOptions.modules).forEach { m ->
            project.getDependencies().add(cfg.name,
                    String.format("org.openjfx:%s:%s:%s", m.getArtifactName(), javaFXOptions.version, platform.classifier));
        }
    }
s

Samkeene

11/02/2020, 9:11 PM
@geepawhill I have this I use: https://github.com/SKeeneCode/TornadoFX-Template Javafx 15, Kotlin 1.4.10, gradle 6.6.1, TornadoFX 2.0 Snapshot and 0.0.9 plugin... haven't looked at in a month so might need something changed.
g

geepawhill

11/02/2020, 9:59 PM
Oh, that's nice! That will catch me up quite well. Thanks, Sam, I'll give it a try in the next few days and get back to you.
3 Views