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

Doug Cutting commented on AVRO-983:
-----------------------------------

The "include" approach of AVRO-1188 would be back-compatible, since folks would 
need to opt-in.
                
> maven-avro-plugin: Allow maven schema compiler to support external reference 
> in an another avro schema file
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-983
>                 URL: https://issues.apache.org/jira/browse/AVRO-983
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.6.1
>            Reporter: Cédric Torcq
>            Assignee: Tom White
>         Attachments: AVRO-983.patch, AVRO-983.patch, SchemaMojo.java.patch
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> Avro Maven plugin doesn't support an external reference in an another Avro 
> schema file even this schema is available in the same src directory
> Example :
> {code:javascript} 
> [
>       {
>               "namespace": "com.afklm.karma.demand.inter",
>               "name": "DatedFlightLegInterType",
>               "type": "record",
>               "fields":
>                       [
>                               { "name": "legOrgArp", "type": "string" },
>                               { "name": "legDestArp", "type": "string" },
>                               { "name": "legDepDate", "type": "long" },
>                               { "name": "flightNb", "type": "string" },
>                               { "name": "dfl", "type": 
> "com.afklm.karma.demand.output.DatedFlightLegType" }
>                       ]
>       },
>       {
>               "namespace": "com.afklm.karma.demand.inter",
>               "name": "AirportAirportDatedFlightLegInterType",
>               "type": "record",
>               "fields":
>                       [
>                               { "name": "aa", "type": 
> "AirportAirportInterType" },
>                               { "name": "legOrgArp", "type": "string" },
>                               { "name": "legDestArp", "type": "string" },
>                               { "name": "legDepDate", "type": "long" },
>                               { "name": "flightNb", "type": "string" }
>                       ]
>       }
> ]
> {code} 
> generate a fatal error :
> {code} 
> org.apache.avro.SchemaParseException: 
> "com.afklm.karma.demand.output.DatedFlightLegType" is not a defined name. The 
> type of t
> he "dfl" field must be a defined name or a {"type": ...} expression.
>         at org.apache.avro.Schema.parse(Schema.java:1131)
>         at org.apache.avro.Schema.parse(Schema.java:1200)
>         at org.apache.avro.Schema$Parser.parse(Schema.java:968)
>         at org.apache.avro.Schema$Parser.parse(Schema.java:945)
>         at org.apache.avro.mojo.SchemaMojo.doCompile(SchemaMojo.java:58)
>         at 
> org.apache.avro.mojo.AbstractAvroMojo.compileFiles(AbstractAvroMojo.java:137)
>         at 
> org.apache.avro.mojo.AbstractAvroMojo.execute(AbstractAvroMojo.java:107)
> {code}
> I propose a patch to support also this case :
> In org.apache.avro.mojo.SchemaMojo (line 55):
>               // File src = new File(sourceDirectory, filename);
>               // Schema.Parser parser = new Schema.Parser();
>               // Schema schema = parser.parse(src);
>               // SpecificCompiler compiler = new SpecificCompiler(schema);
>               // compiler.setTemplateDir(templateDirectory);
>               // compiler.setStringType(StringType.valueOf(stringType));
>               // compiler.compileSchema(src,
>               // outputDirectory);
>               
>               
>         DirectoryScanner scanner = new DirectoryScanner();
>         scanner.setBasedir(sourceDirectory);
>         scanner.setIncludes( getIncludes() );
>         scanner.addDefaultExcludes();
>         scanner.scan();
>         File[] avroFiles = new File[scanner.getIncludedFiles().length];
>         for (int i = 0; i < avroFiles.length; i++) {
>               avroFiles[i] = new File( scanner.getBasedir(), 
> scanner.getIncludedFiles()[i] );
>               }
>         SpecificCompiler.compileSchema(avroFiles, outputDirectory);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to