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

Nicolas commented on AVRO-2940:
-------------------------------

Hey [~rskraba] that makes sense and would simplify, but I think it depends on 
how extensible we see this feature. If we allow plugin developers to add their 
own overrides, should we extend that capability so that importers of the plugin 
can also add their own override on top of our custom plugin on top of the 
apache plugin? I would prefer to give developers the ability to override their 
templates (although they should seldom use it). Given that the apache plugin 
already allows for overrides at the directory level, it seems like that was the 
original intent as well. 

 

With that approach we'd have a list of 3 directories
{code:java}
[
  application/resources/templates,
  customer-plugin/resources/templates,
  apache/resources/templates
] {code}
with priority given to templates at index 0

> 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