-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow extra avsc
file includes
#36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @RustedBones any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the issue is more due to the usage of 2 separate parsers in the compileAvroSchema
steps. Reusing the instance will grant access to the external types in the module.
I wanted 1st to merge the 2 compileAvroSchema
into one single step but the custom avroUseNamespace
made it hard to achieve. I think we should prefer this way though.
src/main/scala/sbtavro/SbtAvro.scala
Outdated
compileAvroSchema(externalSrcDir, outDir, out.log, strType, fieldVis, enbDecimal, useNs, builder) | ||
compileAvroSchema(srcDir, outDir, out.log, strType, fieldVis, enbDecimal, useNs, builder) | ||
compileAvroSchema(externalSrcDir, outDir, Seq.empty, out.log, strType, fieldVis, enbDecimal, useNs, builder) | ||
compileAvroSchema(srcDir, outDir, includes, out.log, strType, fieldVis, enbDecimal, useNs, builder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won 't we compile the include - avroUnpackDependencies / target
twice with this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. See #36 (comment) for a suggestion on how to avoid having this problem by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cacheCompile
below needs to be updated with the includes folder
I went with the additional includes approach because
The ability to extract avsc files from I think to make this change as non-disruptive as possible I would rather simply not add Wdyt? |
84d5181
to
ec8312e
Compare
By default include nothing.
ec8312e
to
1c0f4a7
Compare
Hey @RustedBones, I have updated the PR. Can you have another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look to flix-tech#2.
I tried to factorize code so only one schema builder is used for all src / unpacked / includes folder
Looks great :) Shall I cherry-pick your commit onto this PR? |
@ojung you can merge the PR into your branch, it will update here. |
b8b2cb9
to
1c0f4a7
Compare
Ok, merged in your commit. |
Hey 👋
We have a use case where we want to import 3rd party
avsc
files into our schemas to be able to reference the types defined inside. Since the avro library dependencies (avroUnpackDependencies
/target
) were compiled independently of theavroSource
files, this was not possible.This PR allows specifying additional
avroIncludes
and addsavroUnpackDependencies
/target
by default.The behavior (apart from the default of
avroUnpackDependencies
/target
) is similar to theavro-maven-plugin
, where you can specify extra imports explicitly.