sbt-avrohugger
sbt-avrohugger copied to clipboard
A protocol file (.avdl) with only imports will fail to generate
I was getting the following error:
[error] .../ProtocolName.scala:4: expected class or object definition
[error] ()
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
An invalid file with the name of the protocol is generated. It contains only the namepace name and the problematic parentheses:
/** MACHINE-GENERATED FROM AVRO SCHEMA. DO NOT EDIT DIRECTLY */
package com.example
()
Using bin/avro-tools-1.8.1.jar
generate the protocol properly (for exemple to convert to .avsc), so it's not a syntax issue.
Then I had added a dummy error, to make sure the protocol had more than just records. After a sbt clean
the protocol then generated properly:
/** Include an dummy error, otherwise sbt-avrohugger will fail to generate the protocol */
error DummyError {
string message;
}
I'm using version 0.13.0.
Thanks for the report, @oliviertoupin.
I'm happy to fix this, but do you happen to have an example avdl that fails for you? Many of the current tests are in fact avdls with only records, and I'm unable to reproduce your error.
I just retested.
The problem here, is my "main.avdl", which is used to import all my records. Since it's only imports, I think it's considered empty.
I guess this issue should renamed: "A protocol file (.avdl) with only imports will fail to generate".
This works:
@namespace("com.example)
protocol ProtocolName {
import idl "A.avdl";
import idl "B.avdl";
import idl "C.avdl";
/** Include an dummy error, otherwise sbt-avrohugger will fail to generate the protocol */
error DummyError {
string message;
}
}
This doesn't:
@namespace("com.example)
protocol ProtocolName {
import idl "A.avdl";
import idl "B.avdl";
import idl "C.avdl";
}
I did test this previously, but forgot the clean, sorry.
Ok great, thanks for discovering this. I expect to have time to investigate a fix in the next couple weeks.
Hi there, to complement this issue : the same problem occurs when the protocol only contains enums.