Avro
  1. Avro
  2. AVRO-963

Allow compiler's template directory to be overridden in Maven plugins

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.2
    • Component/s: java
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      It is currently not possible to override the location of the velocity templates except via overriding a system property which requires a maven command line option. Allow for the location of the templates to be specified via a configuration parameter in the avro maven plugin.

      1. avro-jira-963.patch
        3 kB
        George Fletcher

        Activity

        Hide
        Ed Kohlwey added a comment -

        Here's a better patch with a test included.

        Show
        Ed Kohlwey added a comment - Here's a better patch with a test included.
        Hide
        Ed Kohlwey added a comment -

        *edit- just to clarify, I'm putting the templates in $

        {project.basedir}

        /src/main/resources/...

        Show
        Ed Kohlwey added a comment - *edit- just to clarify, I'm putting the templates in $ {project.basedir} /src/main/resources/...
        Hide
        Ed Kohlwey added a comment -

        Has anyone tried this? Putting the velocity templates in /src/resources/... doesn't seem to actually get them on the plugin classpath. Or perhaps I'm doing something wrong...

        Show
        Ed Kohlwey added a comment - Has anyone tried this? Putting the velocity templates in /src/resources/... doesn't seem to actually get them on the plugin classpath. Or perhaps I'm doing something wrong...
        Hide
        Scott Carey added a comment -

        This is great! I'll be using it soon.

        Show
        Scott Carey added a comment - This is great! I'll be using it soon.
        Hide
        Doug Cutting added a comment -

        I committed this. Thanks, George!

        Show
        Doug Cutting added a comment - I committed this. Thanks, George!
        Hide
        George Fletcher added a comment -

        Added a 'templateDirectory' configuration parameter for the avro-maven-plugin that allows the default template directory to be overridden.

        Show
        George Fletcher added a comment - Added a 'templateDirectory' configuration parameter for the avro-maven-plugin that allows the default template directory to be overridden.
        Hide
        George Fletcher added a comment -

        It's pretty straight forward to leverage the SpecificCompiler.java setTemplateDir() method via a configuration parameter. However, this still requires the templates to be part of the java class path. Is that acceptable?

        For example in the *Mojo.java files...

        /**
        *
        * Override the default location for the velocity templates
        * @parameter
        */
        private String templateDir = null;
        
        @Override
        protected void doCompile (...) {
            ...
        
            SpecificCompiler compiler = new SpecificCompiler(protocol);
            if (this.templateDir != null) {
                compiler.setTemplateDir(this.templateDir);
            }
            compiler.setStringType(StringType.valueOf(stringType));
            compiler.compileToDestination(src, outputDirectory);
        
            ...
        }
        
        Show
        George Fletcher added a comment - It's pretty straight forward to leverage the SpecificCompiler.java setTemplateDir() method via a configuration parameter. However, this still requires the templates to be part of the java class path. Is that acceptable? For example in the *Mojo.java files... /** * * Override the default location for the velocity templates * @parameter */ private String templateDir = null ; @Override protected void doCompile (...) { ... SpecificCompiler compiler = new SpecificCompiler(protocol); if ( this .templateDir != null ) { compiler.setTemplateDir( this .templateDir); } compiler.setStringType(StringType.valueOf(stringType)); compiler.compileToDestination(src, outputDirectory); ... }

          People

          • Assignee:
            George Fletcher
            Reporter:
            George Fletcher
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development