[Title] Check binary existing in CLI multi packaging
authorho.namkoong <ho.namkoong@samsung.com>
Wed, 20 Mar 2013 09:50:02 +0000 (18:50 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Wed, 20 Mar 2013 12:15:03 +0000 (21:15 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#] 8795
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I10c5f1e5aeb8821e17786fe7d92be6f2fa4a011f

org.tizen.cli/src/org/tizen/cli/exec/pack/CLIMultiPackager.java

index c1cbe81..6c155a4 100644 (file)
 package org.tizen.cli.exec.pack;
 
 import java.io.File;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.core.command.CommandCancelException;
 import org.tizen.common.core.command.Executor;
+import org.tizen.common.util.FileUtil;
 import org.tizen.nativecommon.IXMLStore;
 import org.tizen.nativecommon.build.AbstractMultiPackager;
 import org.tizen.nativecpp.misc.core.NewAppXmlStore;
@@ -40,6 +43,7 @@ public class CLIMultiPackager extends AbstractMultiPackager{
     private static final String BIN_FOLDER_NAME = "CommandLineBuild";
     private String rootPrjPath;
     private String[] refPrjPath;
+    private Logger logger = LoggerFactory.getLogger(CLIMultiPackager.class);
     
     
     CLIMultiPackager(String rootPrjPath, String[] refPrjPath, Executor executor) {
@@ -71,11 +75,27 @@ public class CLIMultiPackager extends AbstractMultiPackager{
     @Override
     protected boolean validateMultiPackage() {
         File manifestFile = new File(rootPrjPath, ManifestXmlFile.MANIFEST_XML_FILE_NAME);
-        if(manifestFile.exists() || (refPrjPath != null && refPrjPath.length > 0)) {
-            return true;
+        if(!manifestFile.exists() || refPrjPath == null || refPrjPath.length < 1) {
+            return false;
+        }
+        
+        for(String refPath: refPrjPath) {
+            String refPrjBinaryFolder = FileUtil.appendPath(refPath, getBinaryFolder());
+            
+            if(refPath.endsWith("/") || refPath.endsWith("\\")) {
+                refPath = refPath.substring(0, refPath.length() - 1);
+            }
+            
+            String refBinaryName = FileUtil.getFileNameFromPath(refPath) + EXT_BINARY_EXECUTABLE;
+            String refBinaryPath = FileUtil.appendPath(refPrjBinaryFolder, refBinaryName);
+            
+            if(!new File(refBinaryPath).exists()) {
+                logger.error(String.format("Binary of %s does not exist.", refPath));
+                throw new CommandCancelException();
+            }
         }
         
-        return false;
+        return true;
     }
 
     @Override