static {
DIR_PLATFORMS_VER = "tizen" + DIR_PLATFORMS_VER_NUM;
- loadSdkPath();
+ try {
+ loadSdkPath();
+ } catch (Exception e) {
+ String msg = "Failed to load sdk path";
+ logger.error("Failed to load sdk path", e);
+ System.err.println(msg + ": " + e.getMessage());
+ }
}
/**
ProfileInfo latestProfileInfo = getLatestProfileInfo();
return latestProfileInfo == null ? "" : latestProfileInfo.getLatestPlatformName();
}
-
+
/**
* Returns platforms directory or null.
*/
public static String getSnippetsPath() {
return getPlatformVersionPath() + File.separator + DIR_SNIPPETS;
}
-
+
/**
* Returns a snippets path that is installed under the given profile and version.<br>
* If this method cannot find the sample path, returns null.
public static String getOnDemandPath() {
return getPlatformVersionPath() + File.separator + DIR_ON_DEMAND;
}
-
+
/**
* Returns a on-demand path that is installed under the given profile and version.<br>
* If this method cannot find the sample path, returns null.
prop.load(is);
sdkInstallPath = prop.getProperty(SDK_INFO_FILE_KEY_INSTALLED_PATH);
sdkDataPath = prop.getProperty(SDK_INFO_FILE_KEY_DATA_PATH);
- logger.info(String.format("Loaded (install_path - %s, data_path - %s)", sdkInstallPath, sdkDataPath));
+ logger.info(String.format("Loaded (install_path - %s, data_path - %s, sdk.info - %s)", sdkInstallPath, sdkDataPath, sdkInfoFile));
} finally {
IOUtil.tryClose(is);
}
}
- private static void loadSdkPath() {
+ private static void lookupSdkInfoFile(String path) {
+ String sdkPath = new File(path).getParent();
+ while (sdkPath != null) {
+ try {
+ parseSdkInfoFile(sdkPath);
+ break;
+ } catch (FileNotFoundException e) {
+ // to find sdk.info up-through
+ logger.error("Failed to find: " + e.getMessage());
+ sdkPath = new File(sdkPath).getParent();
+ } catch (Exception e) {
+ logger.error("Failed to load from " + sdkPath, e);
+ }
+ }
+ }
+
+ private static void loadSdkPath() throws Exception {
try {
String eclipsePath = org.eclipse.core.runtime.Platform.getInstallLocation().getURL().getPath();
- String sdkPath = new File(eclipsePath).getParent();
// to load from <eclipse>/../sdk.info
- parseSdkInfoFile(sdkPath);
+ // if failed, to find sdk.info up-through
+ lookupSdkInfoFile(eclipsePath);
} catch (NoClassDefFoundError ncdfe) {
// in case of CLI, java.lang.NoClassDefFoundError: org/eclipse/core/runtime/Platform
String path = InstallPathConfig.class.getProtectionDomain().getCodeSource().getLocation().getPath();
- String sdkPath = new File(path).getParent();
- while (sdkPath != null) {
- try {
- parseSdkInfoFile(sdkPath);
- break;
- } catch (FileNotFoundException e) {
- // to find sdk.info up-through
- sdkPath = new File(sdkPath).getParent();
- } catch (Exception e) {
- logger.error("Failed to load from " + sdkPath, e);
- }
- }
+ lookupSdkInfoFile(path);
} catch (Throwable t) {
logger.error("Failed to load from " + SDK_INFO_FILE, t);
} finally {
}
}
- private static void loadSdkPathFromDefault() {
+ private static void loadSdkPathFromDefault() throws Exception {
// FIXME : don't need the following lines if using environment variable
if (OSChecker.isWindows()) {
defaultHomePath = getRegistryValue(REGISTRY_PATH_OF_SHELL_FOLDER, REGISTRY_LOCAL_APP_DATA_OF_SHELL_FOLDER) ;
} else if (OSChecker.isLinux() == true || OSChecker.isUnix() == true || OSChecker.isMAC() == true) {
defaultHomePath = System.getProperty("user.home");
} else {
- DialogUtil.openMessageDialog(System.getProperty("os.name") + " is not supported currently.");
- System.exit(0);
+ throw new Exception(System.getProperty("os.name") + " is not supported currently.");
}
String sdkPath = defaultHomePath + File.separatorChar + SDKSUFFIX;
}
if (!status) {
- DialogUtil.openMessageDialog("Tizen SDK is not installed properly.");
- System.exit(0);
+ try {
+ DialogUtil.openMessageDialog("Tizen SDK is not installed properly.");
+ } catch (Exception e) {
+ logger.error("Failed to open a dialog", e);
+ }
+ throw new Exception("Tizen SDK is not installed properly.");
}
}