Repository: asterixdb Updated Branches: refs/heads/master 35b6c1317 -> 0a0a2b3b5
[NO ISSUE][*DB] Support abs paths in grammar ext plugin params Change-Id: Ifd7ead4fd43154c34b8c6358dc3aff9c614ee172 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2184 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/0a0a2b3b Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/0a0a2b3b Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/0a0a2b3b Branch: refs/heads/master Commit: 0a0a2b3b5536cc6427e3576e6492d30fb1f75e1e Parents: 35b6c13 Author: Michael Blow <[email protected]> Authored: Wed Nov 29 10:44:59 2017 -0500 Committer: Michael Blow <[email protected]> Committed: Wed Nov 29 11:38:29 2017 -0800 ---------------------------------------------------------------------- .../extension/grammar/GrammarExtensionMojo.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0a0a2b3b/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java b/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java index 17a71f2..0abca8a 100644 --- a/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java +++ b/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java @@ -134,6 +134,9 @@ public class GrammarExtensionMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException { base = new File(base).getAbsolutePath(); + gbase = resolvePath(gbase); + gextension = resolvePath(gextension); + output = resolvePath(output); getLog().info("Base dir: " + base); getLog().info("Grammar-base: " + gbase); getLog().info("Grammar-extension: " + gextension); @@ -143,6 +146,10 @@ public class GrammarExtensionMojo extends AbstractMojo { generateOutput(); } + private String resolvePath(String path) { + return new File(path).isAbsolute() ? path : new File(base, path).getAbsolutePath(); + } + private void generateOutput() throws MojoExecutionException { File outputFile = prepareOutputFile(); try (BufferedWriter writer = Files.newBufferedWriter(outputFile.toPath(), StandardCharsets.UTF_8)) { @@ -472,7 +479,7 @@ public class GrammarExtensionMojo extends AbstractMojo { } private void processBase() throws MojoExecutionException { - try (BufferedReader reader = Files.newBufferedReader(Paths.get(base, gbase), StandardCharsets.UTF_8)) { + try (BufferedReader reader = Files.newBufferedReader(Paths.get(gbase), StandardCharsets.UTF_8)) { StringBuilder identifier = new StringBuilder(); while ((position.line = reader.readLine()) != null) { if (position.line.trim().startsWith("//")) { @@ -693,7 +700,7 @@ public class GrammarExtensionMojo extends AbstractMojo { } private void processExtension() throws MojoExecutionException { - try (BufferedReader reader = Files.newBufferedReader(Paths.get(base, gextension), StandardCharsets.UTF_8)) { + try (BufferedReader reader = Files.newBufferedReader(Paths.get(gextension), StandardCharsets.UTF_8)) { StringBuilder identifier = new StringBuilder(); String nextOperation = OVERRIDEPRODUCTION; while (read || (position.line = reader.readLine()) != null) { @@ -989,7 +996,7 @@ public class GrammarExtensionMojo extends AbstractMojo { private File prepareOutputFile() throws MojoExecutionException { // write output - File outputFile = new File(base, output); + File outputFile = new File(output); if (outputFile.exists() && (!outputFile.delete())) { throw new MojoExecutionException("Unable to delete file " + output); }
