Open asm0dey opened 1 year ago
I performed some best-effort migration from the plain-text generated code to KotlinPoet, which allowed me to avoid some annoying bugs (for example, in some schemas (atom), base
and type
were duplicated many-many times and also some functions were duplicated).
Tests do not pass, but I believe that the result is equivalent. However, it's up to you to check the correctness.
You can see results in my fork repository: https://github.com/asm0dey/kotlin-xml-builder/blob/main/kotlin-xml-dsl-generator/src/main/kotlin/org/redundent/kotlin/xml/gen/DslGenerator.kt
Hi, I've been meaning to switch to using KotlinPoet for a while so thanks for getting that started. I'll take a look at your fork and see how it goes
I've also added a dependency on jing because otherwise generate doesn't work with (some) RelaxNG schemas
This is proving to be more of a nightmare than I hoped. Turns out I never published the dsl builder library to Maven Central after jcenter went offline so I'm having to set all that up again.
Do you need help? I have experience with it, can help with GH Actions, for example, you'll only need to put your gpg private key, password and id into GH Secrets
No, I can handle it. Thanks for the offer though. I just need to find the time to deal with getting it all sorted. I'm hoping to have some time this weekend to get it going.
If anything, here is the example with all the modern best practices: https://github.com/asm0dey/dummylib-multiplatform/blob/main/convention-plugins/src/main/kotlin/module.publication.gradle.kts
Here it's used for a KMP project, but the same approach can be used for JVM.
And here is the deployment action: https://github.com/asm0dey/dummylib-multiplatform/blob/main/.github/workflows/deploy.yml
I just published v1.9.0 of the kotlin-xml-dsl-generator which contains the fix for incorrect code generation. I have a ton of stuff to clean up in the repo and I didn't touch the kotlinpoet changes yet. I will do that soon.
Awesome! If you want, I can submit a PR, just briefly describe your desired result
Thanks but I'll take care of it. While fixing the attribute issue, I noticed how much of an embarrassing mess that code was an now I just want to set it on fire and rewrite it all.
If you need any help - I'm here for you!
Hi there!
the generator generates code like
but
attributes
is a read-only map, so setters can't be delegated there. One possible solution is to rewrite it like this:but it is also flawed since does not support attribute namespaces. Probably there should be a map storing attribute-namespace relation and then it could be used like