Skip to content

Conversation

@Asger-KB
Copy link

I wanted to use Lombok for the generated classes (via Annox)

bindings.xjb

<jaxb:bindings
    xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:annox="urn:jaxb.jvnet.org:annox"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jaxb https://jakarta.ee/xml/ns/jaxb/bindingschema_3_0.xsd"
    jaxb:extensionBindingPrefixes="xjc annox"
    version="3.0">
  <jaxb:bindings schemaLocation="scheam.xsd">
    <jaxb:bindings node="//xs:complexType" multiple="yes">
        <annox:annotateClass>@lombok.Data</annox:annotateClass>
        <annox:annotateClass>@lombok.With</annox:annotateClass>
        <annox:annotateClass>@lombok.AllArgsConstructor</annox:annotateClass>
        <annox:annotateClass>@lombok.NoArgsConstructor</annox:annotateClass>
    </jaxb:bindings>
  </jaxb:bindings>
</jaxb:bindings>

This worked, but the generated classes still contained jaxb-produced getter/setters methods. I wanted to be able to generate classes without these methods, so I made these two plugins noGetters and noSetters

@Asger-KB
Copy link
Author

Asger-KB commented Oct 31, 2025

The "@Asger-KB Asger-KB force-pushed the master branch from 6b5120d to 2974f09" was just me signing the commit...

@rawvoid
Copy link

rawvoid commented Dec 2, 2025

Hi,

I just came across this PR #654 – “Plugin to remove java bean methods for when you want to use Lombok or similar” – and I’m really excited about this feature!

We’ve been looking for a clean way to combine JAXB code generation with Lombok (or records/immutables) in several projects, and this plugin would solve a long-standing pain point perfectly.

Would it be possible to review and hopefully merge this contribution? It would be a huge help for the community, and I’d be more than happy to help test it or provide any additional feedback if needed.

Thank you so much for the amazing work on jaxb-tools – it’s still an indispensable tool in 2025!

Best regards,

@mattrpav
Copy link
Collaborator

mattrpav commented Dec 2, 2025

@calmlaw agreed! The 'jaxb' part is almost secondary.. the value in the tools is for managing models across domains and providing consistent capabilities.

The record support probably needs to originate in Eclipse Jakarta jaxb-ri project.

@laurentschoelens would be able to help provide more insight as well.

Thanks!

List<String> lines = Files.readAllLines(javaFile);
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i);
if (line.matches("^ *public [a-zA-Z]+ (isSet|get)[A-Z]\\w+\\(\\) \\{")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't isSet just be is ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSet is only to check for list fields.
I guess is should be enough but if we only want to target getters and setters, my best bet would be to find them according properties of the bean ?

@laurentschoelens
Copy link
Collaborator

@Asger-KB : wouldn't be a better option to have specific plugin to handle lombok generation ?
It would handle all the necessary code to add annotations and remove getters / setters ?

@mattrpav
Copy link
Collaborator

mattrpav commented Dec 3, 2025

Removing getters and setters could be used in combo with Fluent API plugin and not with Lambok

@laurentschoelens
Copy link
Collaborator

Removing getters and setters could be used in combo with Fluent API plugin and not with Lambok

fluent-api is the withXXX plugin ?

@mattrpav
Copy link
Collaborator

mattrpav commented Dec 4, 2025

Yes, fluent-api plugin adds the with* methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants