You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by bl...@apache.org on 2016/09/04 21:05:11 UTC

avro git commit: AVRO-1884: Java: Add method to set the compiler output suffix.

Repository: avro
Updated Branches:
  refs/heads/master c37d05e87 -> e6d2c4d86


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/e6d2c4d8
Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/e6d2c4d8
Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/e6d2c4d8

Branch: refs/heads/master
Commit: e6d2c4d864222290e6e24039365476c8eeb2ea1e
Parents: c37d05e
Author: shijinkui <sh...@163.com>
Authored: Thu May 5 18:43:39 2016 +0800
Committer: Ryan Blue <bl...@apache.org>
Committed: Sun Sep 4 14:04:04 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/e6d2c4d8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5fad68e..70a2e33 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/e6d2c4d8/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;
     }
   }