*/
package org.tizen.ncli.ide.shell;
+import java.io.File;
+
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.StringOptionHandler;
import org.slf4j.Logger;
@Option(name = "-n", aliases = "--name", required = true, usage = "Specify template name")
private String projectName;
- @Option(name = "-out", aliases = {"--output"} ,handler=StringOptionHandler.class, usage = "Specify output directory name")
+ @Option(name = "-out", aliases = {"--output"}, handler=StringOptionHandler.class, usage = "Specify output directory name")
public String outputName;
/*
for (OptionGroup innerOptionGroup : optionGroup.getOptionGroup())
{
String addedKey = key + optionGroupSeparator + innerOptionGroup.getKey(); // key
- // ex)
- // group1_group2
buildModelForOptionGroup(innerOptionGroup, addedKey);
}
}
{
URL url = getClass().getClassLoader().getResource(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER);
String urlPath = url.getPath();
- String paths[] = urlPath.split("[:!]");
- String jarPath = paths[1];
- String destDirPath = jarPath + "_dir";
- String templateLibPath = destDirPath + File.separator + WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER + File.separator;
+ String templateLibPath = urlPath + File.separator;
- File destDirFile = new File(destDirPath);
- if (destDirFile.isDirectory())
- {
- return templateLibPath;
- }
- else
- {
- destDirFile.mkdir();
- }
-
- try
- {
- JarFile jar = new JarFile(jarPath);
- Enumeration enum2 = jar.entries();
- while (enum2.hasMoreElements())
+ // if the url is not expressed jar file
+ if(urlPath.contains("!"))
+ {
+ String jarPath = urlPath.replaceAll("file:", "").substring(0, urlPath.lastIndexOf(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER) - 7);
+
+ System.out.println("jar path = " + jarPath);
+
+ String destDirPath = jarPath + "_dir";
+
+ // make it if the destination directory is not created.
+ File destDirFile = new File(destDirPath);
+ if (destDirFile.isDirectory())
{
- JarEntry file = (JarEntry) enum2.nextElement();
- File f = new File(destDirPath + File.separator + file.getName());
- if (file.isDirectory())
- { // if its a directory, create it
- f.mkdir();
- continue;
- }
- InputStream is = jar.getInputStream(file); // get the input
- // stream
- FileOutputStream fos = new FileOutputStream(f);
- while (is.available() > 0)
- { // write contents of 'is' to 'fos'
- fos.write(is.read());
+ return templateLibPath;
+ }
+ else
+ {
+ destDirFile.mkdir();
+ }
+
+ templateLibPath = destDirPath + File.separator + WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER + File.separator;
+
+ try
+ {
+ JarFile jar = new JarFile(jarPath);
+ Enumeration enum2 = jar.entries();
+ while (enum2.hasMoreElements())
+ {
+ JarEntry file = (JarEntry) enum2.nextElement();
+ File f = new File(destDirPath + File.separator + file.getName());
+ if (file.isDirectory())
+ { // if its a directory, create it
+ f.mkdir();
+ continue;
+ }
+ InputStream is = jar.getInputStream(file); // get the input
+ // stream
+ FileOutputStream fos = new FileOutputStream(f);
+ while (is.available() > 0)
+ { // write contents of 'is' to 'fos'
+ fos.write(is.read());
+ }
+ fos.close();
+ is.close();
}
- fos.close();
- is.close();
+ } catch (FileNotFoundException e)
+ {
+ logger.error(e.getMessage());
+ } catch (IOException e)
+ {
+ logger.error(e.getMessage());
}
- } catch (FileNotFoundException e)
- {
- logger.error(e.getMessage());
- } catch (IOException e)
- {
- logger.error(e.getMessage());
}
+
return templateLibPath;
}
}