OSX: refactor OSX package based on universalJavaApplicationStub

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2329 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2015-01-25 22:23:38 +00:00
parent 22732ab3e3
commit fda6e03d9e
6 changed files with 78 additions and 186 deletions

View File

@ -93,75 +93,33 @@
</target>
<target name="dist-osx">
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler">
<classpath location="lib/jarbundler-2.1.0.jar"/>
</taskdef>
<jarbundler dir="dist"
shortname="DavMail"
name="DavMail"
mainclass="davmail.DavGateway"
build="${release}"
icon="src/osx/tray.icns"
infostring="DavMail Gateway ${release}"
jvmversion="1.5+"
version="${release}"
vmoptions="-Dsun.net.inetaddr.ttl=60 -Xmx512m"
workingdirectory="$APP_PACKAGE"
stubfile="src/osx/davmail">
<jarfileset dir="dist">
<!-- move jar files to new location -->
<copy todir="dist/DavMail.app/Contents/Java">
<fileset dir="dist">
<include name="*.jar"/>
</jarfileset>
<jarfileset dir="dist/lib">
</fileset>
<fileset dir="dist/lib">
<include name="*.jar"/>
<include name="*.jnilib"/>
<exclude name="swt*.jar"/>
<exclude name="junit-*.jar"/>
<exclude name="winrun4j-*.jar"/>
</jarfileset>
</jarbundler>
<!-- prepare hide from dock option -->
<replaceregexp file="dist/DavMail.app/Contents/Info.plist" match="&lt;key>CFBundleName&lt;/key>"
replace="&lt;key>LSUIElement&lt;/key>&lt;string>0&lt;/string>&lt;key>CFBundleName&lt;/key>"/>
<!-- Retina display support -->
<replaceregexp file="dist/DavMail.app/Contents/Info.plist" match="&lt;key>CFBundleName&lt;/key>"
replace="&lt;key>NSHighResolutionCapable&lt;/key>&lt;true/>&lt;key>CFBundleName&lt;/key>"/>
<zip file="dist/DavMail-MacOSX-${release-name}.app.zip" comment="In order to run DavMail on OSX Mountain Lion, you will need to disable Gatekeeper temporarily, see http://davmail.sourceforge.net/macosxsetup.html">
<zipfileset dir="dist">
<include name="DavMail.app/**/*"/>
<exclude name="DavMail.app/Contents/MacOS/davmail"/>
</zipfileset>
<zipfileset dir="dist" filemode="755">
<include name="DavMail.app/Contents/MacOS/davmail"/>
</zipfileset>
</zip>
<!--delete dir="dist/DavMail.app"/-->
</target>
<target name="dist-osx-java7" depends="dist-osx">
<!-- move jar files to new location -->
<move todir="dist/DavMail.app/Contents/Java">
<fileset dir="dist/DavMail.app/Contents/Resources/Java"/>
</move>
<!-- move libgrowl to library path -->
<move todir="dist/DavMail.app/Contents/MacOS">
<fileset file="dist/DavMail.app/Contents/Java/libgrowl.jnilib"/>
</move>
<!-- use Java7 app launcher -->
<copy file="src/osx-java7/JavaAppLauncher" tofile="dist/DavMail.app/Contents/MacOS/davmail" overwrite="true"/>
<!-- include Java7 labels -->
<copy todir="dist/DavMail.app/Contents/Resources">
<fileset dir="src/osx-java7">
<include name="en.lproj/**"/>
</fileset>
</copy>
<!-- move libgrowl to library path -->
<copy todir="dist/DavMail.app/Contents/MacOS">
<fileset file="lib/libgrowl.jnilib"/>
</copy>
<copy file="src/osx/tray.icns" todir="dist/DavMail.app/Contents/Resources" overwrite="true"/>
<!-- use generic app launcher -->
<copy file="src/osx/davmail" todir="dist/DavMail.app/Contents/MacOS" overwrite="true"/>
<!-- template plist -->
<copy file="src/osx-java7/Info.plist" todir="dist/DavMail.app/Contents" overwrite="true">
<copy file="src/osx/Info.plist" todir="dist/DavMail.app/Contents" overwrite="true">
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<zip file="dist/DavMail-MacOSX-Java7-${release-name}.app.zip" comment="In order to run DavMail on OSX Mountain Lion, you will need to disable Gatekeeper temporarily, see http://davmail.sourceforge.net/macosxsetup.html">
<zip file="dist/DavMail-MacOSX-${release-name}.app.zip" comment="In order to run DavMail on OSX Mountain Lion or later, you will need to disable Gatekeeper temporarily, see http://davmail.sourceforge.net/macosxsetup.html">
<zipfileset dir="dist">
<include name="DavMail.app/**/*"/>
<exclude name="DavMail.app/Contents/MacOS/davmail"/>
@ -424,7 +382,7 @@
<antcall target="dist-nsis"/>
<antcall target="dist-deb"/>
<!--antcall target="dist-rpm"/-->
<antcall target="dist-osx-java7"/>
<antcall target="dist-osx"/>
<!-- source with binary deps package -->
<tar tarfile="dist/davmail-src-${release-name}.tgz" compression="gzip" longfile="gnu">
<tarfileset prefix="davmail-src-${release-name}" dir=".">

View File

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plist version="1.0">
<dict>
<key>LSUIElement</key><string>0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleName</key>
<string>DavMail</string>
<key>CFBundleShortVersionString</key>
<string>${release}</string>
<key>CFBundleGetInfoString</key>
<string>DavMail Gateway ${release-name}</string>
<key>CFBundleAllowMixedLocalizations</key>
<string>false</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>davmail</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${release}</string>
<key>CFBundleIconFile</key>
<string>tray.icns</string>
<key>Java</key>
<dict>
<key>MainClass</key>
<string>davmail.DavGateway</string>
<key>JVMVersion</key>
<string>1.5+</string>
<key>ClassPath</key>
<array>
<string>$JAVAROOT/davmail.jar</string>
<string>$JAVAROOT/activation-1.1.1.jar</string>
<string>$JAVAROOT/appbundler-1.0.jar</string>
<string>$JAVAROOT/checkstyle-all-5.0.jar</string>
<string>$JAVAROOT/commons-codec-1.3.jar</string>
<string>$JAVAROOT/commons-collections-3.1.jar</string>
<string>$JAVAROOT/commons-httpclient-3.1.jar</string>
<string>$JAVAROOT/commons-logging-1.0.4.jar</string>
<string>$JAVAROOT/htmlcleaner-2.2.jar</string>
<string>$JAVAROOT/jackrabbit-webdav-2.4.3.jar</string>
<string>$JAVAROOT/jcharset-1.3.jar</string>
<string>$JAVAROOT/jcifs-1.3.14.jar</string>
<string>$JAVAROOT/jdom-1.0.jar</string>
<string>$JAVAROOT/libgrowl-0.2.jar</string>
<string>$JAVAROOT/libgrowl.jnilib</string>
<string>$JAVAROOT/log4j-1.2.16.jar</string>
<string>$JAVAROOT/mail-1.4.3.jar</string>
<string>$JAVAROOT/slf4j-api-1.3.1.jar</string>
<string>$JAVAROOT/slf4j-log4j12-1.3.1.jar</string>
<string>$JAVAROOT/stax-api-1.0.1.jar</string>
<string>$JAVAROOT/stax2-api-3.1.1.jar</string>
<string>$JAVAROOT/woodstox-core-asl-4.1.2.jar</string>
<string>$JAVAROOT/xercesImpl-2.8.1.jar</string>
</array>
<key>VMOptions</key>
<string>-Dsun.net.inetaddr.ttl=60 -Xmx512m</string>
<key>WorkingDirectory</key>
<string>$APP_PACKAGE</string>
</dict>
<key>JVMMainClassName</key>
<string>davmail.DavGateway</string>
<key>JVMOptions</key>
<array>
<string>-Dsun.net.inetaddr.ttl=60 -Xmx512m -Duser.dir=$APP_ROOT</string>
</array>
</dict>
</plist>

Binary file not shown.

View File

@ -1,3 +0,0 @@
"JRELoadError" = "Java 7 not available, please download and install from http://www.java.com";
"MainClassNameRequired" = "Main class name is required.";
"JavaDirectoryNotFound" = "Unable to enumerate Java directory contents.";

36
src/osx/Info.plist Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plist version="1.0">
<dict>
<key>LSUIElement</key><string>0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleName</key>
<string>DavMail</string>
<key>CFBundleShortVersionString</key>
<string>${release}</string>
<key>CFBundleGetInfoString</key>
<string>DavMail Gateway ${release-name}</string>
<key>CFBundleAllowMixedLocalizations</key>
<string>false</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>davmail</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${release}</string>
<key>CFBundleIconFile</key>
<string>tray.icns</string>
<key>JVMMainClassName</key>
<string>davmail.DavGateway</string>
<key>JVMOptions</key>
<array>
<string>-Dsun.net.inetaddr.ttl=60 -Xmx512m</string>
</array>
</dict>
</plist>

View File

@ -183,7 +183,7 @@ else
# set Working Directory and Java and Resources folder
JavaFolder="${OracleJavaFolder}"
ResourcesFolder="${OracleResourcesFolder}"
WorkingDirectory="${OracleJavaFolder}"
WorkingDirectory="${AppPackageFolder}"
APP_ROOT="${AppPackageFolder}"
@ -222,34 +222,21 @@ elif [ -x /usr/libexec/java_home ] && [ -d "`/usr/libexec/java_home 2> /dev/null
JAVACMD="`/usr/libexec/java_home 2> /dev/null`/bin/java"
# otherwise check Java standard symlink (old Apple Java)
elif [ -h /Library/Java/Home ]; then
elif [ -x /Library/Java/Home/bin/java ]; then
JAVACMD="/Library/Java/Home/bin/java"
# fallback: public JRE plugin (Oracle Java)
else
elif [ -x "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" ]; then
JAVACMD="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
else
# fallback fallback: /usr/bin/java
JAVACMD="/usr/bin/java"
fi
# fallback fallback: /usr/bin/java
# but this would prompt to install deprecated Apple Java 6
#
# execute JAVA commandline and do some pre-checks
# execute JAVA commandline
####################################################
# display error message if MainClassName is empty
if [ -z ${JVMMainClass} ]; then
# display error message with applescript
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'!\n\n'MainClass' isn't specified!\nJava application cannot be started!\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
# exit with error
exit 1
# check whether $JAVACMD is a file and executable
elif [ -f "$JAVACMD" ] && [ -x "$JAVACMD" ] ; then
# enable drag&drop to the dock icon
export CFProcessPath="$0"
@ -273,16 +260,3 @@ elif [ -f "$JAVACMD" ] && [ -x "$JAVACMD" ] ; then
${JVMDefaultOptions:+$JVMDefaultOptions }\
${JVMMainClass}\
${JVMArguments:+ $JVMArguments}
else
# display error message with applescript
osascript -e "tell application \"System Events\" to display dialog \"ERROR launching '${CFBundleName}'!\n\nYou need to have JAVA installed on your Mac!\nVisit http://java.com for more information...\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1 with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
# and open java.com
open http://java.com
# exit with error
exit 1
fi