CLI: add progresslog, log, message 60/13560/2
authorshingil.kang <shingil.kang@samsung.com>
Mon, 9 Dec 2013 12:37:57 +0000 (21:37 +0900)
committershingil.kang <shingil.kang@samsung.com>
Mon, 9 Dec 2013 13:33:05 +0000 (22:33 +0900)
use progresslog to show path of the created project.
use log, message to process exception.

Change-Id: Ie9e07b22843b436ad7389e6ae5655e2f558e712e
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateNativeProjectCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateWebProjectCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateNativeProjectCommand.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateWebProjectCommand.java

index ad6b7af..6879a36 100644 (file)
@@ -18,6 +18,10 @@ public class TizenCLIMessages extends NLS {
     public static String MANY_CONNECTED_TARGETS;
     
     public static String FAIL_TARGET;
+    
+    //CR(Create project)
+    public static String CR_CANNOT_CREATE_OUTDIR;
+    public static String CR_CANNOT_COPY_PROJECT;
 
     //BN(Build-Native)
     public static String BN_CANNOT_CREATE_BUILD_TARGET;
index 14a26a7..7f53fc2 100644 (file)
@@ -10,6 +10,9 @@ MANY_CONNECTED_TARGETS = There are many connected targets.
 
 FAIL_TARGET = [Fail]Can not get target .
 
+CR_CANNOT_FIND_OUTDIR = Can not create output directory.
+CR_CANNOT_COPY_PROJECT = Can not copy project file.
+
 BN_CANNOT_CREATE_BUILD_TARGET = Can not create the build target.
 BN_CANNOT_FIND_CPROJECT = Can not find the .cproject file in {0}.
 BN_CANNOT_GET_ARTIFACT_TYPE = Can not get the artifact type.
index 68eac4f..4c6f65b 100644 (file)
@@ -7,12 +7,12 @@ import org.kohsuke.args4j.Option;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 //import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+import org.tizen.ncli.ide.messages.TizenCLIMessages;
 import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommandData;
 
 public class CreateNativeProjectCLI extends AbstractCLI
 {
-    private Logger logger = LoggerFactory.getLogger(getClass());
-
     @Option(name = "-t", aliases = { "--type" }, usage = "Specify template name")
     private String templateName;
 
@@ -42,12 +42,13 @@ public class CreateNativeProjectCLI extends AbstractCLI
             nativeCommand.setOutputName(outputDirectory.getCanonicalPath() + File.separatorChar + nativeCommand.getProjectName());
         } catch (IOException e)
         {
-            logger.error(e.getMessage());
+            log.error(TizenCLIMessages.CR_CANNOT_CREATE_OUTDIR);
         }
 
-        nativeCommand.runCommand();
+        CreateNativeProjectCommandData data = nativeCommand.runCommand();
         
-        System.out.println("Creating native project succeeded!");
+        progressLog.info("Project Location : {}",data.getOutputName());
+        progressLog.info("Creating native project succeeded!");
     }
 
 }
index b0706ee..e05b755 100644 (file)
@@ -29,19 +29,15 @@ import java.io.File;
 import java.io.IOException;
 
 import org.kohsuke.args4j.Option;
-import org.kohsuke.args4j.spi.StringOptionHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-//import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+import org.tizen.ncli.ide.messages.TizenCLIMessages;
+import org.tizen.ncli.ide.subcommands.CreateProjectCommandData;
 import org.tizen.ncli.ide.subcommands.CreateWebProjectCommand;
 
 /**
- * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-core)
  */
 public class CreateWebProjectCLI extends AbstractCLI
 {
-    private Logger logger = LoggerFactory.getLogger(getClass());
-
     @Option(name = "-t", aliases = { "--type" }, usage = "Specify template name")
     private String templateName;
 
@@ -56,7 +52,7 @@ public class CreateWebProjectCLI extends AbstractCLI
     @Override
     public void execute()
     {
-        logger.info("Template Name:{}", templateName);
+        log.info("Template Name:{}", templateName);
 
         CreateWebProjectCommand webCommand = new CreateWebProjectCommand();
 
@@ -78,11 +74,12 @@ public class CreateWebProjectCLI extends AbstractCLI
             webCommand.setOutputName(outputDirectory.getCanonicalPath() + File.separatorChar + webCommand.getProjectName());
         } catch (IOException e)
         {
-            logger.error(e.getMessage());
+            log.error(TizenCLIMessages.CR_CANNOT_CREATE_OUTDIR);
         }
 
-        webCommand.runCommand();
+        CreateProjectCommandData data = webCommand.runCommand();
         
-        System.out.println("Creating web project succeeded!");
+        progressLog.info("project Location : {}",data.getOutputName());
+        progressLog.info("Creating web project succeeded!");
     }
 }
index 47e6744..d6f4c41 100644 (file)
@@ -1,3 +1,28 @@
+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Shingil Kang <shingil.kang@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
 package org.tizen.ncli.ide.subcommands;
 
 import java.io.File;
@@ -20,7 +45,7 @@ import org.tizen.nativecommon.templateengine.util.TemplateUtil;
 import org.tizen.nativecpp.wizards.TemplateTizenCppNewWizard;
 import org.tizen.nativecpp.wizards.build.ExpressProjectGenerator;
 
-public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProjectCommandData>
+public class CreateNativeProjectCommand extends AbstractSubCommand<CreateNativeProjectCommandData>
 {
     private CreateNativeProjectCommandData data = new CreateNativeProjectCommandData();
 
@@ -62,7 +87,7 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
      */
 
     @Override
-    protected CreateProjectCommandData call()
+    protected CreateNativeProjectCommandData call()
     {
         progressLog.info("-----------------------------------------------------");
         progressLog.info("Starting Tizen project creation:");
@@ -74,7 +99,7 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
         // copy native project template and generate .cproject and .project file
         copyNativeProjectTemplate();
 
-        return null;
+        return data;
     }
 
     public void copyNativeProjectTemplate()
@@ -92,7 +117,7 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
             TizenTemplateEngine.createProject(template, new WebCLIProjectGenerator());
         } catch (TizenProcessFailureException e)
         {
-            log.error("Template is not created", e.getMessage());
+            log.error("Template is not created\n{}", e.getMessage());
         }
     }
 
@@ -176,7 +201,7 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
                 }
             } catch (IOException e)
             {
-                log.error("not crate build file", e.getMessage());
+                log.error("not crate build file\n{}", e.getMessage());
             }
             new File(tempDescriptionPath).delete();
         }
@@ -184,6 +209,11 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
         public void setBuildConfigMap(String projectType)
         {
             String tempPath = pg.extractBuiltinJarFiles("templates" + File.separator + "Executables");
+            if(tempPath == null){
+                log.error("No jar folder!");
+                return;
+            }
+                
             tempPath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
             cProjectTemplatePath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
 
@@ -222,6 +252,7 @@ public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProject
                 }
             } catch (Exception e)
             {
+                log.error("Error occurred during reading app/shared/static teamplate!\n{}",e.getMessage());
             }
         }
 
index 9567338..11905f6 100644 (file)
@@ -25,7 +25,6 @@
  */
 package org.tizen.ncli.ide.subcommands;
 
-import static org.tizen.web.common.WebConstant.ATTR_WIDGET_URI;
 import static org.tizen.web.common.WebConstant.WIDGET_BASE_IDENTIFIER;
 
 import java.io.File;
@@ -51,53 +50,32 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 
-import org.kohsuke.args4j.Option;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.tizen.common.Factory;
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.common.core.application.ProfileInfo;
-import org.tizen.common.core.application.TizenProjectDescription;
 import org.tizen.common.core.application.tproject.ObjectFactory;
 import org.tizen.common.core.application.tproject.Platform;
 import org.tizen.common.core.application.tproject.Platforms;
 import org.tizen.common.core.application.tproject.Tproject;
-import org.tizen.common.core.command.ExecutionContext;
-import org.tizen.common.core.command.Prompter;
-import org.tizen.common.core.command.policy.PolicyRegistry;
-import org.tizen.common.file.FileHandler;
-import org.tizen.common.file.StandardFileHandler;
-import org.tizen.common.util.EFSUtil;
 import org.tizen.common.util.FileUtil;
 import org.tizen.common.util.FreeMarkerUtil;
 import org.tizen.common.util.IOUtil;
-import org.tizen.common.util.ObjectUtil;
-import org.tizen.common.util.PluginUtil;
-import org.tizen.common.util.ProjectUtil;
-import org.tizen.ncli.ide.config.ConfigConstant;
-import org.tizen.ncli.ide.shell.TizenAppType;
+import org.tizen.ncli.ide.messages.TizenCLIMessages;
 import org.tizen.web.apptemplate.model.LibraryElement;
 import org.tizen.web.apptemplate.model.OptionElement;
 import org.tizen.web.apptemplate.model.OptionGroup;
 import org.tizen.web.apptemplate.model.Options;
 import org.tizen.web.apptemplate.model.SupportLibraries;
-import org.tizen.web.apptemplate.model.SupportLibrary;
 import org.tizen.web.apptemplate.model.TizenTemplateKindsOfLibraries;
 import org.tizen.web.common.WebConstant;
-import org.tizen.web.config.schema.model.Widget;
 import org.tizen.web.model.TizenAppTemplate;
 import org.tizen.web.model.TizenModelFactory;
 import org.tizen.web.project.configuration.ConfigurationException;
-import org.tizen.web.project.configuration.ConfiguratorFactory;
 import org.tizen.web.project.configuration.ITizenConfigurator;
-import org.tizen.web.project.configuration.TizenConfiguratorImpl;
 import org.tizen.web.project.wizard.model.TizenTemplateLibrariesPool;
 import org.tizen.web.project.wizard.model.TizenTemplateLibraryGroup;
-import org.tizen.web.project.wizard.operation.LibraryCopyOperation;
-import org.tizen.web.project.wizard.operation.OptionProcessOperation;
-import org.tizen.web.project.wizard.operation.TemplateCopyOperation;
 import org.tizen.web.project.wizard.operation.LibraryCopyOperation.TizenWebUIFWType;
-import org.tizen.web.project.wizard.ui.commandbar.WebProjectCreator;
 
 import freemarker.template.Configuration;
 
@@ -200,8 +178,7 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
             FileUtil.copyRecursively(projectPath, destDir, true, resourceFilter);
         } catch (IOException e)
         {
-            // TODO Auto-generated catch block
-            log.error(e.getMessage());
+            log.error(TizenCLIMessages.CR_CANNOT_COPY_PROJECT);
         }
     }
 
@@ -215,15 +192,15 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
         {
             // unmarshal app template.
             tizenAppTemplate = TizenModelFactory.unmarshalAppTemplate(configFile);
-        } catch (FileNotFoundException e2)
+        } catch (FileNotFoundException e)
         {
-            // TODO Auto-generated catch block
-            log.error(e2.getMessage());
+            log.error("not found template file\n{}", e.getMessage());
         }
 
         // get options
         Options options = tizenAppTemplate.getOptions();
         if(options == null){
+            log.error("not get options");
             return;
         }
 
@@ -247,10 +224,6 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
             // copy libraries
             for (TizenTemplateLibraryGroup group : groupList)
             {
-                /*
-                 * if ( isSampleGroup( template ) ) {
-                 * group.setSelectedMinifiedWithDependsUpdate( true ); }
-                 */
                 if (group.getSelectedElement().getKindsOfLibrary() == TizenTemplateKindsOfLibraries.TIZENWEBUIFW)
                 {
                     copyTizenWebUIFWLibrary(group);
@@ -275,9 +248,7 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
         File source = new File(libraryPath);
         if (!source.exists())
         {
-            String errorMsg = "Cannot find template library resource : " + libraryPath; // TODO
-                                                                                        // :
-                                                                                        // externalize
+            log.error("Cannot find template library resource : {}", libraryPath);
         }
 
         // create target directory
@@ -342,7 +313,7 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
         File source = new File(libraryPath);
         if (!source.exists() || !source.isDirectory())
         {
-            String errorMsg = "Cannot find template library resource directory : " + libraryPath;
+            log.error("Cannot find template library resource folder: {}", libraryPath);
         }
 
         // decide target directory
@@ -368,8 +339,7 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
             FileUtil.copyRecursively(libraryPath, destDir, true);
         } catch (IOException e)
         {
-            // TODO Auto-generated catch block
-            log.error(e.getMessage());
+            log.error(TizenCLIMessages.CR_CANNOT_COPY_PROJECT);
         }
 
     }
@@ -551,10 +521,10 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
             FreeMarkerUtil.generateDocument(root, cfg, templateFile.getName(), originalFilePath);
         } catch (IOException e)
         {
-            log.error("not found file", e.getMessage());
+            log.error("not found file\n{}", e.getMessage());
         } catch (freemarker.template.TemplateException e)
         {
-            log.error("Fail to generate HTML files.", e.getMessage());
+            log.error("Fail to generate HTML files.\n{}", e.getMessage());
         } finally
         {
             templateFile.delete();
@@ -616,7 +586,7 @@ public class CreateWebProjectCommand extends AbstractSubCommand<CreateProjectCom
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
             marshaller.marshal(tProject, file);
         } catch (JAXBException e) {
-            log.error("cannot marshal", e);
+            log.error("cannot marshal \n{}", e.getMessage());
         }
     }