Search in sources :

Example 1 with Plist

use of com.jetbrains.cidr.xcode.plist.Plist in project intellij-plugins by JetBrains.

the class Reveal method getRevealVersion.

@Nullable
public static Version getRevealVersion(@NotNull File bundle) {
    Plist plist = PlistDriver.readAnyFormatSafe(new File(bundle, "Contents/Info.plist"));
    if (plist == null)
        return null;
    String version = plist.getString("CFBundleVersion");
    if (version == null)
        return null;
    List<String> parts = StringUtil.split(version, ".");
    if (parts.isEmpty())
        return null;
    return new Version(StringUtil.parseInt(parts.get(0), 0), parts.size() > 1 ? StringUtil.parseInt(parts.get(1), 0) : 0, parts.size() > 2 ? StringUtil.parseInt(parts.get(2), 0) : 0);
}
Also used : Plist(com.jetbrains.cidr.xcode.plist.Plist) Version(com.intellij.openapi.util.Version) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Plist

use of com.jetbrains.cidr.xcode.plist.Plist in project intellij-plugins by JetBrains.

the class RevealRunConfigurationExtension method getBundleID.

@NotNull
private static String getBundleID(@NotNull ExecutionEnvironment environment, @NotNull File product) throws ExecutionException {
    String result = environment.getUserData(BUNDLE_ID_KEY);
    if (result != null)
        return result;
    File plistFile = new File(product, "Info.plist");
    Plist plist = PlistDriver.readAnyFormatSafe(plistFile);
    if (plist == null)
        throw new ExecutionException("Info.plist not found at " + plistFile);
    result = plist.getString("CFBundleIdentifier");
    if (result == null)
        throw new ExecutionException("CFBundleIdentifier not found in " + plistFile);
    environment.putUserData(BUNDLE_ID_KEY, result);
    return result;
}
Also used : Plist(com.jetbrains.cidr.xcode.plist.Plist) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Plist (com.jetbrains.cidr.xcode.plist.Plist)2 File (java.io.File)2 ExecutionException (com.intellij.execution.ExecutionException)1 Version (com.intellij.openapi.util.Version)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1