julianpeeters / sbt-avrohugger

sbt plugin for generating Scala sources for Apache Avro schemas and protocols.
Apache License 2.0
133 stars 50 forks source link

added support for declaring imported schema files to load before other files #7

Closed rkoval closed 9 years ago

rkoval commented 9 years ago

Background

I'm working with an organization that generates POJOs for both Java and Scala applications. We have a handful of schema files defined, but some of them declare types to be used in other schema files. As such, these files need to be loaded first.

Motivation

On the Java side, we're using the Maven plugin to generate the files. This plugin has support for defining these sorts of imports, so we use that to circumvent this problem. I can't seem to find documentation on their main site for it, but this JIRA issue comment illustrates the usage on that end for that plugin.

This PR aims to replicate the above functionality in SBT, since it didn't seem like such functionality existed prior (though, see my PR comment below for something potentially related)

Feedback

Please let me know if you have any feedback on this to get it moving. I'd like to get this merged in and published out so that we can pull a more proper release from the project that has this functionality! Thanks!

rkoval commented 9 years ago

Also, how does one actually execute the test scripts within each of the SBT test sub-projects? I ended up having to manually invoke the commands for my new test and the existing tests because I hadn't seen constructs such as those before. I don't know how to automatically handle or invoke them.

julianpeeters commented 9 years ago

This is great. Yeah, that schema sorter is a little confusing, I agree. It was trying to handle your case too, but expected the type to be a fully qualified type instead of a namespace and simple type name. It was easy to fix though, and since it handles the imports automatically, was preexisting, and likely will be mirrored in sbt-avro, I reverted back to using it, while keeping your tests.

0.4.2 is up at Sonatype now, should be syncing with maven central in a few hours.

The tests in sbt-test are set up to use the scripted plugin, and can be run with sbt scripted.

I'm not familiar with KeyRank, or AminusSetting. What are those about?

It's great to finally match the maven plugin. Thanks again for straightening this out!

rkoval commented 9 years ago

I'm not familiar with KeyRank, or AminusSetting. What are those about?

They seem to just be used for displaying/sorting information in the SBT console. Code is here. I basically just copied the value for sourceDirectory in the default sbt.Keys object, as this use case seemed to be pretty closely related.

Otherwise, this sounds great! We'll sync up with the new version. Thanks for the promptness in getting this merged back in!