Porting SWT apps to both Mac and Linux

If you need to build an SWT application that runs on multiple platforms, and you use Maven to build, this link is really helpful.

In case that link stops working, the relevant bit is this part:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>swt-test</artifactId>
  <packaging>jar</packaging>
  <version>0.1</version>

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

  <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>
It's only fair to share...
Share on Facebook
Facebook
Google+
Google+
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Leave a Reply