package version up (2.1.42), Supports multi-sdk for CLI
authorkh5325.kim <kh5325.kim@samsung.com>
Sat, 8 Jun 2013 08:54:37 +0000 (17:54 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Sat, 8 Jun 2013 08:54:37 +0000 (17:54 +0900)
org.tizen.common/src/org/tizen/common/core/application/InstallPathConfig.java
package/changelog
package/pkginfo.manifest

index ae18cf8..645f1b0 100755 (executable)
@@ -29,6 +29,7 @@ import static org.tizen.common.util.IOUtil.tryClose;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -197,30 +198,55 @@ final public class InstallPathConfig {
         return getSDKPath()  + File.separator + DIR_DOCUMENTS;
     }
 
-    private static void loadSdkPath() {
+    private static void parseSdkInfoFile(String sdkPath) throws Exception {
+        // TODO: fix for //sdk.info
+        String sdkInfoFile = sdkPath + File.separator + SDK_INFO_FILE;
+        logger.info(String.format("Loading from %s...", sdkInfoFile));
+        if (!new File(sdkInfoFile).exists()) {
+            throw new FileNotFoundException("There is no file " + sdkInfoFile);
+        }
+
         InputStream is = null;
         try {
-            String eclipsePath = org.eclipse.core.runtime.Platform.getInstallLocation().getURL().getPath();
-            String sdkPath = new File(eclipsePath).getParent();
-            String sdkInfoFile = sdkPath + File.separator + SDK_INFO_FILE;
-            // to load from <eclipse>/../sdk.info
-            logger.info(String.format("Loading from %s...", sdkInfoFile));
-            if (!new File(sdkInfoFile).exists()) {
-                throw new Exception("There is no file " + sdkInfoFile);
-            }
-
             Properties prop = new Properties();
             is = StringUtil.toInputStream(HostUtil.getContents(sdkInfoFile));
             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));
+        } finally {
+            IOUtil.tryClose(is);
+        }
+    }
+
+    private static void loadSdkPath() {
+        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);
+        } 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);
+                }
+            }
         } catch (Throwable t) {
             logger.error("Failed to load from " + SDK_INFO_FILE, t);
-            // fallback to load from ~/tizen-sdk-data/tizensdkpath
-            loadSdkPathFromDefault();
         } finally {
-            IOUtil.tryClose(is);
+            if (sdkInstallPath == null || sdkDataPath == null) {
+                // fallback to load from ~/tizen-sdk-data/tizensdkpath
+                loadSdkPathFromDefault();
+            }
         }
     }
 
index 03bf50a..2ddd3c1 100644 (file)
@@ -1,3 +1,6 @@
+* 2.1.42
+- Supports multi-sdk for CLI
+== kh5325.kim <kh5325.kim@samsung.com> 2013-06-08
 * 2.1.41
 - Supports multi-sdk
 == kh5325.kim <kh5325.kim@samsung.com> 2013-06-08
index 6e803ea..95164fc 100644 (file)
@@ -1,4 +1,4 @@
-Version:2.1.41
+Version:2.1.42
 Source:common-eplugin
 Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song <jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>, bonyong lee <bonyong.lee@samsung.com>, shingil kang <shingil.kang@samsung.com>