Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] [External Sender] shipping directly a jre with an eclipse product on OSX

So I’ve done this, but not yet with OpenJDK (however I will likely need to update our project once funding resumes to switch to OpenJDK)..

The challenge with macOS is Gatekeeper. I’ve not checked with current versions of Eclipse or Tycho so they may have been updated since I did this, however at the time the location of the JRE and external directory within the App directory by default does not conform to the structure of a macOS Application Bundle per https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW19  The TLDR is if you don’t conform to the conventional structure, Gatekeeper sandboxes your application at runtime, and anything not in the conventional locations will not be accessible your application; e.g. things located outside the <appname>.app/Contents/ won’t be accessible - the JRE by default used to get placed in <appname.app>/JRE, so not visible at runtime.

Basically the long and short of it is that I located the JRE and external in a place that is located in a permissible location (so I could code sign and run the application later without Gatekeeper complaining or the app just plain failing to start). Then you need to modify the <appname>.ini file to alter the startup arguments to utilize the JRE you’re bundling.  One caveat, which was the case I found previously, was that tycho didn’t handle the symlink to libjli.dylib correctly, and thus I had to create it.

Below is an excerpt from our POM which handles all this JRE packaging - minus the code signing…   You could likely “hand jam” the procedure to validate that it still works.  FWIW: I repackaged the Oracle JRE as a Maven artifact and store it in our private Artifactory to make use of it simpler for us. 

Hopefully this is helpful


<profile>
<id>fix-jre-archives</id>
<activation>
<os><family>unix</family></os>
</activation>
<dependencies>
<dependency>
<groupId>com.sri</groupId>
   <artifactId>oracle-jre</artifactId>
   <version>${distrib.oracle-jre.version}</version>
   <classifier>macosx-x64</classifier>
   <type>tar.gz</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-mac-jre</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.sri</groupId>
   <artifactId>oracle-jre</artifactId>
   <version>${distrib.oracle-jre.version}</version>
   <classifier>macosx-x64</classifier>
   <type>tar.gz</type>
<outputDirectory>${distrib.macosx.x86_64}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
 <executions>
<execution>
<id>fix-jre-mac</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${distrib.macosx.x86_64}/${distrib.product.name}.app"/>
<move file="${distrib.macosx.x86_64}/jre${distrib.jre.version}.jre" tofile="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/jre"/>
<symlink action="" link="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/jre/Contents/MacOS/libjli.dylib" />
<symlink link="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/jre/Contents/MacOS/libjli.dylib"
resource="../Home/lib/jli/libjli.dylib" overwrite="true"/>


<concat destfile="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}_temp.ini" fixlastline="yes">
<header filtering="no" trimleading="yes">
-vm
../jre/Contents/Home/lib/server/libjvm.dylib
</header>
<fileset file="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}.ini"/>
</concat>
<move file="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}.ini"
tofile="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}_bak.ini" />
<move file="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}_temp.ini"
tofile="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Eclipse/${distrib.bin.name}.ini" />
</target>
</configuration>
</execution>
<execution>
<id>relocate-external-mac</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Sunflower"/>
<move file="${distrib.macosx.x86_64}/external" tofile="${distrib.macosx.x86_64}/${distrib.product.name}.app/Contents/Sunflower/external" />
</target>
</configuration>
</execution>
<execution>
<id>remove-director-archive-mac</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete file="${archive.macosx.x86_64}" />
<mkdir dir="${distrib.macosx.x86_64}/${distrib.product.name}" />
<move file="${distrib.macosx.x86_64}/${distrib.product.name}.app"
tofile="${distrib.macosx.x86_64}/${distrib.product.name}/${distrib.bin.name}.app" />
<move file="${distrib.macosx.x86_64}/doc"
tofile="${distrib.macosx.x86_64}/${distrib.product.name}/doc" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>



On Apr 30, 2019, at 3:17 AM, Johan Compagner <jcompagner@xxxxxxxxxx> wrote:

Not directly a tycho question, but i guess this group does build there own products so maybe somebody knows the answer to this here?

shipping a jre with a eclipse is for windows quite easy
just unzip a openjdk jre in a "jre" folder besides the eclipse.exe file

But how does this work for the mac/osx?

there we have the eclipse.app can we have there a nested jre (app)?
or should it be besides the eclipse.app? and if it is inside the app in what dir?

--
Johan Compagner
Servoy
_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://gcc01.safelinks.protection.outlook.com/?url="">

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Back to the top