Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A protocol file (.avdl) with only imports will fail to generate #33

Open
oliviertoupin opened this issue Jan 4, 2017 · 4 comments
Open

Comments

@oliviertoupin
Copy link

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.

@julianpeeters
Copy link
Owner

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.

@oliviertoupin
Copy link
Author

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.

@julianpeeters
Copy link
Owner

Ok great, thanks for discovering this. I expect to have time to investigate a fix in the next couple weeks.

@julianpeeters julianpeeters changed the title A protocol file (.avdl) with only records will fail to generate A protocol file (.avdl) with only imports will fail to generate Jan 5, 2017
@dmnpignaud
Copy link

Hi there, to complement this issue : the same problem occurs when the protocol only contains enums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants