collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
908 stars 102 forks source link

Refactor com.riiablo.excel to use annotation processors #135

Open collinsmith opened 3 years ago

collinsmith commented 3 years ago

This seems like the most appropriate way to handle generating the excel table serializers, however I've had a lot of trouble trying to decouple the com.riiablo.excel hierarchy to support this. The excel table code generation depends on the excel classes, while the serializer generation depends on com.riiablo.io. project(':core') cannot act as it's own annotation processor because that creates a circular dependency (can't process itself if it needs itself to annotate process itself).

Long story short, I'm abandoning this complication for the time being and moving to an automated dependency-driven gradle task. I think implementing this feature will require thought and refactoring to the core classes com.riiablo.excel.Excel, com.riiablo.excel.TxtParser, and com.riiablo.excel.Serializer.

http://hannesdorfmann.com/annotation-processing/annotationprocessing101

collinsmith commented 3 years ago

Thinking about this issue a bit more, I think it may not be as difficult as I previously thought. I may be able to stub out the dependent classes in the project if I cannot specify them as strings. E.g., create a com.riiablo.io.ByteInput class within :annotation-parser module used for generating code. The Excel class dependencies may be more difficult if their functionality is required.

collinsmith commented 3 years ago

Implemented as com.riiablo.table package within project(':table').subprojects. Merged back into master so that this project may be shelved for a bit without falling egregiously behind. com.riiablo.excel contains the previous iteration which is basically a step above com.riiablo.codec.excel, but not nearly as refined. project(':excel').subprojects projects contain dependency issues, but the code is still kept until :table is complete. I decided to veer away from naming tables excel because it didn't really fit -- new terms are Table, Schema, Record -- more DB-friendly terms.

collinsmith commented 3 years ago

Caching is not enabled causing the annotation processor task to run on every build. I've decided to disable it in :core and exclude com.riiablo.table.*.** from compilation in the meantime until I decide to move forward with properly implementing support for this feature.