[ 
https://issues.apache.org/jira/browse/AVRO-2940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17222157#comment-17222157
 ] 

Ryan Skraba commented on AVRO-2940:
-----------------------------------

Hello!  This sounds like a nice improvement for those who are writing their own 
templates (which is already a very daunting task in Java...) 

What do you think about about simply falling back to the resources packaged 
with the Avro compiler, even if the templateDir is specified?  I can't see 
anybody _wanting_ to have an error because there's a missing velocity template 
and that might cover your use case without having to change the templateDir 
from a single string to a list.

> Add velocity template overrides to maven plugin
> -----------------------------------------------
>
>                 Key: AVRO-2940
>                 URL: https://issues.apache.org/jira/browse/AVRO-2940
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Nicolas
>            Priority: Major
>
> h3. Context
> In my team, we are exploring creating java classes for our internal teams 
> with additional customizations like adding annotations to the output java 
> class from .avsc. To do this, we have modeled off of the maven-plugin module. 
> Ultimately we needed to create a custom record.vm template and set our own 
> templateDirectory in the classpath of our custom wrapping jar. 
> {code:java}
> final SpecificCompiler compiler = new SpecificCompiler(protocol);
> compiler.setTemplateDir(templateDirectory); {code}
> h3. Problem 
> Even though we are only overriding a subset of the velocity templates, we are 
> copy pasting all of the templates from the compiler module. The 
> SpecificCompiler class can only handle a single directory and assumes we can 
> just append
> {code:java}
> templateDir + "<template>.vm" {code}
> h3. Idea for improvement
> I am wondering if it's worth exploring having users of the compiler take a 
> list of directories. We can use the ordering to determine the priority of the 
> template so that users like me could provide our local directory at the head 
> with only our overrides present. 
> For backwards compatibility, we can keep the existing setter method. The 
> result of that is a singleton list. As part of this, we could create 
> .addTemplateOverride() on the compiler which would prepend.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to