Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.8.2, 1.10.0, 1.9.2
-
None
Description
- avro-maven-plugin v1.10.0
- apache avro v1.10.0
- maven 3.5.4
We have encountered problems with some file structures and how the avro plugin manages the inclusion and exclusion of files in the processing and generation of java classes.
When we specify the order of the files or directories import for the plugin, we see mainly two problems that we detail below.
For the following avro definition structure:
├── imports │ └── event │ ├── event1 │ │ ├── v5 │ │ │ └── imports │ │ │ └── entities │ │ │ └── PrivacyImport.avsc │ │ └── v6 │ │ └── imports │ │ └── entities │ │ └── PrivacyImport.avsc │ └── event2 │ └── v1 │ └── entities │ └── PrivacyImport.avsc └── sources └── event └── event1 ├── v5 │ └── User.avsc └── v6 └── User.avsc
1. If by necessity of the project we must explicitly specify first in the order of import a file (PrivacyImport.avsc), and then different directories containing a file with the same name, even if their content is different, the plugin excludes them from processing.
<avro.imports.resources> ${project.basedir}/src/main/resources/demo/imports/event/event2/v1/entities/PrivacyImport.avsc,${project.basedir}/src/main/resources/demo/imports/event/event1/v5/imports,${project.basedir}/src/main/resources/demo/imports/event/event1/v6/imports </avro.imports.resources>
Result: Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.0:schema (avro-events) on project demo-event: Execution avro-events of goal org.apache.avro:avro-maven-plugin:1.10.0:schema failed: Undefined name: "test.v5.PrivacyImport"
2. If for necessity of the project we must explicitly specify first in the order a directory (imports/event/event2/v1/entities), and then different directories contain a directory with the same name, the plugin excludes these directories (entities/**) and all their content from processing.
<avro.imports.resources> ${project.basedir}/src/main/resources/demo/imports/event/event2/v1/entities,${project.basedir}/src/main/resources/demo/imports/event/event1/v5/imports,${project.basedir}/src/main/resources/demo/imports/event/event1/v6/imports </avro.imports.resources>
Result: Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.0:schema (avro-events) on project demo-event: Execution avro-events of goal org.apache.avro:avro-maven-plugin:1.10.0:schema failed: Undefined name: "test.v5.PrivacyImport"
From what we have seen, these unexpected behaviors occur because in the configuration of the exclusion of files and directories in the "getIncludedFiles()" method of the AbstractAvroMojo.java class, only the filename is obtained. For example, if the import settings is:
<avro.imports.resources> ${project.basedir}/src/main/resources/demo/imports/event/event2/v1/entities/PrivacyImport.avsc,${project.basedir}/src/main/resources/demo/imports/event/event1/v5/imports,${project.basedir}/src/main/resources/demo/imports/event/event1/v6/imports </avro.imports.resources>
this list of excludes is:
{"**/PrivacyImport.avsc", "imports/**, imports/**"}
, so as explained above in case 1, the files with the name "PrivacyImport.avsc" in the directories "demo/imports/event/event1/v5/imports/entitites" and "demo/imports/event/event1/v6/imports/entitites" will be excluded.
Do you see it convenient to consider that in the exclusions the absolute name of the file or directory (with the path) is added instead of just the name?
Attached to the issue is a demo application that reproduces the problems explained.