This project help build multiplatform swt application jar. One jar to run on all platforms using just maven without osgi or tycho.
git clone https://github.com/jendap/multiplatform-swt.git
cd multiplatform-swt
mvn package -Pmultiplatform
java -jar multiplatform-swt-example/target/*.jarCopy dependecies, spring-boot-maven-plugin and profiles section from
swt-multiplatform-example/pom.xml
into your pom.xml.
It is important to keep the dependency on multiplatform-swt-loader
and layoutFactory configuration in spring-boot-maven-plugin.
All versions of multiplatform jar files have to be on classpath when
building the final package. The example achieve this by defining
multiplatform profile.
This project builds on top of the great
spring-boot-maven-plugin.
We create custom
MultiPlatformJarLayout
to add our own
MultiPlatformJarLauncher.
The jar launcher implements postProcessClassPathArchives to remove
undesirable jars from classpath.
The classpath (and the jar) contains all the dependencies.
We are adding all the platform specific variants to classpath
when building the jar. See multiplatform profile in
swt-multiplatform-example/pom.xml.
The actual logic of system properties os.name and os.arch
mapping to eclipse jar file names is in
MultiPlatformJarNaming.
- Check other options of using swt. There used to be
tychoproject. It was modularized eclipse platform. It allowed to reuse all plugins of eclipse ecosystem. But that was some years back. There may be other recommended ways these days. - Feel free to add
WarLauncherand/orPropertesLauncherin similar fashion. - Calling
Display.setAppName(this.getClass().getName());before anything else will setWM_CLASSonlinux. That can be matched withStartupWMClassin *.desktop file. Use it to get icons for your app.