Repository: gora Updated Branches: refs/heads/master 37d44b874 -> 1242a61db
Add ability to compile files in a directory via gora-compiler Project: http://git-wip-us.apache.org/repos/asf/gora/repo Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/3a4f1390 Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/3a4f1390 Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/3a4f1390 Branch: refs/heads/master Commit: 3a4f1390673ea29f96be1166a8f28fee4bd7444a Parents: 37d44b8 Author: nishadi <ndime...@gmail.com> Authored: Mon May 22 22:05:19 2017 +0530 Committer: nishadi <ndime...@gmail.com> Committed: Mon May 22 22:05:19 2017 +0530 ---------------------------------------------------------------------- .../gora/compiler/cli/GoraCompilerCLI.java | 27 +++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/gora/blob/3a4f1390/gora-compiler-cli/src/main/java/org/apache/gora/compiler/cli/GoraCompilerCLI.java ---------------------------------------------------------------------- diff --git a/gora-compiler-cli/src/main/java/org/apache/gora/compiler/cli/GoraCompilerCLI.java b/gora-compiler-cli/src/main/java/org/apache/gora/compiler/cli/GoraCompilerCLI.java index c96ed57..39cd5a6 100644 --- a/gora-compiler-cli/src/main/java/org/apache/gora/compiler/cli/GoraCompilerCLI.java +++ b/gora-compiler-cli/src/main/java/org/apache/gora/compiler/cli/GoraCompilerCLI.java @@ -46,18 +46,31 @@ public class GoraCompilerCLI { printHelp(); System.exit(1); } - File[] inputs = new File[args.length-1]; - for(int i = 0; i<inputs.length; i++){ - File inputFile = new File(args[i]); - if(!inputFile.isFile()){ - LOG.error("Input must be a file."); + // Processing input directory or input files + File inputDir = new File(args[0]); + File[] inputFiles = null; + if (inputDir.isDirectory()) { + if (inputDir.length() > 0) + inputFiles = inputDir.listFiles(); + else { + LOG.error("Input directory must include at least one file."); printHelp(); System.exit(1); } - inputs[i] = inputFile; + } else { + inputFiles = new File[args.length - 1]; + for (int i = 0; i < inputFiles.length; i++) { + File inputFile = new File(args[i]); + if (!inputFile.isFile()) { + LOG.error("Input must be a file."); + printHelp(); + System.exit(1); + } + inputFiles[i] = inputFile; + } } try { - GoraCompiler.compileSchema(inputs, outputDir); + GoraCompiler.compileSchema(inputFiles, outputDir); LOG.info("Compiler executed SUCCESSFULL."); } catch (IOException e) { LOG.error("Error while compiling schema files. Check that the schemas are properly formatted.");