If you need to solve the SWT
dependencies with Maven for Windows, Linux and Mac you could use a technique described by Olivier Cailloux here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=520337#c0:
The main problem is the dependency of the platform specific builds
(for example, org.eclipse.swt.gtk.linux.x86_64
) to some generic build
(org.eclipse.swt
), which in turn depends on platform specific builds
[...]
I believe the strategy suggested at
https://github.com/oliviercailloux/java-course/tree/master/SWT#maven,
namely, excluding org.eclipse.platform:org.eclipse.swt
, is better than
those suggested in bug 510186 comment 12. Excluding
org.eclipse.platform:org.eclipse.swt
conveys the intent better (this
dependency is not useful and triggers some problems, so let’s tell
Maven that we don’t really need it)
Basically you need to set the corresponding Maven profile for the correct OS and insert this in your pom:
<profiles>
<profile>
<id>swt-unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId>
<env>linux</env>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>3.108.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
<profile>
<id>swt-mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<swt.artifactId>org.eclipse.swt.cocoa.macosx.x86_64</swt.artifactId>
<env>mac</env>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>3.108.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
<profile>
<id>swt-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<swt.artifactId>org.eclipse.swt.win32.win32.x86_64</swt.artifactId>
<env>windows</env>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>3.108.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
</profiles>