This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch branch-1.9
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.9 by this push:
     new 97e20b0  AVRO-1762: Velocity custom objects (#524)
97e20b0 is described below

commit 97e20b0d0dbea09b14affa8e1188f000a1fe0026
Author: Nicola Bova <[email protected]>
AuthorDate: Mon Jun 10 20:35:09 2019 +0200

    AVRO-1762: Velocity custom objects (#524)
    
    * AVRO-1762. Java: Put additional objects into Velocity template
    
    It provides more flexibility when generating code with custom Velocity
    templates.
    
    * AVRO-1762. Java: Put additional objects into Velocity template
    
    Rebased on master
    
    * AVRO-1762. Java: Put additional objects into Velocity template
    
    Improved unit tests
    
    * AVRO-1762: Velocity custom objects
    
    velocityTools is now of type List<Object>
    
    (cherry picked from commit a897c50bf28720373b89b10661902a8b9754f7a5)
---
 .../avro/compiler/specific/SpecificCompiler.java   | 17 +++++
 .../compiler/specific/TestSpecificCompiler.java    | 22 +++++++
 .../templates_with_custom_tools/record.vm          | 23 +++++++
 .../org/apache/avro/mojo/AbstractAvroMojo.java     | 22 +++++++
 .../java/org/apache/avro/mojo/IDLProtocolMojo.java |  1 +
 .../java/org/apache/avro/mojo/ProtocolMojo.java    |  1 +
 .../main/java/org/apache/avro/mojo/SchemaMojo.java |  1 +
 .../org/apache/avro/mojo/TestIDLProtocolMojo.java  | 19 ++++++
 .../org/apache/avro/mojo/TestProtocolMojo.java     | 17 +++++
 .../java/org/apache/avro/mojo/TestSchemaMojo.java  | 18 ++++++
 .../src/test/resources/templates/enum.vm           | 19 ++++++
 .../src/test/resources/templates/protocol.vm       | 19 ++++++
 .../src/test/resources/templates/record.vm         | 21 ++++++
 .../unit/idl/pom-injecting-velocity-tools.xml      | 74 ++++++++++++++++++++++
 .../unit/protocol/pom-injecting-velocity-tools.xml | 74 ++++++++++++++++++++++
 .../unit/schema/pom-injecting-velocity-tools.xml   | 71 +++++++++++++++++++++
 16 files changed, 419 insertions(+)

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 ef8e951..9123f5d 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
@@ -138,6 +138,7 @@ public class SpecificCompiler {
   private boolean enableDecimalLogicalType = false;
   private final DateTimeLogicalTypeImplementation 
dateTimeLogicalTypeImplementation;
   private String suffix = ".java";
+  private List<Object> additionalVelocityTools = new ArrayList<>();
 
   /*
    * Used in the record.vm template.
@@ -215,6 +216,14 @@ public class SpecificCompiler {
   }
 
   /**
+   * Set additional Velocity tools (simple POJOs) to be injected into the 
Velocity
+   * template context.
+   */
+  public void setAdditionalVelocityTools(List<Object> additionalVelocityTools) 
{
+    this.additionalVelocityTools = additionalVelocityTools;
+  }
+
+  /**
    * Set the resource directory where templates reside. First, the compiler 
checks
    * the system path for the specified file, if not it is assumed that it is
    * present on the classpath.
@@ -551,6 +560,10 @@ public class SpecificCompiler {
     VelocityContext context = new VelocityContext();
     context.put("protocol", protocol);
     context.put("this", this);
+    for (Object velocityTool : additionalVelocityTools) {
+      String toolName = velocityTool.getClass().getSimpleName().toLowerCase();
+      context.put(toolName, velocityTool);
+    }
     String out = renderTemplate(templateDir + "protocol.vm", context);
 
     OutputFile outputFile = new OutputFile();
@@ -602,6 +615,10 @@ public class SpecificCompiler {
     VelocityContext context = new VelocityContext();
     context.put("this", this);
     context.put("schema", schema);
+    for (Object velocityTool : additionalVelocityTools) {
+      String toolName = velocityTool.getClass().getSimpleName().toLowerCase();
+      context.put(toolName, velocityTool);
+    }
 
     switch (schema.getType()) {
     case RECORD:
diff --git 
a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
 
b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
index 34d8f1e..8b14c44 100644
--- 
a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
+++ 
b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
@@ -754,4 +754,26 @@ public class TestSpecificCompiler {
     }
     assertEquals(17, optionalFound);
   }
+
+  @Test
+  public void testAdditionalToolsAreInjectedIntoTemplate() throws Exception {
+    SpecificCompiler compiler = createCompiler();
+    List<Object> customTools = new ArrayList<>();
+    customTools.add(new String());
+    compiler.setAdditionalVelocityTools(customTools);
+    compiler.setTemplateDir("src/test/resources/templates_with_custom_tools/");
+    compiler.compileToDestination(this.src, this.OUTPUT_DIR.getRoot());
+    assertTrue(this.outputFile.exists());
+    int itWorksFound = 0;
+    try (BufferedReader reader = new BufferedReader(new 
FileReader(this.outputFile))) {
+      String line;
+      while ((line = reader.readLine()) != null) {
+        line = line.trim();
+        if (line.contains("It works!")) {
+          itWorksFound++;
+        }
+      }
+    }
+    assertEquals(1, itWorksFound);
+  }
 }
diff --git 
a/lang/java/compiler/src/test/resources/templates_with_custom_tools/record.vm 
b/lang/java/compiler/src/test/resources/templates_with_custom_tools/record.vm
new file mode 100644
index 0000000..75f9e5b
--- /dev/null
+++ 
b/lang/java/compiler/src/test/resources/templates_with_custom_tools/record.vm
@@ -0,0 +1,23 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
[email protected]
+public class ExemplarOne {
+  /**
+   * $string.concat("It works!")
+   */
+}
diff --git 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
index 0bbc137..279df8c 100644
--- 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
+++ 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
@@ -120,6 +120,15 @@ public abstract class AbstractAvroMojo extends 
AbstractMojo {
   protected String templateDirectory = 
"/org/apache/avro/compiler/specific/templates/java/classic/";
 
   /**
+   * The qualified names of classes which the plugin will look up, instantiate
+   * (through an empty constructor that must exist) and set up to be injected 
into
+   * Velocity templates by Avro compiler.
+   *
+   * @parameter property="velocityToolsClassesNames"
+   */
+  protected String[] velocityToolsClassesNames = new String[0];
+
+  /**
    * The createOptionalGetters parameter enables generating the getOptional...
    * methods that return an Optional of the requested type. This works ONLY on
    * Java 8+
@@ -286,6 +295,19 @@ public abstract class AbstractAvroMojo extends 
AbstractMojo {
     }
   }
 
+  protected List<Object> instantiateAdditionalVelocityTools() {
+    List<Object> velocityTools = new 
ArrayList<>(velocityToolsClassesNames.length);
+    for (String velocityToolClassName : velocityToolsClassesNames) {
+      try {
+        Class klass = Class.forName(velocityToolClassName);
+        velocityTools.add(klass.newInstance());
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+    return velocityTools;
+  }
+
   protected abstract void doCompile(String filename, File sourceDirectory, 
File outputDirectory) throws IOException;
 
   protected URLClassLoader createClassLoader() throws 
DependencyResolutionRequiredException, MalformedURLException {
diff --git 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/IDLProtocolMojo.java
 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/IDLProtocolMojo.java
index 070cdac..19e5cbe 100644
--- 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/IDLProtocolMojo.java
+++ 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/IDLProtocolMojo.java
@@ -94,6 +94,7 @@ public class IDLProtocolMojo extends AbstractAvroMojo {
         compiler.setCreateOptionalGetters(createOptionalGetters);
         compiler.setGettersReturnOptional(gettersReturnOptional);
         compiler.setCreateSetters(createSetters);
+        
compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
         compiler.setEnableDecimalLogicalType(enableDecimalLogicalType);
         for (String customConversion : customConversions) {
           
compiler.addCustomConversion(projPathLoader.loadClass(customConversion));
diff --git 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java
index e5638c7..b65c44a 100644
--- 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java
+++ 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/ProtocolMojo.java
@@ -66,6 +66,7 @@ public class ProtocolMojo extends AbstractAvroMojo {
     compiler.setCreateOptionalGetters(createOptionalGetters);
     compiler.setGettersReturnOptional(gettersReturnOptional);
     compiler.setCreateSetters(createSetters);
+    compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
     compiler.setEnableDecimalLogicalType(enableDecimalLogicalType);
     final URLClassLoader classLoader;
     try {
diff --git 
a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java 
b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java
index 95c5a4c..c0ad0d1 100644
--- a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java
+++ b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/SchemaMojo.java
@@ -93,6 +93,7 @@ public class SchemaMojo extends AbstractAvroMojo {
       throw new IOException(e);
     }
     
compiler.setOutputCharacterEncoding(project.getProperties().getProperty("project.build.sourceEncoding"));
+    compiler.setAdditionalVelocityTools(instantiateAdditionalVelocityTools());
     compiler.compileToDestination(src, outputDirectory);
   }
 
diff --git 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestIDLProtocolMojo.java
 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestIDLProtocolMojo.java
index d75c75d..7429b94 100644
--- 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestIDLProtocolMojo.java
+++ 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestIDLProtocolMojo.java
@@ -30,6 +30,8 @@ public class TestIDLProtocolMojo extends AbstractAvroMojoTest 
{
 
   protected File jodaTestPom = new File(getBasedir(), 
"src/test/resources/unit/idl/pom-joda.xml");
   protected File jsr310TestPom = new File(getBasedir(), 
"src/test/resources/unit/idl/pom-jsr310.xml");
+  protected File injectingVelocityToolsTestPom = new File(getBasedir(),
+      "src/test/resources/unit/idl/pom-injecting-velocity-tools.xml");
 
   public void testIdlProtocolMojoJoda() throws Exception {
     IDLProtocolMojo mojo = (IDLProtocolMojo) lookupMojo("idl-protocol", 
jodaTestPom);
@@ -58,4 +60,21 @@ public class TestIDLProtocolMojo extends 
AbstractAvroMojoTest {
     String idlUserContent = FileUtils.fileRead(new File(outputDir, 
"IdlUser.java"));
     assertTrue(idlUserContent.contains("java.time.Instant"));
   }
+
+  public void testSetCompilerVelocityAdditionalTools() throws Exception {
+    injectingVelocityToolsTestPom = new File(getBasedir(),
+        "src/test/resources/unit/idl/pom-injecting-velocity-tools.xml");
+    IDLProtocolMojo mojo = (IDLProtocolMojo) lookupMojo("idl-protocol", 
injectingVelocityToolsTestPom);
+
+    assertNotNull(mojo);
+    mojo.execute();
+
+    File outputDir = new File(getBasedir(), "target/test-harness/idl/test");
+    String[] generatedFiles = new String[] { "IdlPrivacy.java", 
"IdlTest.java", "IdlUser.java", "IdlUserWrapper.java" };
+
+    assertFilesExist(outputDir, generatedFiles);
+
+    String schemaUserContent = FileUtils.fileRead(new File(outputDir, 
"IdlUser.java"));
+    assertTrue(schemaUserContent.contains("It works!"));
+  }
 }
diff --git 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestProtocolMojo.java
 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestProtocolMojo.java
index eb8477e..33663ed 100644
--- 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestProtocolMojo.java
+++ 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestProtocolMojo.java
@@ -30,6 +30,8 @@ public class TestProtocolMojo extends AbstractAvroMojoTest {
 
   protected File jodaTestPom = new File(getBasedir(), 
"src/test/resources/unit/protocol/pom-joda.xml");
   protected File jsr310TestPom = new File(getBasedir(), 
"src/test/resources/unit/protocol/pom-jsr310.xml");
+  protected File injectingVelocityToolsTestPom = new File(getBasedir(),
+      "src/test/resources/unit/protocol/pom-injecting-velocity-tools.xml");
 
   public void testProtocolMojoJoda() throws Exception {
     ProtocolMojo mojo = (ProtocolMojo) lookupMojo("protocol", jodaTestPom);
@@ -60,4 +62,19 @@ public class TestProtocolMojo extends AbstractAvroMojoTest {
     String protocolUserContent = FileUtils.fileRead(new File(outputDir, 
"ProtocolUser.java"));
     assertTrue(protocolUserContent.contains("java.time.Instant"));
   }
+
+  public void testSetCompilerVelocityAdditionalTools() throws Exception {
+    ProtocolMojo mojo = (ProtocolMojo) lookupMojo("protocol", 
injectingVelocityToolsTestPom);
+
+    assertNotNull(mojo);
+    mojo.execute();
+
+    File outputDir = new File(getBasedir(), 
"target/test-harness/protocol/test");
+    String[] generatedFiles = new String[] { "ProtocolPrivacy.java", 
"ProtocolTest.java", "ProtocolUser.java" };
+
+    assertFilesExist(outputDir, generatedFiles);
+
+    String schemaUserContent = FileUtils.fileRead(new File(outputDir, 
"ProtocolUser.java"));
+    assertTrue(schemaUserContent.contains("It works!"));
+  }
 }
diff --git 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestSchemaMojo.java 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestSchemaMojo.java
index 9dc367f..4a116a8 100644
--- 
a/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestSchemaMojo.java
+++ 
b/lang/java/maven-plugin/src/test/java/org/apache/avro/mojo/TestSchemaMojo.java
@@ -30,6 +30,8 @@ public class TestSchemaMojo extends AbstractAvroMojoTest {
 
   protected File jodaTestPom = new File(getBasedir(), 
"src/test/resources/unit/schema/pom-joda.xml");
   protected File jsr310TestPom = new File(getBasedir(), 
"src/test/resources/unit/schema/pom-jsr310.xml");
+  protected File injectingVelocityToolsTestPom = new File(getBasedir(),
+      "src/test/resources/unit/schema/pom-injecting-velocity-tools.xml");
 
   public void testSchemaMojoJoda() throws Exception {
     SchemaMojo mojo = (SchemaMojo) lookupMojo("schema", jodaTestPom);
@@ -62,4 +64,20 @@ public class TestSchemaMojo extends AbstractAvroMojoTest {
     String schemaUserContent = FileUtils.fileRead(new File(outputDir, 
"SchemaUser.java"));
     assertTrue(schemaUserContent.contains("java.time.Instant"));
   }
+
+  public void testSetCompilerVelocityAdditionalTools() throws Exception {
+    SchemaMojo mojo = (SchemaMojo) lookupMojo("schema", 
injectingVelocityToolsTestPom);
+
+    assertNotNull(mojo);
+    mojo.execute();
+
+    File outputDir = new File(getBasedir(), "target/test-harness/schema/test");
+    String[] generatedFiles = new String[] { "PrivacyDirectImport.java", 
"PrivacyImport.java", "SchemaPrivacy.java",
+        "SchemaUser.java" };
+
+    assertFilesExist(outputDir, generatedFiles);
+
+    String schemaUserContent = FileUtils.fileRead(new File(outputDir, 
"SchemaUser.java"));
+    assertTrue(schemaUserContent.contains("It works!"));
+  }
 }
diff --git a/lang/java/maven-plugin/src/test/resources/templates/enum.vm 
b/lang/java/maven-plugin/src/test/resources/templates/enum.vm
new file mode 100644
index 0000000..0ec156f
--- /dev/null
+++ b/lang/java/maven-plugin/src/test/resources/templates/enum.vm
@@ -0,0 +1,19 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+## No need to place anything here by now. File must exist, though.
diff --git a/lang/java/maven-plugin/src/test/resources/templates/protocol.vm 
b/lang/java/maven-plugin/src/test/resources/templates/protocol.vm
new file mode 100644
index 0000000..0ec156f
--- /dev/null
+++ b/lang/java/maven-plugin/src/test/resources/templates/protocol.vm
@@ -0,0 +1,19 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+## No need to place anything here by now. File must exist, though.
diff --git a/lang/java/maven-plugin/src/test/resources/templates/record.vm 
b/lang/java/maven-plugin/src/test/resources/templates/record.vm
new file mode 100644
index 0000000..0c55177
--- /dev/null
+++ b/lang/java/maven-plugin/src/test/resources/templates/record.vm
@@ -0,0 +1,21 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+/**
+ * $string.concat("It works!")
+ */
diff --git 
a/lang/java/maven-plugin/src/test/resources/unit/idl/pom-injecting-velocity-tools.xml
 
b/lang/java/maven-plugin/src/test/resources/unit/idl/pom-injecting-velocity-tools.xml
new file mode 100644
index 0000000..b79458a
--- /dev/null
+++ 
b/lang/java/maven-plugin/src/test/resources/unit/idl/pom-injecting-velocity-tools.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>avro-parent</artifactId>
+    <groupId>org.apache.avro</groupId>
+    <version>1.9.0-SNAPSHOT</version>
+    <relativePath>../../../../../../../../../</relativePath>
+  </parent>
+
+  <artifactId>avro-maven-plugin-test</artifactId>
+  <packaging>jar</packaging>
+
+  <name>testproject</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>avro-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>idl</id>
+            <goals>
+              <goal>idl-protocol</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <sourceDirectory>${basedir}/src/test</sourceDirectory>
+          <outputDirectory>${basedir}/target/test-harness/idl</outputDirectory>
+          <stringType>String</stringType>
+          <templateDirectory>
+            ${basedir}/src/test/resources/templates/
+          </templateDirectory>
+          <velocityToolsClassesNames>
+            <param>java.lang.String</param>
+          </velocityToolsClassesNames>
+          <project 
implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.avro</groupId>
+      <artifactId>avro</artifactId>
+      <version>${parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git 
a/lang/java/maven-plugin/src/test/resources/unit/protocol/pom-injecting-velocity-tools.xml
 
b/lang/java/maven-plugin/src/test/resources/unit/protocol/pom-injecting-velocity-tools.xml
new file mode 100644
index 0000000..d811eb4
--- /dev/null
+++ 
b/lang/java/maven-plugin/src/test/resources/unit/protocol/pom-injecting-velocity-tools.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>avro-parent</artifactId>
+    <groupId>org.apache.avro</groupId>
+    <version>1.9.0-SNAPSHOT</version>
+    <relativePath>../../../../../../../../../</relativePath>
+  </parent>
+
+  <artifactId>avro-maven-plugin-test</artifactId>
+  <packaging>jar</packaging>
+
+  <name>testproject</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>avro-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>protocol</id>
+            <goals>
+              <goal>protocol</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <sourceDirectory>${basedir}/src/test/avro</sourceDirectory>
+          
<outputDirectory>${basedir}/target/test-harness/protocol</outputDirectory>
+          <project 
implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <templateDirectory>
+            ${basedir}/src/test/resources/templates/
+          </templateDirectory>
+          <stringType>String</stringType>
+          <velocityToolsClassesNames>
+            <param>java.lang.String</param>
+          </velocityToolsClassesNames>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.avro</groupId>
+      <artifactId>avro</artifactId>
+      <version>${parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git 
a/lang/java/maven-plugin/src/test/resources/unit/schema/pom-injecting-velocity-tools.xml
 
b/lang/java/maven-plugin/src/test/resources/unit/schema/pom-injecting-velocity-tools.xml
new file mode 100644
index 0000000..f45076e
--- /dev/null
+++ 
b/lang/java/maven-plugin/src/test/resources/unit/schema/pom-injecting-velocity-tools.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>avro-maven-plugin-test</artifactId>
+  <packaging>jar</packaging>
+
+  <name>testproject</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>avro-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>schema</id>
+            <goals>
+              <goal>schema</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <sourceDirectory>${basedir}/src/test/avro</sourceDirectory>
+          
<outputDirectory>${basedir}/target/test-harness/schema</outputDirectory>
+          <imports>
+            <import>${basedir}/src/test/avro/imports</import>
+            
<import>${basedir}/src/test/avro/directImport/PrivacyDirectImport.avsc</import>
+          </imports>
+          <project 
implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <templateDirectory>
+            ${basedir}/src/test/resources/templates/
+          </templateDirectory>
+          <stringType>String</stringType>
+          <velocityToolsClassesNames>
+            <param>java.lang.String</param>
+          </velocityToolsClassesNames>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.avro</groupId>
+      <artifactId>avro</artifactId>
+      <version>${parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>

Reply via email to