Skip to content
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

-Xfluent-builder is not supported #508

Closed
Vishal-Joshi opened this issue Feb 20, 2024 · 7 comments
Closed

-Xfluent-builder is not supported #508

Vishal-Joshi opened this issue Feb 20, 2024 · 7 comments
Assignees
Labels
question xjc-plugins Issue concerns basics plugins

Comments

@Vishal-Joshi
Copy link

I used to use org.jvnet.jaxb2.maven2:maven-jaxb2-plugin v0.14.0 to create builders in generated classes using -Xfluent-builder

However, when I switch to org.jvnet.jaxb:jaxb-maven-plugin v2.0.9 the argument -Xfluent-builder is not supported.
I tried using the -Xfluent-api as mentioned here https://github.com/highsource/jaxb-tools/wiki/JAXB2-Fluent-API-Plugin
but that generates the with* methods and not Builder in the generated class.

Are builders not supported anymore?

@laurentschoelens
Copy link
Collaborator

laurentschoelens commented Feb 20, 2024

Hi @Vishal-Joshi

Could you share a code sample of expected ?

I've created test project (that I'll push in next v4) and generated code is like :

public Address withStreet(String value) {
  setStreet(value);
  return this;
}

public Address withNumber(int value) {
  setNumber(value);
  return this;
}

So you can chain code like

Address a = new Address().withStreet("MyStreet").withNumber(10);

@laurentschoelens laurentschoelens self-assigned this Feb 20, 2024
@laurentschoelens laurentschoelens added question xjc-plugins Issue concerns basics plugins labels Feb 20, 2024
@laurentschoelens
Copy link
Collaborator

Moreover, could you tell me from where the -Xfluent-builder arg came from ? Which xjc plugin ? Thanks

laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Feb 20, 2024
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Feb 20, 2024
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Feb 21, 2024
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Feb 21, 2024
@Vishal-Joshi
Copy link
Author

Vishal-Joshi commented Feb 23, 2024

Hi @laurentschoelens
-Xfluent-builder from org.jvnet.jaxb2.maven2:maven-jaxb2-plugin v0.14.0 would created a builder method in the unmarshalled class from xml. It is the implementation of builder pattern

A sample class would invocation would look like,

FactSet factSet = FactSet.builder()
                    .withFact(builder().withType("type1").build(), builder().withType("type2").build())
                    .build();

where FactSet was an unmarshalled class from a given xml. The builder() and build() were added by the jaxb plugin's xjc implementation

@laurentschoelens
Copy link
Collaborator

Thanks but the Xfluent-builder does not came from here. Could you share sample pom.xml config ?

@laurentschoelens
Copy link
Collaborator

laurentschoelens commented Feb 24, 2024

One option I'm thinking of is that the xjc plugin responsible of handling Xfluent-builder is defined in parent pom.xml in plugin / pluginManagament configuration with the older coordinates (org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0) but since you move to the newest version of jaxb-tools for jaxb2 (2.0.9), the configuration is no more inherited from parent.

I'm also pretty sure you are using the following library : https://github.com/mklemm/jaxb2-rich-contract-plugin which refers to same configuration as yours.

I'll try to contact or propose PR to update documentation according to latest version of jaxb-tools.

@laurentschoelens
Copy link
Collaborator

Feel free to reopen issue if you still have problems, providing more details. Thanks
FI : 4.0.0 of net.codesup.util:jaxb2-rich-contract-plugin has just been released, with support of JAXB4
It should take a few hours before getting to maven-central

@mklemm
Copy link

mklemm commented May 2, 2024

Because the plugin doesn't support JAXB 2 anymore, the "2" has been removed from the artifactId. It's called:
net.codesup.util:jaxb-rich-contract-plugin:4.2.0.0 now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question xjc-plugins Issue concerns basics plugins
Projects
None yet
Development

No branches or pull requests

3 participants