Maven: How to define target OS?

Viewed 359

I have a Java application, which has a Maven dependency on JavaFX. If I'm building this application on macOS, the resulting jar contains macOS specific JavaFX libraries, e.g. javafx-controls-11.0.2-mac.jar. Thus, I can't just take this jar and run it on Windows.

If I build this application on Windows, I get a Windows dependent jar, which can't be run on macOS.

Is there any way, to tell Maven to build the application for a specific OS? I mean, if I were using a Linux build server, the resulting jar would only be runnable on Linux...

I tried to run Maven with the flag -Dos.name=Windows, but that didn't do the job.

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx</artifactId>
            <version>11</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
        </dependency>
0 Answers
Related