Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create SWT Maven project without having to provide platform specific SWT binaries

Tags:

maven

swt

I'm trying to build a (nearly) platform independent SWT Maven archetype to build SWT applications out of. It should automatically download the needed SWT libraries depending on the platform. This is my pom so far:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.mackaz</groupId>
    <artifactId>swttest</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <swt.version>3.7</swt.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${swt.groupId}</groupId>
            <artifactId>${swt.artifactId}</artifactId>
            <version>${swt.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <debug>true</debug>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <name>mac os x</name>
                </os>
            </activation>
            <properties>
                <swt.groupId>org.eclipse.swt.carbon</swt.groupId>
                <swt.artifactId>macosx</swt.artifactId>
            </properties>
        </profile>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <swt.groupId>org.eclipse.swt.win32.win32</swt.groupId>
                <swt.artifactId>x86</swt.artifactId>
            </properties>
        </profile>
        <profile>
            <id>linux</id>
            <activation>
                <os>
                    <family>linux</family>
                </os>
            </activation>
            <properties>
                <swt.groupId>org.eclipse.swt.gtk.linux</swt.groupId>
                <swt.artifactId>x86_64</swt.artifactId>
            </properties>
        </profile>
    </profiles>
</project>

I just learned that there seems to be NO official Maven repository for SWT (why???). Since I don't want to provide the SWT Jars for all platforms together with my archetype, I want to write a little script which downloads the right library automatically.

But now I have the next problem: is there a reliable source where I can download the platform specific SWT jars? When trying to download them from eclipse.org, you don't get any permanent and reliable links. What are the best practices to distribute an SWT Maven project without having to provide the platform specific SWT binaries?

EDIT:

Additional info to this problem after some research:

There seems to be a related Issue, which exists since 3.4:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=199302

Also, there is an Eclipse Forum entry where somebody asks for a Maven Repo:
http://www.eclipse.org/forums/index.php/m/526969/

And I also posted a (quite redundant) Forum entry about this:
http://www.eclipse.org/forums/index.php/t/215253/

So no solution yet (but I'm open for alternative solutions)

like image 820
Wolkenarchitekt Avatar asked Jun 23 '11 14:06

Wolkenarchitekt


2 Answers

There are no SWT Libraries in the Eclipse Maven Repositories. A related (and unresolved) Issue exists since 3.4: https://bugs.eclipse.org/bugs/show_bug.cgi?id=199302

EDIT:

Cool, at least now there is a testing repository which already contains a lot of SWT libs: http://maven.eclipse.org/nexus/content/repositories/testing/org/eclipse/swt/
If the structure does not change one could already write clients and later exchange the address with a non-testing-Maven-repo.

like image 103
Wolkenarchitekt Avatar answered Nov 29 '22 13:11

Wolkenarchitekt


Starting with Eclipse 4.6.2, SWT (and all of Eclipse) is published to maven central. If you're using Gradle, the goomph plugin has a mavencentral plugin that makes it pretty easy:

apply plugin: 'com.diffplug.gradle.eclipse.mavencentral'
eclipseMavenCentral {
  release '4.7.0', {
    compile 'org.eclipse.swt'
    useNativesForRunningPlatform()
  }
}
like image 24
Ned Twigg Avatar answered Nov 29 '22 14:11

Ned Twigg