yahoo / squidb

SquiDB is a SQLite database library for Android and iOS
https://github.com/yahoo/squidb/wiki
Apache License 2.0
1.31k stars 132 forks source link

Use JavaPoet for the code generator [4.0] #259

Closed sbosley closed 7 years ago

sbosley commented 7 years ago

My old apt-utils library is sort of klugey and a pain to maintain. Square's JavaPoet is the new hotness, has an awesome API, and is actively under development. Let's use it instead!

This PR rewrites the entirety of the code generator to use javapoet instead of apt-utils. Most notably, this changes the plugin API in some pretty significant ways. JavaPoet prefers building up an entire specification of the generated class before writing code, so as such the "before/after" hooks don't apply in quite the same way since JavaPoet determines the ultimate order in which things in the spec are written to the generated class. Fortunately they choose a pretty reasonable ordering, so with some good use of static initializers we can get essentially the same behavior that we had with our old "append as you go" approach.

This is a big change, but JavaPoet is awesome and way more powerful than apt-utils ever was, so I think it'll let us do even more cool things going forward. In the most immediate future I'm hoping it will help support adding nullability annotations to our generated code.

jdkoren commented 7 years ago

LGTM