asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Blow (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [NO ISSUE][*DB] Support abs paths in grammar ext plugin params
Date Wed, 29 Nov 2017 15:45:34 GMT
Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2184

Change subject: [NO ISSUE][*DB] Support abs paths in grammar ext plugin params
......................................................................

[NO ISSUE][*DB] Support abs paths in grammar ext plugin params

Change-Id: Ifd7ead4fd43154c34b8c6358dc3aff9c614ee172
---
M asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/84/2184/1

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 @@
     @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);
@@ -141,6 +144,10 @@
         processBase();
         processExtension();
         generateOutput();
+    }
+
+    private String resolvePath(String path) {
+        return new File(path).isAbsolute() ? path : new File(base, path).getAbsolutePath();
     }
 
     private void generateOutput() throws MojoExecutionException {
@@ -472,7 +479,7 @@
     }
 
     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 @@
     }
 
     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 @@
 
     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);
         }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2184
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd7ead4fd43154c34b8c6358dc3aff9c614ee172
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mblow@apache.org>

Mime
View raw message