org.openbakery.bundle.ApplicationBundle.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xcode-plugin Show documentation
Show all versions of xcode-plugin Show documentation
XCode-Plugin is a plugin to allow custom XCode projects to build as generated by CMake
The newest version!
package org.openbakery.bundle
import org.openbakery.xcode.Type
public class ApplicationBundle {
File applicationPath
Type type
boolean simulator
public ApplicationBundle(File applicationPath, Type type, boolean simulator) {
this.applicationPath = applicationPath
this.type = type
this.simulator = simulator
}
List getBundles() {
ArrayList bundles = new ArrayList();
addPluginsToAppBundle(applicationPath, bundles)
if (isDeviceBuildOf(Type.iOS)) {
addWatchToAppBundle(applicationPath, bundles)
}
bundles.add(applicationPath)
return bundles;
}
private void addPluginsToAppBundle(File appBundle, ArrayList bundles) {
File plugins
if (isDeviceBuildOf(Type.iOS)) {
plugins = new File(appBundle, "PlugIns")
} else if (this.type == Type.macOS) {
plugins = new File(appBundle, "Contents/PlugIns")
} else {
return
}
if (plugins.exists()) {
for (File pluginBundle : plugins.listFiles()) {
if (pluginBundle.isDirectory()) {
if (pluginBundle.name.endsWith(".framework")) {
// Frameworks have to be signed with this path
bundles.add(new File(pluginBundle, "/Versions/Current"))
} else if (pluginBundle.name.endsWith(".appex")) {
for (File appexBundle : pluginBundle.listFiles()) {
if (appexBundle.isDirectory() && appexBundle.name.endsWith(".app")) {
bundles.add(appexBundle)
}
}
bundles.add(pluginBundle)
} else if (pluginBundle.name.endsWith(".app")) {
bundles.add(pluginBundle)
}
}
}
}
}
private void addWatchToAppBundle(File appBundle, ArrayList bundles) {
File watchDirectory
watchDirectory = new File(appBundle, "Watch")
if (watchDirectory.exists()) {
for (File bundle : watchDirectory.listFiles()) {
if (bundle.isDirectory()) {
if (bundle.name.endsWith(".app")) {
addPluginsToAppBundle(bundle, bundles)
bundles.add(bundle)
}
}
}
}
}
boolean isDeviceBuildOf(Type expectedType) {
if (type != expectedType) {
return false;
}
return !this.simulator
}
}