avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [12/35] avro git commit: AVRO-1884: Java: Add method to set the compiler output suffix.
Date Sat, 05 Nov 2016 20:20:29 GMT
AVRO-1884: Java: Add method to set the compiler output suffix.

Use when generating non-Java files with custom templates. For example:

```
compiler.setSuffix(".scala")
compiler.setTemplateDir(scalaTemplatePath)
compiler.compileToDestination(file, new File("src/main/scala/"))
```

Closes #90.


Project: http://git-wip-us.apache.org/repos/asf/avro/repo
Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/d60d2663
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/d60d2663
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/d60d2663

Branch: refs/heads/branch-1.8
Commit: d60d26639a176494c133b5ef45eb77e5737e002b
Parents: 988a379
Author: shijinkui <shijinkui666@163.com>
Authored: Thu May 5 18:43:39 2016 +0800
Committer: Ryan Blue <blue@apache.org>
Committed: Sat Nov 5 13:15:17 2016 -0700

----------------------------------------------------------------------
 CHANGES.txt                                             |  3 +++
 .../apache/avro/compiler/specific/SpecificCompiler.java | 12 +++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/avro/blob/d60d2663/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2242785..3940fad 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -10,6 +10,9 @@ Trunk (not yet released)
 
     AVRO-1704: Spec: Add single-message encoding format. (Niels Basjes via blue)
 
+    AVRO-1884: Java: Add method to set the compiler output suffix.
+    (shijinkui via blue)
+
   OPTIMIZATIONS
 
   IMPROVEMENTS

http://git-wip-us.apache.org/repos/asf/avro/blob/d60d2663/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
index 762f84c..d1b594f 100644
--- a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
+++ b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
@@ -109,6 +109,7 @@ public class SpecificCompiler {
   private boolean createAllArgsConstructor = true;
   private String outputCharacterEncoding;
   private boolean enableDecimalLogicalType = false;
+  private String suffix = ".java";
 
   /*
    * Used in the record.vm template.
@@ -171,6 +172,11 @@ public class SpecificCompiler {
     this.templateDir = templateDir;
   }
 
+  /** Set the resource file suffix, .java or .xxx */
+  public void setSuffix(String suffix) {
+    this.suffix = suffix;
+  }
+
   /**
    * @return true if the record fields should be marked as deprecated
    */
@@ -400,12 +406,12 @@ public class SpecificCompiler {
     return outputFile;
   }
 
-  static String makePath(String name, String space) {
+  private String makePath(String name, String space) {
     if (space == null || space.isEmpty()) {
-      return name + ".java";
+      return name + suffix;
     } else {
       return space.replace('.', File.separatorChar) + File.separatorChar + name
-          + ".java";
+          + suffix;
     }
   }
 


Mime
View raw message