5

I have built an Eclipse RCP application (Indigo) with Tycho. The build is run on a Win 7, 64-bit machine.

The parent POM includes:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>target-platform-configuration</artifactId>
  <version>${tycho-version}</version>
  <configuration>
  <resolver>p2</resolver>

  <environment>
    <os>linux</os>
    <ws>gtk</ws>
    <arch>x86_64</arch>
  </environment>
  <environment>
    <os>win32</os>
    <ws>win32</ws>
    <arch>x86_64</arch>
  </environment>
  <environment>
    <os>macosx</os>
    <ws>cocoa</ws>
    <arch>x86_64</arch>
  </environment>

...

The product configuration looks like this (with a few omissions and extra line breaks for readbility):

<product name="My App" uid="myapp.product" id="myapp.core.product" application="myapp.core.application" version="0.1.4.qualifier" useFeatures="true" includeLaunchers="true">

   <configIni use="default">
   </configIni>

   <launcherArgs>
      <programArgs>-data @noDefault</programArgs>
      <vmArgsMac>-XstartOnFirstThread
                         -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
   </launcherArgs>

   <launcher name="myapp_0_1_4">
      <solaris/>
      <win useIco="false">
         <bmp/>
      </win>
   </launcher>

   <vm>
      <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</macos>
   </vm>

   <plugins>
      <plugin id="com.ibm.icu"/>
      <plugin id="myapp.core"/>
      <plugin id="org.eclipse.core.runtime"/>
      <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
      <plugin id="org.eclipse.equinox.app"/>
      <plugin id="org.eclipse.equinox.common"/>
      <plugin id="org.eclipse.osgi"/>
      <plugin id="org.eclipse.swt"/>
      <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
      <plugin id="org.eclipse.ui"/>
      <plugin id="org.eclipse.ui.workbench"/>
   </plugins>

   <features>
      <feature id="org.eclipse.rcp" version="3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272"/>
      <feature id="myapp.platform_dependencies.feature" version="0.1.4.qualifier"/>
      <feature id="myapp.core.feature" version="0.1.4.qualifier"/>
      <feature id="myapp.ui.feature" version="0.1.4.qualifier"/>
      <feature id="myapp.model.feature" version="0.1.4.qualifier"/>
   </features>

   <configurations>
      <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
      <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
   </configurations>

</product>

The build runs without problems, and generates zip files, which, unpacked on the target OSs Windows & Linux include working launchers. (On Linux, I have to make the launcher executable before being able to run it.)

On Mac OS X (10.6.8), however, the launcher (myapp.app) does nothing...

When I run java -jar -XstartOnFirstThread plugins/org.eclipse.equinox.launcher_[version], the application is launched, albeit without the splash screen.

I imagine I have a wrong setting anywhere in my Product Configuration, but I cannot mind which.

s.d
  • 4,017
  • 5
  • 35
  • 65
  • I should add that I'm using the Indigo p2 repo rather than a local target platform in the build. – s.d Feb 25 '13 at 12:50
  • A note to .app newbies like myself: `myapp.app` is actually a folder, and setting the executable bit for this folder - unless done recursively - won't change anything. The actual launcher file is located within this folder at *myapp.app/Contents/MacOS/myapp*, and setting the executable bit for this file (`chmod +x myapp`) will do the trick and make the app executable (a) via running this file from the command line (from within *myapp.app/Contents/MacOS/* with `./myapp`), (b) via double-clicking on *myapp.app/Contents/MacOS/myapp*, or (c) via double-clicking on *myapp.app* itself (in Finder) – s.d Feb 25 '13 at 19:54

2 Answers2

3

Cross-platform build on Windows for Mac is not expected to work. The reason is that Tycho/p2 would need to simulate a file system with Unix permissions. There is a request for this in Tycho's issue tracker, but IMHO implementing this is not worth the effort.

oberlies
  • 11,503
  • 4
  • 63
  • 110
  • I've read through the bug report, and won't at this point contribute to the discussion whether an implementation of the executable bit feature for Windows is helpful or not (I'm fairly OS-agnostic anyway), but can you confirm that moving the build to, e.g., Linux will fix this? – s.d Feb 25 '13 at 19:42
  • 2
    Yes, cross-platform builds with Tycho work if the build machine is a *nix system. – oberlies Feb 26 '13 at 09:04
1

I have just figured out how to make OSX executable .app from Windows.

You can set the Tycho build to generate .tar.gz files for Mac/Linux, then use a tool to set permission on the executable within the tar file, as tar supports *nix permissions.

Here is a snippet that shows how to set this in a pom.xml file. (This snippet also sets up Mac .app folder and adds version to archive file names): http://snipt.org/Aggid3

Here is a Java class that does the permissions bit. It requires Guava and Apache Commons Compress: http://snipt.org/Aggic1

Here is a prebuilt jar including all the dependencies: https://mega.co.nz/#!WcNjyRjS!KE7tM1xYrt1l9JIguUAsrgpLe2V0NS1QIj_NvdAnm88

A usage example using the above would be: java -jar gztperms.jar “My Product-0.0.1.201309091838-macosx.cocoa.x86.tar.gz” “My Product-Executable-0.0.1.201309091838-macosx.cocoa.x86.tar.gz” “My Product.app/Contents/MacOS/My Product”

I have a fairly trivial Ant-based post-build script I execute from Jenkins that finds the .gz file and runs this script on it, and everything now works from the artifact link.

n8n8baby
  • 493
  • 5
  • 16