Skip to content

Commit

Permalink
OSX .app bundle with embedded JRE: 'mvn -P create-dmg package'
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Aug 8, 2017
1 parent 8efec62 commit 7140e25
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 32 deletions.
19 changes: 0 additions & 19 deletions ugs-platform/application/launcher.conf

This file was deleted.

181 changes: 180 additions & 1 deletion ugs-platform/application/pom.xml
Expand Up @@ -78,19 +78,51 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<configuration>
<!-- Set up the gephi.conf for the final artifact -->
<etcConfFile>${basedir}/target/${brandingToken}.conf</etcConfFile>
</configuration>
</plugin>
<!-- Permits NbModuleSuite to be run in integration-test phase: -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${ugs.maven-surefire-plugin}</version>
<version>${ugs.maven-surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<all.clusters>${all.clusters}</all.clusters>
<branding.token>${brandingToken}</branding.token>
</systemPropertyVariables>
</configuration>
</plugin>

<!-- Copy ressources gephi.conf and Info.plist with filtering (replacing 'project.version' by the actual version -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>generate-app-conf-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>${brandingToken}.conf</include>
<include>Info.plist</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<escapeString>\</escapeString>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -116,5 +148,152 @@
</plugins>
</build>
</profile>

<profile>
<id>create-dmg</id>
<properties>
<skipCreateDmg>false</skipCreateDmg>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<!-- Create the Mac OS X application bundle and dmg file -->
<execution>
<id>create-app-bundle</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skipCreateDmg}</skip>
<target>
<!-- Clean -->
<delete includeEmptyDirs="true" failonerror="false" removeNotFollowedSymlinks="true">
<fileset dir="${project.build.directory}/${ugs.appbundle.name}.app" followsymlinks="false"/>
<fileset dir="${project.build.directory}/${ugs.app.title}" followsymlinks="false"/>
<fileset dir="${project.build.directory}/${project.artifactId}-${project.version}.dmg" followsymlinks="false"/>
</delete>
<delete file="${project.build.directory}/${project.artifactId}-${project.version}.dmg" failonerror="false"/>

<!-- Create folders -->
<mkdir dir="${project.build.directory}/${ugs.appbundle.name}.app"/>
<mkdir dir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/MacOS"/>

<!-- Copy application -->
<copy todir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/Resources/${brandingToken}">
<fileset dir="${project.build.directory}/${brandingToken}"/>
</copy>

<!-- Copy logo and configuration files -->
<copy tofile="${project.build.directory}/${ugs.appbundle.name}.app/Contents/Resources/${brandingToken}.icns" file="src/main/app-resources/${brandingToken}.icns" />
<copy tofile="${project.build.directory}/${ugs.appbundle.name}.app/Contents/Info.plist" file="${project.build.directory}/Info.plist"/>

<!-- Move bin/ugsplatform script into MacOS/ugsplatform and modify the script so it founds its resources -->
<move file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/Resources/${brandingToken}/bin/${brandingToken}" todir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/MacOS"/>
<replace file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/MacOS/${brandingToken}" token="`dirname &quot;$PRG&quot;`" value="`dirname &quot;$PRG&quot;`&quot;/../Resources/${brandingToken}/bin&quot;"/>
<chmod file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/MacOS/${brandingToken}" perm="ugo+rx"/>

<!-- Download and untar JRE -->
<exec dir="${project.build.directory}" executable="curl">
<arg line="-L"/>
<arg line="-C"/>
<arg line="-"/>
<arg line="-b"/>
<arg line="&quot;oraclelicense=accept-securebackup-cookie&quot;"/>
<arg line="-O"/>
<arg line="${ugs.bundle.jre.url}/${ugs.bundle.jre.version}.tar.gz"/>
</exec>

<!-- Unzip archive -->
<mkdir dir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns"/>
<exec dir="${project.build.directory}" executable="tar">
<arg line="-zxf"/>
<arg line="${ugs.bundle.jre.version}.tar.gz"/>
<arg line="-C &quot;${ugs.appbundle.name}.app/Contents/PlugIns&quot;"/>
</exec>

<!-- Remove quarantine bit set recursively on JRE -->
<exec dir="${project.build.directory}" os="Mac OS X" executable="xattr">
<arg line="-rd"/>
<arg line="com.apple.quarantine"/>
<arg line="&quot;${ugs.appbundle.name}.app/Contents/PlugIns&quot;"/>
</exec>

<!-- Get the JRE folder name -->
<path id="jre_name">
<dirset dir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns" includes="jre*" />
</path>
<property name="bundle.jre.path" refid="jre_name" />
<basename property="bundle.jre.name" file="${bundle.jre.path}"/>

<!-- Configure relative JRE path into ugsplatform.conf -->
<replace file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/Resources/${brandingToken}/etc/${brandingToken}.conf" token="#jdkhome=&quot;/path/to/jdk&quot;" value="jdkhome=&quot;../../PlugIns/${bundle.jre.name}/Contents/Home&quot;"/>
<chmod file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns/**" perm="+x" type="both"/>

<!-- Fix JRE by replacing libjli.dylib symlink with real file -->
<delete file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/MacOS/libjli.dylib"/>
<copy file="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/Home/lib/jli/libjli.dylib" todir="${project.build.directory}/${ugs.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/MacOS"/>

<!-- Codesign JRE -->
<exec dir="${project.build.directory}" os="Mac OS X" executable="codesign">
<arg value="-fs"/>
<arg value="${ugs.codesign.identity}"/>
<arg value="-v"/>
<arg value="${ugs.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/"/>
</exec>

<!-- Codesign app -->
<exec dir="${project.build.directory}" os="Mac OS X" executable="codesign">
<arg value="-fs"/>
<arg value="${ugs.codesign.identity}"/>
<arg value="-v"/>
<arg value="${ugs.appbundle.name}.app"/>
</exec>

<!-- Create application folder and add Applications dynamic link -->
<mkdir dir="${project.build.directory}/${ugs.app.title}"/>
<move file="${project.build.directory}/${ugs.appbundle.name}.app" todir="${project.build.directory}/${ugs.app.title}/" />
<symlink link="${project.build.directory}/${ugs.app.title}/Applications" resource="/Applications" failonerror="false" />

<!-- Create DMG (Mac OS X) -->
<exec dir="${project.build.directory}" os="Mac OS X" executable="hdiutil">
<arg value="create"/>
<arg value="-noanyowners"/>
<arg value="-imagekey"/>
<arg value="zlib-level=9"/>
<arg value="-srcfolder"/>
<arg value="${project.build.directory}/${ugs.app.title}"/>
<arg value="${project.artifactId}-${project.version}.dmg"/>
</exec>

<!-- Create DMG (Linux), only for testing -->
<exec dir="${project.build.directory}" os="Linux" executable="genisoimage">
<arg value="-V"/>
<arg value="${ugs.appbundle.name}"/>
<arg value="-U"/>
<arg value="-D"/>
<arg value="-l"/>
<arg value="-allow-multidot"/>
<arg value="-max-iso9660-filenames"/>
<arg value="-relaxed-filenames"/>
<arg value="-no-iso-translate"/>
<arg value="-r"/>
<arg value="-o"/>
<arg value="${project.artifactId}-${project.version}.dmg"/>
<arg value="-root"/>
<arg value="${project.build.directory}/${ugs.app.title}"/>
<arg value="${project.build.directory}/${ugs.app.title}"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Binary file not shown.
35 changes: 35 additions & 0 deletions ugs-platform/application/src/main/resources/Info.plist
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plist version="1.0">
<dict>

<key>CFBundleName</key>
<string>Universal Gcode Platform</string>

<key>CFBundleVersion</key>
<string>${project.version}</string>

<key>CFBundleExecutable</key>
<string>${brandingToken}</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleShortVersionString</key>
<string>${project.version}</string>

<key>CFBundleSignature</key>
<string>????</string>

<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

<key>CFBundleIdentifier</key>
<string>${project.groupId}</string>

<key>CFBundleIconFile</key>
<string>${brandingToken}.icns</string>

<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
14 changes: 14 additions & 0 deletions ugs-platform/application/src/main/resources/ugsplatform.conf
@@ -0,0 +1,14 @@
# \${HOME} will be replaced by user home directory according to platform
default_userdir="\${HOME}/.\${APPNAME}/${project.version}/dev"
default_mac_userdir="\${HOME}/Library/Application Support/\${APPNAME}/${project.version}/dev"

# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--branding ${branding.token} -J-Xms64m -J-Xverify:none -J-Dsun.java2d.noddraw=true -J-Dsun.awt.noerasebackground=true -J-Dnetbeans.indexing.noFileRefresh=true"
# for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea

# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
#jdkhome="/path/to/jdk"

# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#extra_clusters=
40 changes: 28 additions & 12 deletions ugs-platform/pom.xml
Expand Up @@ -17,20 +17,31 @@

<properties>
<netbeans.version>RELEASE81</netbeans.version>
<ugs.app.title>Universal Gcode Platform ${project.version}</ugs.app.title>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!--==== Mac OS X bundle settings ====-->
<ugs.appbundle.name>Universal Gcode Platform</ugs.appbundle.name>
<ugs.bundle.jre.url>http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163</ugs.bundle.jre.url>
<ugs.bundle.jre.version>jre-8u131-macosx-x64</ugs.bundle.jre.version>

<!-- Mac OS X signing identity - must match with a verified Apple developer certificate in the keychain -->
<ugs.codesign.identity>Developer ID Application</ugs.codesign.identity>

<!--==== Netbeans Plugin Settings ====-->
<brandingToken>ugsplatform</brandingToken>
<all.clusters>${project.build.directory}/${brandingToken}</all.clusters>

<!--==== Plugin Versions ====-->
<ugs.maven-surefire-plugin>2.20</ugs.maven-surefire-plugin>
<ugs.maven-surefire-plugin.version>2.20</ugs.maven-surefire-plugin.version>

<ugs.maven-jar-plugin.version>3.0.2</ugs.maven-jar-plugin.version>

<ugs.maven-compiler-plugin.version>3.6.1</ugs.maven-compiler-plugin.version>

<ugs.maven-antrun-plugin.version>1.8</ugs.maven-antrun-plugin.version>

<ugs.nbm-maven-plugin.version>4.1</ugs.nbm-maven-plugin.version>
</properties>

Expand Down Expand Up @@ -71,17 +82,22 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${ugs.maven-jar-plugin.version}</version>
<configuration>
<archive>
<!-- required since nbm-maven-plugin 3.0-->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${ugs.maven-jar-plugin.version}</version>
<configuration>
<archive>
<!-- required since nbm-maven-plugin 3.0-->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${ugs.maven-antrun-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down

0 comments on commit 7140e25

Please sign in to comment.