├── .hgignore ├── appbundler ├── src │ └── com │ │ └── oracle │ │ └── appbundler │ │ ├── GenericApp.icns │ │ ├── IconContainer.java │ │ ├── Environment.java │ │ ├── Architecture.java │ │ ├── PlistEntry.java │ │ ├── Argument.java │ │ ├── Option.java │ │ ├── TypeDeclaration.java │ │ ├── Runtime.java │ │ ├── BundleDocument.java │ │ └── AppBundlerTask.java ├── res │ ├── en.lproj │ │ └── Localizable.strings │ ├── de.lproj │ │ └── Localizable.strings │ └── fr.lproj │ │ └── Localizable.strings ├── doc │ └── appbundler.html └── native │ └── main.m ├── TODO └── README.md /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | appbundler/bin 3 | .classpath 4 | .project 5 | SwingInterop.jar -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/GenericApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/appbundler/HEAD/appbundler/src/com/oracle/appbundler/GenericApp.icns -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - Architectures should be automatically inferred from the embedded JVM 2 | - It makes more sense to take as input a JRE instead of taking a JDK and strip 3 | it until it becomes a JRE... 4 | -------------------------------------------------------------------------------- /appbundler/res/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "JRELoadError" = "Unable to load Java Runtime Environment."; 2 | "JRExLoadError" = "Unable to load a Java %d Runtime Environment."; 3 | "JRExLoadFullError" = "This application requires that Java %d or later be installed on your computer. Please download and install the latest version of Java from www.java.com and try again."; 4 | "JDKxLoadFullError" = "This application requires that a Java %d JDK or later be installed on your computer. Please download and install the latest Java JDK from Oracle.com and try again."; 5 | "MainClassNameRequired" = "Main class name is required."; 6 | "JavaDirectoryNotFound" = "Unable to enumerate Java directory contents."; 7 | "BundlePathContainsColon" = "Cannot launch from folder that contains a \"/\" in its name."; 8 | -------------------------------------------------------------------------------- /appbundler/res/de.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "JRELoadError" = "Die Java Laufzeitumgebung konnte nicht geladen werden."; 2 | "JRExLoadError" = "Die Java %d Laufzeitumgebung konnte nicht geladen werden."; 3 | "JRExLoadFullError" = "Diese Anwendung benötigt die Java %d Laufzeitumgebung oder höher auf Ihrem Computer installiert sein. Bitte installieren Sie die neueste Version von Java von www.java.com und erneut versuchen."; 4 | "JDKxLoadFullError" = "Diese Anwendung benötigt die Java %d Laufzeitumgebung oder höher auf Ihrem Computer installiert sein. Bitte installieren Sie die neueste JDK von Oracle.com und erneut versuchen."; 5 | "MainClassNameRequired" = "Hauptklassenname ist erforderlich."; 6 | "JavaDirectoryNotFound" = "Das Java Verzeichnis ist nicht vorhanden."; 7 | "BundlePathContainsColon" = "Kann nicht vom einem Ordner aus starten, der \"/\" in seinem Namen enthält."; 8 | -------------------------------------------------------------------------------- /appbundler/res/fr.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "JRELoadError" = "Impossible d'utiliser un environnement Java."; 2 | "JRExLoadError" = "Impossible d'utiliser un environnement Java %d."; 3 | "JRExLoadFullError" = "Ce logiciel nécessite que Java %d ou plus récent être installés sur votre ordinateur. S'il vous plaît télécharger et installer la dernière version de Java à partir de www.java.com et essayez à nouveau."; 4 | "JDKxLoadFullError" = "Ce logiciel nécessite que Java %d JDK ou plus récent être installés sur votre ordinateur. S'il vous plaît télécharger et installer le JDK plus récente de Oracle.com et essayez à nouveau."; 5 | "MainClassNameRequired" = "Principal nom de classe est nécessaire."; 6 | "JavaDirectoryNotFound" = "Impossible d'énumérer répertoire Java contenu."; 7 | "BundlePathContainsColon" = "Pas de commencer à partir d'un dossier qui contient un \"/\" dans son nom."; -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/IconContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Quality First Software GmbH and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | */ 23 | 24 | package com.oracle.appbundler; 25 | 26 | import java.io.File; 27 | 28 | public interface IconContainer { 29 | public boolean hasIcon(); 30 | public String getIcon(); 31 | public File getIconFile(); 32 | } 33 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | package com.oracle.appbundler; 27 | 28 | public class Environment extends Option { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/Architecture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, The Infinite Kind and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. The Infinite Kind designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by The Infinite Kind in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | */ 23 | 24 | package com.oracle.appbundler; 25 | 26 | /** 27 | * Class representing an architecture that will be written in the Info.plist file 28 | * to indicate which architectures the binary support. 29 | */ 30 | public class Architecture { 31 | private String name = null; 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return name; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/PlistEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | package com.oracle.appbundler; 27 | 28 | public class PlistEntry extends Option { 29 | private String type = null; 30 | 31 | public void setKey(String key) { 32 | setName(key); 33 | } 34 | 35 | public String getKey() { 36 | return getName(); 37 | } 38 | 39 | public void setType(String type) { 40 | this.type = type; 41 | } 42 | 43 | public String getType() { 44 | return type; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/Argument.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | 27 | package com.oracle.appbundler; 28 | 29 | /** 30 | * Class representing an argument that will be passed to the Java application 31 | * at startup. 32 | */ 33 | public class Argument { 34 | private String value = null; 35 | 36 | public String getValue() { 37 | return value; 38 | } 39 | 40 | public void setValue(String value) { 41 | this.value = value; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | 27 | package com.oracle.appbundler; 28 | 29 | /** 30 | * Class representing an option that will be passed to the JVM at startup. 31 | * The class can optionally be named, which allows the bundled Java program 32 | * itself to override the option. Changes will take effect upon restart of the 33 | * application.

34 | * Assuming your {@code CFBundleIdentifier} (settable via {@link AppBundlerTask#setIdentifier(String)}) 35 | * is {@code com.oracle.appbundler}. Then you can override a named option by calling 36 | *

37 | * import java.util.prefs.Preferences; 38 | * [...] 39 | * Preferences jvmOptions = Preferences.userRoot().node("/com/oracle/appbundler/JVMOptions"); 40 | * jvmOptions.put("name", "value"); 41 | * jvmOptions.flush(); 42 | * 43 | * The corresponding entries will be stored in a file called 44 | * {@code ~/Library/Preferences/com.oracle.appbundler.plist}. 45 | * To manipulate the file without Java's {@link java.util.prefs.Preferences} from the command line, 46 | * you should use the tool 47 | * defaults. 48 | * For example, to add an entry via the command line, use: 49 | * 50 | * defaults write com.oracle.appbundler /com/oracle/appbundler/ -dict-add JVMOptions/ '{"name"="value";}' 51 | * 52 | * 53 | * @author Hendrik Schreiber (preference related code only) 54 | */ 55 | public class Option { 56 | private String value = null; 57 | private String name = null; 58 | 59 | public String getValue() { 60 | return value; 61 | } 62 | 63 | public void setValue(String value) { 64 | this.value = value; 65 | } 66 | 67 | public String getName() { 68 | return name; 69 | } 70 | 71 | public void setName(final String name) { 72 | this.name = name; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return name == null ? value : name + "=" + value; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/TypeDeclaration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Quality First Software GmbH and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | */ 23 | 24 | package com.oracle.appbundler; 25 | 26 | import static com.oracle.appbundler.BundleDocument.getListFromCommaSeparatedString; 27 | 28 | import java.io.File; 29 | import java.util.Arrays; 30 | import java.util.List; 31 | 32 | /** 33 | * Class representing an UTExportedTypeDeclaration or UTImportedTypeDeclaration in Info.plist 34 | */ 35 | public class TypeDeclaration implements IconContainer { 36 | 37 | private boolean imported = false; 38 | private String identifier = null; 39 | private String referenceUrl = null; 40 | private String description = null; 41 | private String icon = null; 42 | private List conformsTo = null; 43 | private List osTypes = null; 44 | private List mimeTypes = null; 45 | private List extensions = null; 46 | 47 | public TypeDeclaration() { 48 | this.conformsTo = Arrays.asList(new String[]{"public.data"}); 49 | } 50 | 51 | public boolean isImported() { 52 | return imported; 53 | } 54 | 55 | public void setImported(boolean imported) { 56 | this.imported = imported; 57 | } 58 | 59 | public String getIdentifier() { 60 | return identifier; 61 | } 62 | 63 | public void setIdentifier(String identifier) { 64 | this.identifier = identifier; 65 | } 66 | 67 | public String getReferenceUrl() { 68 | return referenceUrl; 69 | } 70 | 71 | public void setReferenceUrl(String referenceUrl) { 72 | this.referenceUrl = referenceUrl; 73 | } 74 | 75 | public String getDescription() { 76 | return description; 77 | } 78 | 79 | public void setDescription(String description) { 80 | this.description = description; 81 | } 82 | 83 | public String getIcon() { 84 | return icon; 85 | } 86 | 87 | public void setIcon(String icon) { 88 | this.icon = icon; 89 | } 90 | 91 | public File getIconFile() { 92 | if (icon == null) { return null; } 93 | 94 | File ifile = new File (icon); 95 | 96 | if (! ifile.exists ( ) || ifile.isDirectory ( )) { return null; } 97 | 98 | return ifile; 99 | } 100 | 101 | public boolean hasIcon() { 102 | return icon != null; 103 | } 104 | 105 | public List getConformsTo() { 106 | return conformsTo; 107 | } 108 | 109 | public void setConformsTo(String conformsToAsString) { 110 | this.conformsTo = getListFromCommaSeparatedString(conformsToAsString, "Conforms To"); 111 | } 112 | 113 | public List getOsTypes() { 114 | return osTypes; 115 | } 116 | 117 | public void setOsTypes(String osTypesAsString) { 118 | this.osTypes = getListFromCommaSeparatedString(osTypesAsString, "OS Types"); 119 | } 120 | 121 | public List getMimeTypes() { 122 | return mimeTypes; 123 | } 124 | 125 | public void setMimeTypes(String mimeTypesAsString) { 126 | this.mimeTypes = getListFromCommaSeparatedString(mimeTypesAsString, "Mime Types", true); 127 | } 128 | 129 | public List getExtensions() { 130 | return extensions; 131 | } 132 | 133 | public void setExtensions(String extensionsAsString) { 134 | this.extensions = getListFromCommaSeparatedString(extensionsAsString, "Extensions", true); 135 | } 136 | 137 | @Override 138 | public String toString() { 139 | return "" + imported; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/Runtime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | 27 | package com.oracle.appbundler; 28 | 29 | import java.io.File; 30 | import java.io.IOException; 31 | 32 | import org.apache.tools.ant.DirectoryScanner; 33 | import org.apache.tools.ant.types.FileSet; 34 | 35 | public class Runtime extends FileSet { 36 | 37 | /* Override to provide canonical path so that runtime can be specified 38 | * via a version-agnostic path (relative link, e.g. `current-jre`) while 39 | * still preserving the original runtime directory name, e.g. `jre1.8.0_45.jre`. 40 | */ 41 | @Override 42 | public File getDir() { 43 | File dir = super.getDir(); 44 | try { 45 | return dir.getCanonicalFile(); 46 | } catch (IOException e) { 47 | return dir; 48 | } 49 | } 50 | 51 | private void detectType() { 52 | boolean isJDK = new File(getDir(), "jre").isDirectory(); 53 | 54 | if (isJDK) { 55 | appendIncludes(new String[] { 56 | "jre/lib/", 57 | "jreCOPYRIGHT", 58 | "jre/LICENSE", 59 | "jre/README", 60 | "jre/THIRDPARTYLICENSEREADME-JAVAFX.txt", 61 | "jre/THIRDPARTYLICENSEREADME.txt", 62 | "jre/Welcome.html" 63 | }); 64 | appendExcludes(new String[] { 65 | "jre/lib/deploy/", 66 | "jre/lib/deploy.jar", 67 | "jre/lib/javaws.jar", 68 | "jre/lib/libdeploy.dylib", 69 | "jre/lib/libnpjp2.dylib", 70 | "jre/lib/plugin.jar", 71 | "jre/lib/security/javaws.policy" 72 | }); 73 | } else { 74 | appendIncludes(new String[] { 75 | "lib/", 76 | "COPYRIGHT", 77 | "LICENSE", 78 | "README", 79 | "THIRDPARTYLICENSEREADME-JAVAFX.txt", 80 | "THIRDPARTYLICENSEREADME.txt", 81 | "Welcome.html" 82 | }); 83 | } 84 | } 85 | 86 | void copyTo(File targetDir) throws IOException { 87 | detectType(); 88 | 89 | File runtimeHomeDirectory = getDir(); 90 | File runtimeContentsDirectory = runtimeHomeDirectory.getParentFile(); 91 | File runtimeDirectory = runtimeContentsDirectory.getParentFile(); 92 | 93 | // Create root plug-in directory 94 | File pluginDirectory = new File(targetDir, runtimeDirectory.getName()); 95 | pluginDirectory.mkdir(); 96 | 97 | // Create Contents directory 98 | File pluginContentsDirectory = new File(pluginDirectory, runtimeContentsDirectory.getName()); 99 | pluginContentsDirectory.mkdir(); 100 | 101 | // Copy MacOS directory 102 | File runtimeMacOSDirectory = new File(runtimeContentsDirectory, "MacOS"); 103 | AppBundlerTask.copy(runtimeMacOSDirectory, new File(pluginContentsDirectory, runtimeMacOSDirectory.getName())); 104 | 105 | 106 | // Copy Info.plist file 107 | File runtimeInfoPlistFile = new File(runtimeContentsDirectory, "Info.plist"); 108 | AppBundlerTask.copy(runtimeInfoPlistFile, new File(pluginContentsDirectory, runtimeInfoPlistFile.getName())); 109 | 110 | // Copy included contents of Home directory 111 | File pluginHomeDirectory = new File(pluginContentsDirectory, runtimeHomeDirectory.getName()); 112 | 113 | DirectoryScanner directoryScanner = getDirectoryScanner(getProject()); 114 | String[] includedFiles = directoryScanner.getIncludedFiles(); 115 | 116 | for (int i = 0; i < includedFiles.length; i++) { 117 | String includedFile = includedFiles[i]; 118 | File source = new File(runtimeHomeDirectory, includedFile); 119 | File destination = new File(pluginHomeDirectory, includedFile); 120 | AppBundlerTask.copy(source, destination); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/BundleDocument.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, The Infinite Kind and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. The Infinite Kind designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by The Infinite Kind in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | */ 23 | 24 | package com.oracle.appbundler; 25 | 26 | import java.io.File; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import org.apache.tools.ant.BuildException; 31 | 32 | 33 | /** 34 | * Represent a CFBundleDocument. 35 | */ 36 | public class BundleDocument implements IconContainer { 37 | private String name = null; 38 | private String role = "Editor"; 39 | private String icon = null; 40 | private String handlerRank = null; 41 | private List extensions; 42 | private List contentTypes; 43 | private List exportableTypes; 44 | private boolean isPackage = false; 45 | 46 | private String capitalizeFirst(String string) { 47 | char[] stringArray = string.toCharArray(); 48 | stringArray[0] = Character.toUpperCase(stringArray[0]); 49 | return new String(stringArray); 50 | } 51 | 52 | public void setExtensions(String extensionsString) { 53 | extensions = getListFromCommaSeparatedString(extensionsString, "Extensions", true); 54 | } 55 | 56 | public void setContentTypes(String contentTypesString) { 57 | contentTypes = getListFromCommaSeparatedString(contentTypesString, "Content Types"); 58 | } 59 | 60 | public void setExportableTypes(String exportableTypesString) { 61 | exportableTypes = getListFromCommaSeparatedString(exportableTypesString, "Exportable Types"); 62 | } 63 | 64 | public static List getListFromCommaSeparatedString(String listAsString, 65 | final String attributeName) { 66 | return getListFromCommaSeparatedString(listAsString, attributeName, false); 67 | } 68 | 69 | public static List getListFromCommaSeparatedString(String listAsString, 70 | final String attributeName, final boolean lowercase) { 71 | if(listAsString == null) { 72 | throw new BuildException(attributeName + " can't be null"); 73 | } 74 | 75 | String[] splittedListAsString = listAsString.split(","); 76 | List stringList = new ArrayList(); 77 | 78 | for (String extension : splittedListAsString) { 79 | String cleanExtension = extension.trim(); 80 | if (lowercase) { 81 | cleanExtension = cleanExtension.toLowerCase(); 82 | } 83 | if (cleanExtension.length() > 0) { 84 | stringList.add(cleanExtension); 85 | } 86 | } 87 | 88 | if (stringList.size() == 0) { 89 | throw new BuildException(attributeName + " list must not be empty"); 90 | } 91 | return stringList; 92 | } 93 | 94 | public void setIcon(String icon) { 95 | this.icon = icon; 96 | } 97 | 98 | public void setName(String name) { 99 | this.name = name; 100 | } 101 | 102 | public void setRole(String role) { 103 | this.role = capitalizeFirst(role); 104 | } 105 | 106 | public void setHandlerRank(String handlerRank) { 107 | this.handlerRank = capitalizeFirst(handlerRank); 108 | } 109 | 110 | public void setIsPackage(String isPackageString) { 111 | if(isPackageString.trim().equalsIgnoreCase("true")) { 112 | this.isPackage = true; 113 | } else { 114 | this.isPackage = false; 115 | } 116 | } 117 | 118 | public String getIcon() { 119 | return icon; 120 | } 121 | 122 | public String getName() { 123 | return name; 124 | } 125 | 126 | public String getRole() { 127 | return role; 128 | } 129 | 130 | public String getHandlerRank() { 131 | return handlerRank; 132 | } 133 | 134 | public List getExtensions() { 135 | return extensions; 136 | } 137 | 138 | public List getContentTypes() { 139 | return contentTypes; 140 | } 141 | 142 | public List getExportableTypes() { 143 | return exportableTypes; 144 | } 145 | 146 | public File getIconFile() { 147 | if (icon == null) { return null; } 148 | 149 | File ifile = new File (icon); 150 | 151 | if (! ifile.exists ( ) || ifile.isDirectory ( )) { return null; } 152 | 153 | return ifile; 154 | } 155 | 156 | public boolean hasIcon() { 157 | return icon != null; 158 | } 159 | 160 | public boolean isPackage() { 161 | return isPackage; 162 | } 163 | 164 | @Override 165 | public String toString() { 166 | StringBuilder s = new StringBuilder(getName()); 167 | s.append(" ").append(getRole()) 168 | .append(" ").append(getIcon()) 169 | .append(" ").append(getHandlerRank()) 170 | .append(" "); 171 | if (contentTypes != null) { 172 | for(String contentType : contentTypes) { 173 | s.append(contentType).append(" "); 174 | } 175 | } 176 | if (extensions != null) { 177 | for(String extension : extensions) { 178 | s.append(extension).append(" "); 179 | } 180 | } 181 | if (exportableTypes != null) { 182 | for(String exportableType : exportableTypes) { 183 | s.append(exportableType).append(" "); 184 | } 185 | } 186 | 187 | return s.toString(); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | appbundler 2 | ============= 3 | 4 | A fork of the [Java Application Bundler](https://svn.java.net/svn/appbundler~svn) 5 | with the following changes: 6 | 7 | - The native binary is created as universal (32/64) 8 | - Fixes [icon not showing bug](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7159381) in `JavaAppLauncher` 9 | - Adds `LC_CTYPE` environment variable to the `Info.plist` file in order to fix an [issue with `File.exists()` in OpenJDK 7](http://java.net/jira/browse/MACOSX_PORT-165) **(Contributed by Steve Hannah)** 10 | - Allows to specify the name of the executable instead of using the default `"JavaAppLauncher"` **(contributed by Karl von Randow)** 11 | - Adds `classpathref` support to the `bundleapp` task 12 | - Adds support for `JVMArchs` and `LSArchitecturePriority` keys 13 | - Allows to specify a custom value for `CFBundleVersion` 14 | - Allows specifying registered file extensions using `CFBundleDocumentTypes` and `UT[Ex|Im]portedTypeDeclarations` 15 | - Passes to the Java application a set of system properties with the paths of 16 | the OSX special folders, whether the application is running in the 17 | sandbox (see below) and which modifier keys are held down while opening the app. With the latter, the Java application can mimic the behavior of e.g. iTunes or Photos to select another or create a new media library on startup with the option key. 18 | - Allows overriding of passed JVM options by the bundled app itself via java.util.Preferences **(contributed by Hendrik Schreiber)** 19 | - Allows writing arbitrary key-value pairs to `Info.plist` via `plistentry` 20 | - Allows setting of environment variables via `Info.plist` 21 | - Allows running the Application as `privileged` - e.g. for Setup **(Contributed by Gerry Weißbach)** 22 | - Allows specifying a JNLP file (`jnlplaunchername`) as alternative to the `mainclassname` which can then be launched without hassle when the Application is signed. See [How to sign (dynamic) JNLP files for OSX 10.8.4 and Gatekeeper](http://stackoverflow.com/questions/16958130/how-to-sign-dynamic-jnlp-files-for-osx-10-8-4-and-gatekeeper) **(Contributed by Gerry Weißbach)** 23 | 24 | These are the system properties passed to the JVM: 25 | 26 | - `LibraryDirectory` 27 | - `DocumentsDirectory` 28 | - `CachesDirectory` 29 | - `ApplicationSupportDirectory` 30 | - `ApplicationDirectory` 31 | - `AutosavedInformationDirectory` 32 | - `DesktopDirectory` 33 | - `DownloadsDirectory` 34 | - `MoviesDirectory` 35 | - `MusicDirectory` 36 | - `PicturesDirectory` 37 | - `SharedPublicDirectory` 38 | - `SystemLibraryDirectory` 39 | - `SystemApplicationSupportDirectory` 40 | - `SystemCachesDirectory` 41 | - `SystemApplicationDirectory` 42 | - `SystemUserDirectory` 43 | - `UserHome` (the user's home directory, even if running within a sandbox) 44 | - `SandboxEnabled` (the String `true` or `false`) 45 | - `LaunchModifierFlagCapsLock` (the String `true` or `false`) 46 | - `LaunchModifierFlagShift` (the String `true` or `false`) 47 | - `LaunchModifierFlagControl` (the String `true` or `false`) 48 | - `LaunchModifierFlagOption` (the String `true` or `false`) 49 | - `LaunchModifierFlagCommand` (the String `true` or `false`) 50 | - `LaunchModifierFlagNumericPad` (the String `true` or `false`) 51 | - `LaunchModifierFlagHelp` (the String `true` or `false`) 52 | - `LaunchModifierFlagFunction` (the String `true` or `false`) 53 | - `LaunchModifierFlags` (an Integer) 54 | 55 | 56 | For more details, please refer to the [task documentation](http://htmlpreview.github.io/?https://bitbucket.org/infinitekind/appbundler/raw/tip/appbundler/doc/appbundler.html). 57 | 58 | Example 1: 59 | 60 | 61 | 64 | 65 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 95 | 96 | 97 | 101 | 102 | 103 | 110 | 111 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 137 | 138 | 139 | Example 2, use installed Java but require Java 8 (or later): 140 | 141 | 142 | 145 | 159 | 160 | 161 | 162 | Example 2, use installed Java but require Java 8 (or later) JRE and not a JDK: 163 | 164 | 165 | 168 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /appbundler/doc/appbundler.html: -------------------------------------------------------------------------------- 1 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | AppBundler Task 33 | 34 | 35 | 36 |

AppBundler

37 |

Description

38 |

Generates a native launcher for a Java application.

39 | 40 |

Parameters

41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 68 | 69 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 81 | 82 | 83 | 84 | 85 | 88 | 89 | 90 | 91 | 92 | 94 | 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 148 | (Details) 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 172 | 173 | 174 | 175 | 176 | 179 | 180 | 181 | 182 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |
AttributeDescriptionRequired
outputdirectoryThe output folder for the generated bundle.Yes
nameThe name of the application. 55 | Corresponds to the CFBundleName key in the Info.plist file.Yes
displaynameThe display name of the application. 61 | Corresponds to the CFBundleDisplayName key in the Info.plist file.Yes
identifierAn identifier string that specifies the application type. 67 | Corresponds to the CFBundleIdentifier key in the Info.plist file.Yes
iconThe icon file for the application. 73 | Corresponds to the CFBundleIconFile key in the Info.plist file.No
hideDockIconSet to true to prevent display of the application icon on the Mac OS X dock. 79 | Corresponds to the LSUIElement key in the Info.plist file. 80 | (Details)No
shortversionThe release version number string for the application. 86 | Corresponds to the CFBundleShortVersionString key in the Info.plist 87 | file.No
signatureThe four-letter code identifying the application creator. 93 | Corresponds to the CFBundleSignature key in the Info.plist file.No
copyrightThe copyright notice for the application. 99 | Corresponds to the NSHumanReadableCopyright key in the Info.plist 100 | file.No
applicationCategoryThe application category. 106 | Corresponds to the LSApplicationCategoryType key in the Info.plist 107 | file.No
privilegedBool value if the bundled application is to be launched as privileged.No
mainclassnameThe name of the bundled application's main class.Yes, alternative to jnlplaunchernameYes
plistClassPathsA comma-separated list of classpath-elements which are used for the java application. 124 | $APP_ROOT is replaced by the path of the .app-bundle. Required only if not 125 | the libraries specified by the classpath and librarypath should be used.No
jvmRequiredSpecifies the required Java virtual machine version.No (defaults to 1.7)
jrePreferredIf set to true, a Java Runtime Edition is required for execution. If both jrePreferred and jdkPreferred are set true, then a JRE is preferred but a JDK ia also accepted.No
jdkPreferredIf set to true, a Java Development Kit is required for execution. If both jrePreferred and jdkPreferred are set true, then a JRE is preferred but a JDK ia also accepted.No
minimumSystemVersionIndicates the minimum version of OS X required for this app to run. 146 | Corresponds to the LSMinimumSystemVersion key in the Info.plist 147 | file.No
jnlplaunchernameThe name of the bundled applications's jnlp file. The file has to be be copied to the Contents/Java folder. It has to be present during execution of the application. This serves as option to deliver signed applications based upon JNLP files. The application can then be signed and the signature won't break when modifying the JNLP file.No, alternative to mainclassname
workingdirectorySpecifies the working directory of the application. 159 | $APP_ROOT is replaced by the path of the .app-bundle.No
privilegedIf set, the application is started with administrator privileges.No
highResolutionCapableSets the High Resolution Capable flag. 170 | Corresponds to the NSHighResolutionCapable key in the Info.plist 171 | file.No
supportsAutomaticGraphicsSwitchingAllow OpenGL applications to utilize the integrated GPU. 177 | Corresponds to the NSSupportsAutomaticGraphicsSwitching key in the Info.plist 178 | No
ignorePSNIf set to true, the -psn... arguments passed by the OS 183 | to the application is filtered out.No
isDebugIf set to true, additiona console output will be produced during startup.No
192 | 193 |

Parameters specified as nested elements

194 |

runtime

195 |

A fileset representing the Java 196 | runtime environment to embed in the application.

197 | 198 |

This element is optional. If specified, the base directory of the fileset must point to the 199 | root directory of a valid Java runtime environment. The contents of the runtime will be copied to 200 | the Contents/PlugIns/ folder of the generated application bundle.

201 | 202 |

By default, only the contents of the jre/ directory will be included with the bundled 203 | application. All executable content (i.e. bin/, jre/bin/) is excluded. Additional 204 | content can be included or excluded using nested <include> and 205 | <exclude> elements, respectively.

206 | 207 |

If this element is omitted, a Java runtime environment will not be copied into the generated 208 | bundle, and target systems must have a shared JRE installed in 209 | /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ in order to run the application.

210 | 211 |

classpath

212 |

A fileset representing the class 213 | path of the bundled application. Corresponds to the java.class.path system property. 214 | Entries will be copied to the Contents/Java/ folder of the generated bundle.

215 | 216 |

librarypath

217 |

A fileset representing the library 218 | path of the bundled application. Corresponds to the java.library.path system property. 219 | Entries will be copied to the Contents/MacOS/ folder of the generated bundle.

220 | 221 |

option

222 |

Specifies a command-line option to be passed to the JVM at startup.

223 |

Options may be named, which allows the bundled Java program 224 | itself to override the option (e.g. to adjust heap settings). Changes will take effect upon restart of the 225 | application. Assuming your CFBundleIdentifier (settable via the attribute identifier) 226 | is com.oracle.appbundler. Then you can override a named option by calling 227 |

import java.util.prefs.Preferences; 228 | [...] 229 | Preferences jvmOptions = Preferences.userRoot().node("/com/oracle/appbundler/JVMOptions"); 230 | jvmOptions.put("name", "value"); // use option name and desired value here 231 | jvmOptions.flush(); 232 | The corresponding entries will be stored in a file called 233 | ~/Library/Preferences/com.oracle.appbundler.plist. To manipulate the file 234 | without Java's Preferences from the command line, you should use the tool 235 | defaults. 236 | For example, to add an entry via the command line, use: 237 | defaults write com.oracle.appbundler /com/oracle/appbundler/ -dict-add JVMOptions/ '{"name"="value";}' 238 | Of named options, only the value is passed to the JVM, not the name. The name merely serves as identifier. 239 |

240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 |
AttributeDescriptionRequired
valueThe option value.Yes
nameThe option name.No
257 | 258 |

argument

259 |

Specifies a command-line argument to be passed to the bundled application at startup.

260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 |
AttributeDescriptionRequired
valueThe argument value.Yes
272 | 273 |

environment

274 |

Specifies an environment variable set via LSEnvironment entry in the Info.plist file. See the 275 | Apple Documentation for details.

276 |

The string $APP_ROOT will be replaced by the application bundle path in all environment variables on runtime.

277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 |
AttributeDescriptionRequired
nameThe variable name.Yes
valueThe variable value.Yes
294 | 295 |

architecture

296 |

Specifies the elements of the LSArchitecturePriority array in Info.plist. 297 | (Details)

298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 |
AttributeDescriptionRequired
nameThe architecture name.Yes
310 | 311 |

plistentry

312 |

Adds an arbitrary entry to the generated Info.plist.

313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 |
AttributeDescriptionRequired
keyThe entry's key.Yes
valueThe entry's value.Yes
typeThe entry's type.No (defaults to String)
335 | 336 | 337 |

scheme

338 |

Specifies a protocol for which the bundled application should be registered as a handler.

339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 |
AttributeDescriptionRequired
valueThe protocol scheme.Yes
351 | 352 |

bundledocument

353 |

Describes a document associated with your application.

354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 411 | 412 | 413 |
AttributeDescriptionCorresponding CFBundleDocumentTypes keyRequired
contentTypesA comma-separated list of Uniform Type Identifiers defining each a supported file type. 364 | If you reference custom filetypes, declare them using a typedeclaration. 365 | If set, extensions and isPackage are ignored. See the UTI reference for a list of default UTIs.LSItemContentTypesYes (or extensions)
extensionsA comma-separated list of filename extensions (minus the leading period) to map to this document type.CFBundleTypeExtensionsYes (or contentTypes)
iconThe name of the icon file (.icns) to associate with this OS X document type.CFBundleTypeIconFileNo (But recommended)
nameThe abstract name for the document type.CFBundleTypeNameNo (But recommended)
roleThis key specifies the app's role with respect to the type. The value can be Editor, Viewer, Shell, or None.CFBundleTypeRoleNo (default: Editor)
handlerRankDetermines how Launch Services ranks this app among the apps that declare themselves editors or viewers of files of this type. The possible values are: Owner (this app is the creator of files of this type), Alternate (this app is a secondary viewer of files of this type), None (this app must never be used to open files of this type, but it accepts drops of files of this type), Default (default; this app doesn't accept drops of files of this type). LSHandlerRankNo
isPackageSpecifies whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file.LSTypeIsPackageNo (default: false)
exportableTypesA comma-separated list of Uniform Type Identifiers defining a supported file type to which this document can export its content. 408 | If you reference custom filetypes, declare them using a typedeclaration. 409 | See also the Additional Document Type Considerations of the Document-Based App Programming Guide for Mac. 410 | NSExportableTypesNo
414 | 415 |

typedeclaration

416 |

Declares a new Uniform Type Identifier. 417 | Required if you reference non-system UTIs in bundledocument's contentTypes or exportableTypes

. 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 472 | 473 | 474 | 475 | 476 | 477 | 480 | 481 | 482 | 483 |
AttributeDescriptionCorresponding UT...TypeDeclarations keyRequired
identifierThe unique UTI for the declared type. Following the reverse-DNS format beginning with com.companyName is a simple way to ensure uniqueness.UTTypeIdentifierYes
descriptionA user-visible description of this type.UTTypeDescriptionNo
iconThe name of the icon file (.icns) to associate with this UTI.UTTypeIconFileNo
referenceUrlThe URL of a reference document describing this type.UTTypeReferenceURLNo
conformsToA comma-separated list of UTIs to which this identifier conforms. 452 | Although a custom UTI can conform to any UTI, public.data or com.apple.package must be at the root of the conformance hierarchy.UTTypeConformsToNo (defaults to public.data)
extensionsA comma-separated list of filename extensions (minus the leading period) to map to this UTI.UTTypeTagSpecification -> public.filename-extensionNo (but recommended)
mimeTypesA comma-separated list of mime types which identify this UTI.UTTypeTagSpecification -> public.mime-typeNo
osTypesComma-separated list of four-character codes formerly used to identify types. 471 | Only specify OSTypes if you really know what you're doing.UTTypeTagSpecification -> com.apple.ostypeNo
importedIf set to true, the declaration is listed under the UTImportedTypeDeclarations key. 478 | Otherwise, it is listed under UTExportedTypeDeclarations. 479 | If your code relies on third-party UTI types that may not be present on the system, you should declare those UTIs as imported types.-No
484 | 485 |

Examples

486 |

Generate a launcher for the "Swing Set" demo, bundling the JRE defined by the JAVA_HOME 487 | environment variable with the resulting executable.

488 |
489 | <-- Import environment variables -->
490 | <property environment="env"/>
491 | 
492 | <-- Define the appbundler task -->
493 | <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask"/>
494 | 
495 | <-- Create the app bundle -->
496 | <target name="bundle-swingset" depends="package">
497 |     <bundleapp outputdirectory="."
498 |         name="SwingSet2"
499 |         displayname="SwingSet 2"
500 |         identifier="com.oracle.javax.swing.SwingSet2"
501 |         shortversion="1.0"
502 |         applicationCategory="public.app-category.developer-tools"
503 |         mainclassname="SwingSet2">
504 |         <runtime dir="${env.JAVA_HOME}"/>
505 |         <classpath file="/Library/Java/Demos/JFC/SwingSet2/SwingSet2.jar"/>
506 |         <option value="-Dapple.laf.useScreenMenuBar=true"/>
507 |         <scheme value="mailto"/>
508 |     </bundleapp>
509 | </target>
510 | 
511 | 512 |

Example 2: JNLP Launcher

513 |

Generate a launcher for a JNLP File, copy it into the package and sign the package. You need to have a Developer ID Profile to sign the application.

514 |

You can now dynamically modify the zip content (only the JNLP file), deliver it with your web service and the application should directly unpack and can be run

515 |
516 | <-- Define the appbundler task -->
517 | <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask"/>
518 | 
519 | <-- Create the app bundle -->
520 | <target name="bundle-swingset" depends="package">
521 | 
522 |     <mkdir dir="./app">
523 | 
524 |     <bundleapp outputdirectory="./app"
525 |         name="SwingSet2"
526 |         displayname="SwingSet 2"
527 |         identifier="com.oracle.javax.swing.SwingSet2"
528 |         shortversion="1.0"
529 |         icon="icon.icns"
530 |         applicationCategory="public.app-category.developer-tools"
531 |         jnlplaunchername="Contents/_CodeSignature/SwingSet2.jnlp">
532 |         
533 |         <value="-Xdock:icon=Contents/Resources/icon.icns" />
534 |         <option value="-Dapple.laf.useScreenMenuBar=true"/>
535 |     </bundleapp>
536 | 
537 |     <!-- Optionally copy an original file -->
538 |     <copy todir="./SwingSet2.app/Contents/_CodeSignature" includeemptydirs="true" overwrite="false">
539 |         <fileset dir=".">
540 |             <include name="**/*.jnlp" />
541 |         </fileset>
542 |     </copy>
543 | 	
544 |     <!-- Sign File -->
545 |     <exec executable="codesign" os="Mac OS X" failonerror="true">
546 |         <arg value="-f" />
547 |         <arg value="--deep" />
548 |         <arg value="-s" />
549 |         <arg value="Developer ID Application" />
550 |         <arg value="./app/SwingSet2.app" />
551 |     </exec>
552 | 
553 |     <zip destfile="./SwingSet2.app.zip" basedir="${copyroot}/app"></zip>
554 | </target>
555 | 
556 |
557 | 
558 | 
559 | 560 | -------------------------------------------------------------------------------- /appbundler/src/com/oracle/appbundler/AppBundlerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012, Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | * 6 | * This code is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License version 2 only, as 8 | * published by the Free Software Foundation. Oracle designates this 9 | * particular file as subject to the "Classpath" exception as provided 10 | * by Oracle in the LICENSE file that accompanied this code. 11 | * 12 | * This code is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | * version 2 for more details (a copy is included in the LICENSE file that 16 | * accompanied this code). 17 | * 18 | * You should have received a copy of the GNU General Public License version 19 | * 2 along with this work; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 | * 22 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 | * or visit www.oracle.com if you need additional information or have any 24 | * questions. 25 | */ 26 | 27 | package com.oracle.appbundler; 28 | 29 | import java.io.BufferedOutputStream; 30 | import java.io.BufferedWriter; 31 | import java.io.File; 32 | import java.io.FileOutputStream; 33 | import java.io.FileWriter; 34 | import java.io.IOException; 35 | import java.io.InputStream; 36 | import java.io.OutputStream; 37 | import java.io.Writer; 38 | import java.net.URL; 39 | import java.nio.file.Files; 40 | import java.nio.file.LinkOption; 41 | import java.nio.file.Path; 42 | import java.nio.file.StandardCopyOption; 43 | import java.util.ArrayList; 44 | import java.util.Iterator; 45 | import java.util.List; 46 | import java.util.zip.ZipEntry; 47 | import java.util.zip.ZipInputStream; 48 | 49 | import javax.xml.stream.XMLOutputFactory; 50 | import javax.xml.stream.XMLStreamException; 51 | import javax.xml.stream.XMLStreamWriter; 52 | 53 | import org.apache.tools.ant.BuildException; 54 | import org.apache.tools.ant.DirectoryScanner; 55 | import org.apache.tools.ant.Task; 56 | import org.apache.tools.ant.types.FileSet; 57 | import org.apache.tools.ant.types.Reference; 58 | import org.apache.tools.ant.types.resources.FileResource; 59 | 60 | /** 61 | * App bundler Ant task. 62 | */ 63 | public class AppBundlerTask extends Task { 64 | // Output folder for generated bundle 65 | private File outputDirectory = null; 66 | 67 | // General bundle properties 68 | private String name = null; 69 | private String displayName = null; 70 | private String identifier = null; 71 | private File icon = null; 72 | private String executableName = EXECUTABLE_NAME; 73 | 74 | private String shortVersion = "1.0"; 75 | private String version = "1.0"; 76 | private String signature = "????"; 77 | private String copyright = ""; 78 | private String privileged = null; 79 | private String workingDirectory = null; 80 | private String minimumSystemVersion = null; 81 | 82 | private String jvmRequired = null; 83 | private boolean jrePreferred = false; 84 | private boolean jdkPreferred = false; 85 | 86 | private String applicationCategory = null; 87 | 88 | private boolean highResolutionCapable = true; 89 | private boolean supportsAutomaticGraphicsSwitching = true; 90 | private boolean hideDockIcon = false; 91 | private boolean isDebug = false; 92 | private boolean ignorePSN = false; 93 | 94 | // JVM info properties 95 | private String mainClassName = null; 96 | private String jnlpLauncherName = null; 97 | private String jarLauncherName = null; 98 | private Runtime runtime = null; 99 | private ArrayList classPath = new ArrayList<>(); 100 | private ArrayList libraryPath = new ArrayList<>(); 101 | private ArrayList