Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save valery-barysok/d16e47ebadfefb335f2293bad2a1c95a to your computer and use it in GitHub Desktop.
Save valery-barysok/d16e47ebadfefb335f2293bad2a1c95a to your computer and use it in GitHub Desktop.
A shell script to create a NetBeans.app package for macOS from the NetBeans binaries
#!/bin/bash
clear
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then
echo "
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a dir.
Usage: `basename "$0"` netbeans_dir
- netbeans_dir: The directory containing all the files for a specific NetBeans release.
All those files will be copied into a NetBeans.app bundle.
You can download a NetBeans release zip file at https://netbeans.apache.org/download/
Copyright (c) Thomas Aylott <http://subtlegradient.com/>
Modified by Mathias Bynens <http://mathiasbynens.be/> and Manoel Campos <http://twitter.com/manoelcampos>
"
exit;
fi
APPNAME="NetBeans"
APP_DIR="$APPNAME.app"
APP_MACOS_DIR="$APP_DIR/Contents/MacOS"
APP_RESOURCES_DIR="$APP_DIR/Contents/Resources"
rm -rf "$APP_DIR"
echo "Copying $1 content to $APP_DIR"
rm -f "$1/bin/netbeans.exe"
rm -f "$1/bin/netbeans64.exe"
cp -r "$1" "$APP_DIR" && \
mkdir -p "$APP_MACOS_DIR" && \
mkdir -p "$APP_RESOURCES_DIR" && \
ln -s "../../bin/netbeans" "$APP_MACOS_DIR/$APPNAME" && \
chmod +x "$APP_MACOS_DIR/$APPNAME" && \
echo -e "<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version='1.0'>
<dict>
<key>CFBundleExecutable</key>
<string>$APPNAME</string>
<key>CFBundleIconFile</key>
<string>$APPNAME.icns</string>
<key>CFBundleName</key>
<string>$APPNAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>10.10</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
</dict>
</plist>
" > "$APP_DIR/Contents/Info.plist" && \
cp "$1/nb/netbeans.icns" "$APP_RESOURCES_DIR/$APPNAME.icns" && \
echo "$PWD/$APP_DIR created" || (echo "Error trying to create $APP_DIR package")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment