You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Tom White (JIRA)" <ji...@apache.org> on 2012/11/09 12:30:13 UTC

[jira] [Reopened] (AVRO-983) maven-avro-plugin: Allow maven schema compiler to support external reference in an another avro schema file

     [ https://issues.apache.org/jira/browse/AVRO-983?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tom White reopened AVRO-983:
----------------------------


I just reverted this as it breaks the build. The IPC module doesn't build with this change since it defines multiple schemas containing an MD5 type, and these clash causing the compilation to fail. For this reason we shouldn't include the patch in a bugfix release since it is potentially incompatible.
                
> 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