/**
* Class for representing parameter of Web Build
+ *
* @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)
*
*/
public class BuildWebParameter {
-
private boolean optimize;
private boolean excludeUIFW;
private List<String> excludeList = new ArrayList<String>();
}
public void setExcludeList(List<String> excludeList) {
- this.excludeList = excludeList;
+ if( null != excludeList) {
+ this.excludeList = excludeList;
+ }
}
public String getOutputName() {
this.workingDir = workingDir;
}
+
/**
* @return the workingDir
*/
}
public List<File> getReferences() {
- if( hasReference()) {
+ if (hasReference()) {
return Arrays.asList(this.refs);
}
return null;
import java.util.List;\r
\r
import org.kohsuke.args4j.Option;\r
+import org.kohsuke.args4j.spi.StringOptionHandler;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
import org.tizen.core.ide.BuildWebParameter;\r
import org.tizen.ncli.ide.subcommands.BuildWebCLICommand;\r
\r
-\r
-public class BuildWebCLI extends AbstractCLI{\r
+public class BuildWebCLI extends AbstractCLI {\r
private Logger log = LoggerFactory.getLogger(getClass());\r
- \r
- @Option(name="-opt" , aliases= {"--optimize"}, usage="Optimize option" )\r
- private boolean optimize;\r
- \r
- @Option(name="--output" , usage="Specify output directory name")\r
- private String outputName;\r
- \r
- @Option(name="-euf" , aliases= {"--exclude-uifw"} , usage="")\r
- private boolean excludeUIFW;\r
- \r
- @Option(name="-e" , aliases= {"--exclude"} , usage="")\r
- private List<String> excludeList;\r
- \r
+\r
+ @Option(name = "-opt", aliases = { "--optimize" }, usage = "Optimize option")\r
+ public boolean optimize;\r
+\r
+ @Option(name = "-out", aliases = {"--output"} ,handler=StringOptionHandler.class, usage = "Specify output directory name")\r
+ public String outputName;\r
+\r
+ @Option(name = "-euf", aliases = { "--exclude-uifw" }, usage = "Specify whether exclude tizen web ui f/w or not.")\r
+ public boolean excludeUIFW;\r
+\r
+ @Option(name = "-e", aliases = { "--exclude" }, usage = "Specify exclude file list.")\r
+ public List<String> excludeList;\r
+\r
private File cwd = new File(".");\r
- \r
- \r
- public void execute() {\r
- log.trace("Execute BuildWebCLI...");\r
- \r
- BuildWebCLICommand command = new BuildWebCLICommand();\r
- \r
- command.setOptimize(optimize);\r
- command.setOutputName(outputName);\r
- command.setExcludeUIFW(excludeUIFW);\r
- command.setExcludeList(excludeList);\r
- command.setWorkingDir(workingDir);\r
- \r
- BuildWebParameter commandData = command.runCommand();\r
- \r
- output.println("Build web project succeeded!");\r
- output.println(commandData);\r
+\r
+ public void execute() {\r
+ log.trace("Execute BuildWebCLI...");\r
+\r
+ BuildWebCLICommand command = new BuildWebCLICommand();\r
\r
+ if( null == workingDir && null != currentWorkspacePath) {\r
+ workingDir = new File(currentWorkspacePath);\r
+ }else {\r
+ workingDir = cwd;\r
+ }\r
+ if(null != outputName) {\r
+ command.setOutputName(outputName);\r
+ }\r
+ if( null != excludeList) {\r
+ command.setExcludeList(excludeList);\r
+ }\r
+ command.setOptimize(optimize);\r
+ command.setExcludeUIFW(excludeUIFW);\r
+ command.setWorkingDir(workingDir);\r
+\r
+ BuildWebParameter commandData = command.runCommand();\r
+\r
+ output.println("Build web project succeeded!");\r
+ output.println(commandData);\r
+\r
}\r
- \r
\r
}\r
// TODO implement build process with BuildProcess\r
\r
try {\r
- // set output path (absolute)\r
- if (!StringUtil.isEmpty(webAppBuildData.getOutputName())) {\r
-// this.buildWebAppModule.setOutput(convertPath(webAppBuildData.getOutputName()));\r
- } \r
-\r
- // If output path exist, the path will be recreated.\r
- // Set exclude file list\r
-\r
- // Set start layer\r
- // Get resource list for build\r
- // Generate web builders to build process\\r
-\r
+ buildWebAppModule.setData(webAppBuildData);\r
buildWebAppModule.buildResources();\r
\r
- } catch (MinifyException e) {\r
- StringBuffer msg = new StringBuffer();\r
- msg.append("Optimization failed.\n");\r
- msg.append("Error: " + e.getPath() + "(" + e.getLineNumber() + "): " + e.getLineSource() + "\n");\r
- msg.append("Cause: " + e.getMessage() + "\n");\r
- // TODO print out Exception message\r
- // getPrompter().notify(msg.toString());\r
- e.printStackTrace();\r
} catch (IOException e) {\r
e.printStackTrace();\r
} catch (BuildException e) {\r
import static org.junit.Assert.*;
import org.junit.Test;
+import org.kohsuke.args4j.CmdLineException;
/**
* @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)
*/
public class BuildWebCLITest extends Args4JTestBase<BuildWebCLI> {
-
+
+
+ @Test
+ public void test_build_basic() {
+ BuildWebCLI testObject = getTestObject();
+ String [] args = {"--output", "buildOutput"};
+ try {
+ parser.parseArgument(args);
+ } catch (CmdLineException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ log.trace("test_build_basic..");
+ }
+
@Override
public BuildWebCLI getTestObject() {
- // TODO Auto-generated method stub
return new BuildWebCLI();
}