-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use APT to generate code on compilation #14827
Comments
@gzsombor : it's an important subject, so you should post a mail to the mailing list and mention this ticket. It needs to be discussed before doing something |
Do I hear xdoclet revival? We may still have templates for it somewhere. Actually not having those code under version control is a great idea |
This issue is stale because it has been open 30 days with no activity. |
Lets reopen, I've started working on this ... |
Have we considered use of Java |
Yes, definitely. I'm not sure what kind of customization could be feasible, I would really like to have the possibility to even extend the logic by anyone. But I'm a bit concerned the classloading issues on source generation. |
This issue is stale because it has been open 30 days with no activity. |
@gzsombor, what is the current status? Are you still available to create a PR? |
This issue is stale because it has been open for too long without any activity. |
Overview of the feature request
As JHipster generates lots of boilerplate source code, which could be intimidating or annoying - especially for entities with long list of fields (for DTOs, Criteria objects, etc...), and with MapStruct or the Hibernate Static Metamodel generator it is a proven path to reduce the repetitiveness, I'm suggesting to use APT to generate part of our code on compilation instead of project setup/re-generation.
Motivation for or Use Case
DTOs and Criteria objects are really long and boring code, and most of the cases it's just waste - for example adding 5 fields to an entity, currently result in a lot of changes in the generated code, and reviewing these changes are annoying - easy to miss the important changes. The other problem which I regularly face, is that after a generated project matures a bit, using the current JHipster generators to add new fields, or regenerate the project is much bigger task that used to be. (Because the customization is everywhere, for example having a @Version field, which needs special handling, or custom field types...)
My idea is to develop annotations and annotation processing tools to improve the situation.
Imagine, for a starter, instead of generating all the DTOs and criteria objects, on your entity you could write:
And you would get a com.mypackage.dto.MyEntityDetailedDTO with all the fields from MyEntity, minus the version and 'otherEntities', but a String someValue is added, and all the UUID fields are mapped to String.
If someone needs to customize the generated code, they could easily do it, with copying the generated source to in their source folder, and remove the annotation. Or if it's enough, they can just extend the generated java class in their project.
With this annotation based approach we wouldn't need to maintain the separate UserDTO templates anymore, I believe.
Related issues or PR
I'm sure, there were tickets about the huge amounts of code generated ...
The text was updated successfully, but these errors were encountered: