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.
<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>