18

Well, in short, I may need to grab new SWT version instead of 3.3 we're using for now. The project now has only this dependency and builds fine:

<dependency>
  <groupId>org.eclipse.swt.win32.win32</groupId>
  <artifactId>x86</artifactId>
  <version>3.3.0-v3346</version>
</dependency>

AFAICGoogle, there is no more recent version in the public maven repo: http://repo1.maven.org/maven2/org/eclipse/swt/

So:

  1. Is there some public maven repo with recent builds?
  2. If not, where do you get the jars you install locally and/or in your corporate Nexus?
  3. Any groupId/artifactId suggestions/conventions you know of?

TIA

PS: I am mostly a noob as to Eclipse products site layout and usually get lost in Google search results and/or the Eclipse site itself... so while the answer may be obvious for you it would likely not be so for me, even retrospectively.

Anton Kraievyi
  • 4,182
  • 4
  • 26
  • 41

5 Answers5

42

I have created a maven repo for windows, Linux & osx artifacts at github:

https://github.com/maven-eclipse/swt-repo

To use it just put the following in your pom.xml:

<repositories>
    <repository>
        <id>swt-repo</id>
        <url>https://raw.githubusercontent.com/maven-eclipse/swt-repo/master/</url>
    </repository>
</repositories>

Then you can just reference the SWT dependency relevant to your platform. For example:

    <dependency>
        <groupId>org.eclipse.swt</groupId>
        <artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
        <version>4.4</version>
    </dependency>

For other platforms, just replace artifactId with the appropriate value:

  • org.eclipse.swt.win32.win32.x86
  • org.eclipse.swt.win32.win32.x86_64
  • org.eclipse.swt.gtk.linux.x86
  • org.eclipse.swt.gtk.linux.x86_64
  • org.eclipse.swt.cocoa.macosx
  • org.eclipse.swt.cocoa.macosx.x86_64

In addition, artifacts for SWT 4.3.2, 4.3.1, 4.3.0, 4.2.2, 4.2.1, 3.8, 3.7.2 & 3.5.1 are also available from this repository.

We use a selenium-based approach to automatically deploy the artifacts of new SWT versions as they are released. The source code for the automation is open and available on github:

https://github.com/hennr/swt-release-fetcher

Happy coding!

hennr
  • 2,632
  • 2
  • 23
  • 26
urish
  • 8,943
  • 8
  • 54
  • 75
  • Thanks! I wish this was sorted out in central. – Steve Swinsburg Jun 27 '13 at 02:21
  • Both `swt-repo` and `swt-release-fetcher` are no longer maintained since Oct. 2015. See these two SO answers to grab SWT related artifacts: https://stackoverflow.com/a/15487277/363573 and https://stackoverflow.com/a/41586394/363573. – Stephan Dec 20 '17 at 16:50
16

Update: The repo was taken down and replaced by repo.eclipse.org which does not hold SWT artifacts.

You can use a Nexus repository hosted at eclipse (this repository is in 'testing' status)

http://maven.eclipse.org/nexus/content/repositories/testing/org/eclipse/swt/

There is a bug open on this with further info: https://bugs.eclipse.org/bugs/show_bug.cgi?id=199302

hennr
  • 2,632
  • 2
  • 23
  • 26
lenkite
  • 1,102
  • 13
  • 9
11

Grab here the version you need. SWT is still not bundled platform-neutrally, so you have to pay attention to the platform to use. I'd grabbed windows version, with postfix of 3.6.1-win32-win32-x86. I've used that as a versionId, leaving the platform out of group/artifact fields. This might be not totally correct for maven gurus but fits for me quite well (at least for now). Also I am using the debug-version of the jar, which is okay for development.

So here we go.

Unpack the archive and then issue this (in the root folder of your archive):

mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.6.1-win32-win32-x86 -Dfile=swt-debug.jar -Dpackaging=jar -DlocalRepositoryPath=../path/to/your/local/project/repo

and then this, to install sources as well:

mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.6.1-win32-win32-x86 -Dfile=src.zip -Dpackaging=jar -Dclassifier=sources -DlocalRepositoryPath=../path/to/your/local/project/repo

Add reference to a local repo to your pom.xml,

<repositories>
    <repository>
        <id>local</id>
        <name>Project Local Repository</name>
        <layout>default</layout>
        <url>file://${project.baseDir}/path/to/your/local/project/repo/</url>
    </repository>
</repositories>

and then add a dependency itself:

<dependency>
    <groupId>org.eclipse</groupId>
    <artifactId>swt</artifactId>
    <version>3.6.1-win32-win32-x86</version>
</dependency>

Hope this helps someone, and I get some karma for bounties on other, harder questions of mine... ;)

Anton Kraievyi
  • 4,182
  • 4
  • 26
  • 41
  • 1
    By the way, if you are installing it on linux the command should be *mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.7-gtk-linux-amd64-x86 -Dpackaging=jar -Dfile=swt-debug.jar* – Vlad Aug 02 '11 at 00:01
4

As of Neon.2 (v 4.6.2) many Eclipse bundles, including SWT, are available on Maven Central:

https://repo1.maven.org/maven2/org/eclipse/platform/

Note that, in contrast to earlier published SWT artifacts, the group id was changed to org.eclipse.platform. To include SWT for Windows, for example, add this to your pom:

<dependency>
    <groupId>org.eclipse.platform</groupId>
    <artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
    <version>${swt-version}</version>  <!-- currently 3.105.2 -->
</dependency>

From now on, all Eclipse platform releases (currently published every year around June) will be available as maven artifacts. See here to find the most recent version number: https://search.maven.org/#search%7Cga%7C1%7Corg.eclipse.platform%20swt

See here for an announcement with further details: https://objectteams.wordpress.com/2017/01/09/eclipse-neon-2-is-on-maven-central/

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • If I try to use this location in a gradle buid file, I get "Could not find any matches for org.eclipse.platform:org.eclipse.swt.gtk.linux.aarch64:[3.105.2,3.105.2]". I guess it's related to bug 491951...? Do you happen to know how to exclude this platform in gradle? I am trying to build a library that depends on SWT, so theoretically I should need only the SWT "declarations", no actual platform implementation.... Is there any "clean" gradle way for this case? – Stefan Haustein Mar 19 '17 at 20:01
  • I am afraid, I don't know of a _clean_ way to work around this in Gradle. Unfortunately, SWT does not provide separate artifacts for API and implementation - and guessing from how the source code is organized this isn't easy to achieve either. Have you tried using the repository mentioned in [in comment #35](https://bugs.eclipse.org/bugs/show_bug.cgi?id=491951#c35) as a workaround? – Rüdiger Herrmann Mar 20 '17 at 06:13
  • #35 points to an eclipse update site... Are you aware of any way to point gradle to this? – Stefan Haustein Mar 20 '17 at 19:54
  • Ups, my bad.Your best bet may be to attempt to convert the p2 repository into Maven repository. – Rüdiger Herrmann Mar 21 '17 at 20:20
  • The latest version served by this repository seems to be ancient. If I try to use it, I cannot compile because certain classes are missing methods. Specifically, the `Color` class does not seem to have a `getAlpha()` method. Is my understanding correct that the versions served by this repository are useless today, or am I doing something wrong? – Mike Nakis Apr 29 '19 at 21:02
  • I couldn't find a recent version either. To clarify what their current policy for releasing Maven artefacts is you may want to ask on the eclipse platform mailing list: https://accounts.eclipse.org/mailing-list/platform-dev . – Rüdiger Herrmann May 01 '19 at 08:18
4

have a look at the maven-eclipse-plugin. Assuming you have a local eclipse installation at /opt/eclipse, do the following:

mvn eclipse:to-maven -DeclipseDir=/opt/eclipse/ -DstripQualifier=true

This will generate poms for all eclipse plugins and upload them to your local repo. It's also possible to load the generated poms and jars to a remote repo using the plugin option "deployTo".

See also:
maven-eclipse-plugin

After that you can use the artifacts from the repository.

Hope the information is helpfull.

-Martin

MNeimeier
  • 196
  • 3
  • 2
    Not sure this will get me going with SWT jars. Are you serious about installing eclipse just to mavenize one library jar for a specific platform? I think the whole library/update approach, which eclipse platform uses, goes to some weird direction if you're serious... – Anton Kraievyi Mar 19 '11 at 09:56