Using SWT and JFace with Maven in non-OSGi projects
There is no problem in using SWT and JFace in Eclipse applications.
These libraries were designed for it. Eclipse building solutions handle them well (p2, Tycho…).
SWT and JFace can also be used outside Eclipse.
However, they are not usable as libraries with Maven. Only as bundles with Tycho. This is because Eclipse releases are not hosted on Maven repositories but on p2 repositories. The Maven plugin called Tycho allows Maven, among other things, to rely on p2 repositories. But it is intended to build OSGi applications.
Hopefully, there is now a regular Maven repository that hosts SWT and JFace bundles as libraries.
Thus, they can be used with Maven, in non-Osgi projects. This repository is available at this address: http://swt-repo.googlecode.com/svn/repo/
To use these libraries in a non-Osgi project, add the repository to your POM.
<repositories> <repository> <id>swt-repo</id> <url>https://swt-repo.googlecode.com/svn/repo/</url> </repository> </repositories>
If you only want to use SWT, add the SWT library that fits your operating system.
As an example, for Windows x64.
<dependencies> <!-- SWT --> <dependency> <groupId>org.eclipse.swt</groupId> <artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId> <version>3.7.2</version> </dependency> </dependencies>
If in addition you want to use JFace and Eclipse extensions for JFace (ListDialog, ListeSelectionDialog…), add the following dependency. This will add JFace by transitivity.
<dependencies> <!-- JFace + Eclipse's JFace extensions --> <dependency> <groupId>org.eclipse.ui</groupId> <artifactId>org.eclipse.ui.workbench</artifactId> <version>3.7.1.v20120104-1859</version> </dependency> </dependencies>
If you need JFace but not its Eclipse extensions, add instead…
<dependencies> <!-- JFace dependencies --> <dependency> <groupId>org.eclipse.jface</groupId> <artifactId>org.eclipse.jface</artifactId> <version>3.7.0.v20110928-1505</version> </dependency> </dependencies>
Other versions of SWT and JFace should be added to the repository.
Another solution could be based on Tycho. But so far, I have not found any solution. I started a thread about this on the Tycho-user mailing list.
Anyway, the solution described above will fit all the Maven versions.
A Tycho-based solution would only work with Maven3 (but would avoid duplicating the libraries).