<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="lib/args4j-2.0.25.jar"/>
+ <classpathentry kind="lib" path="lib/args4j-2.0.25.jar" sourcepath="/args4j/args4j/src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
private Logger log = LoggerFactory.getLogger(getClass());
private BuildWebParameter data;
private String cwd;
- private String output = ".buildResult";
+ private String output = ".buildResult";
private SimpleFileFilter filter = new SimpleFileFilter(true);
public FactoryWithArgument<Filter, String> filterFactory = new WildCardFilterFactory();
public List<String> excludes = new ArrayList<String>();
- private String[] DEFAULT_EXCLUDES = {
- ".build/*",
- ".project",
- ".settings/*",
- ".sdk_delta.info", "*.wgt"
- };
+ private String[] DEFAULT_EXCLUDES = { ".build/*", ".project", ".settings/*", ".sdk_delta.info", "*.wgt" };
public BuildWebAppModule() {
// TODO Auto-generated constructor stub
}
+
/**
* @param cwd
* the cwd to set
}
/**
- * @param data the data to set
+ * @param data
+ * the data to set
*/
public void setData(BuildWebParameter data) {
this.data = data;
this.excludes = excludes;
}
-
-
public void buildResources() throws IOException, BuildException, Exception {
BuildProcess buildProcess = new BuildProcess();
-
- if( isPrerequisiteSatisfy()) {
+
+ if (isPrerequisiteSatisfy()) {
// Set output
- if( null != data && null != data.getOutputName()) {
- this.output = cwd+File.separator+data.getOutputName();
- }else {
- this.output = cwd+File.separator+this.output;
+ if (null != data && null != data.getOutputName()) {
+ this.output = cwd + File.separator + data.getOutputName();
+ } else {
+ this.output = cwd + File.separator + this.output;
}
// If output path exist, the path will be recreated.
deleteOutput();
// Set default exclude resources
addDefaultExclude();
-
+
// Set start layer
FileHandler fh = new StandardFileHandler();
fh.setCurrentWorkingDirectory(cwd);
log.trace("Total resource count: {}", resources.length);
// Generate web builders to build process
}
-
+
generateAllBuilders(buildProcess, startLayer);
if (buildProcess.getLastBuilder() != null) {
// check succeeding status.
checkHybridStructure(buildProcess);
}
- }else {
+ } else {
throw new BuildException(null);
}
- Assert.notNull(cwd,"Current Working Directory should not be NULL.");
+ Assert.notNull(cwd, "Current Working Directory should not be NULL.");
}
private void deleteOutput() {
- if(FileUtil.isExist(output)) {
+ if (FileUtil.isExist(output)) {
FileUtil.recursiveDelete(new File(output));
}
}
+
private void addDefaultExclude() {
- if( null != data && null != data.getExcludeList()) {
- for (String defaultExclude : DEFAULT_EXCLUDES) {
- log.trace("add exclude:{}",defaultExclude);
- data.getExcludeList().add(defaultExclude);
- }
+ if (null == data) {
+ data = new BuildWebParameter();
+ }
+ for (String defaultExclude : DEFAULT_EXCLUDES) {
+ log.trace("add exclude:{}", defaultExclude);
+ data.getExcludeList().add(defaultExclude);
}
}
+
/**
* Check pre-requisite for executing build
- *
+ *
* @return
*/
private boolean isPrerequisiteSatisfy() {
- return null != cwd && !"".equals(cwd.trim()) ;
+ return null != cwd && !"".equals(cwd.trim());
}
/**
private Resource[] getBuildResources(ResourceLayer layer) throws IOException {
List<Resource> resources = new ArrayList<Resource>();
// setIncludes(includes);
- setExcludes(data.getExcludeList());
- log.trace("CWD:{}",cwd);
+ setExcludes(data.getExcludeList());
+ log.trace("CWD:{}", cwd);
String cwd = layer.getFileHandler().getCurrentWorkingDirectory();
resources.addAll(getResources(cwd, FilenameUtil.getRelativePath(cwd, cwd), layer));
// TODO Notification ?? getPrompter().notify( MessageFormat.format( SUCCEED_MSG, this.output ) );
}
-
+
/**
* Set excluding resource list
+ *
* @param excludes
*/
private void setExcludes(List<String> excludes) {
-// filter.clearExcludes();
+ // filter.clearExcludes();
if (null != excludes) {
for (final String exclude : excludes) {
filter.addExcludes(filterFactory.create(exclude));
\r
protected PrintWriter output = new PrintWriter(System.out);;\r
\r
- public final void execute(String[] args) {\r
- parseArgument(args);\r
- execute();\r
- }\r
-\r
- /**\r
- * @param args\r
- */\r
- private void parseArgument(String[] args) {\r
- log.trace("Could not use parsing argument again!");\r
- }\r
public abstract void execute();\r
}\r
*/\r
package org.tizen.ncli.ide.shell;\r
\r
+import java.io.PrintWriter;\r
import java.util.List;\r
\r
import org.kohsuke.args4j.Argument;\r
import org.kohsuke.args4j.CmdLineException;\r
import org.kohsuke.args4j.CmdLineParser;\r
+import org.kohsuke.args4j.OptionHandlerFilter;\r
import org.kohsuke.args4j.spi.OptionHandler;\r
import org.kohsuke.args4j.spi.SubCommand;\r
import org.kohsuke.args4j.spi.SubCommandHandler;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
\r
-\r
/**\r
- * This class is entry point of Tizen New Command Line Interface. All the command\r
- * line argument would be parsed and then proper Command class is called.\r
+ * This class is entry point of Tizen New Command Line Interface. All the command line argument would be parsed and then\r
+ * proper Command class is called.\r
* \r
* @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
* \r
\r
private Logger log = LoggerFactory.getLogger(Main.class);\r
\r
- @Argument(index = 0, required = true, handler = SubCommandHandler.class, usage = "Command is needed!")\r
+ @Argument(index = 0, required = true, handler = SubCommandHandler.class, \r
+ usage = "Sub command is needed!" , \r
+ metaVar="[create | build-native | build-web | cli-config | sign]")\r
@SubCommands({ @SubCommand(name = "create", impl = CreateCLI.class),\r
@SubCommand(name = "build-native", impl = BuildNativeCLI.class),\r
@SubCommand(name = "build-web", impl = BuildWebCLI.class),\r
- @SubCommand(name = "sign", impl = SignCLI.class),\r
- @SubCommand(name = "cli-config", impl = ConfigCLI.class) })\r
+ @SubCommand(name = "sign", impl = SignCLI.class), @SubCommand(name = "cli-config", impl = ConfigCLI.class) })\r
private AbstractCLI tizenCLI;\r
\r
/**\r
\r
private void run(String[] args) {\r
CmdLineParser cmdParser = new CmdLineParser(this);\r
-\r
log.trace("Start running Tizen CLI Main class...");\r
try {\r
- //Argument parsing - make metadata from annotation.\r
+ // Argument parsing - make metadata from annotation.\r
cmdParser.parseArgument(args);\r
- if( null != this.tizenCLI) {\r
+ if (null != this.tizenCLI) {\r
this.tizenCLI.execute();\r
}\r
- \r
+\r
} catch (CmdLineException e) {\r
// TODO Handle CLI exception\r
+ cmdParser.printUsage(System.out);\r
e.printStackTrace();\r
} catch (Exception e) {\r
- // TODO: handle exception\r
- e.printStackTrace();\r
- }\r
+ // TODO: handle exception\r
+ cmdParser.printUsage(System.out);\r
+ e.printStackTrace();\r
+ }\r
\r
}\r
\r
--- /dev/null
+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.shell;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)
+ *
+ *
+ */
+public class BuildWebCLITest extends Args4JTestBase<BuildWebCLI> {
+
+
+ @Override
+ public BuildWebCLI getTestObject() {
+ // TODO Auto-generated method stub
+ return new BuildWebCLI();
+ }
+
+}
try {\r
parser.parseArgument(args);\r
} catch (CmdLineException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- throw new Exception();\r
+ fail(e.getMessage());\r
}\r
testObject.execute();\r
- //TODO assertion needed\r
+ }\r
+ \r
+ @Test\r
+ public void test_no_option() throws Exception{\r
+ String [] args = {""};\r
+ \r
+ try {\r
+ parser.parseArgument(args);\r
+ } catch (CmdLineException e) {\r
+ e.printStackTrace();\r
+ assertNotNull(e);\r
+ }\r
}\r
\r
\r