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

[Java] internal config option to use jakarta or javax package #14310

Merged
merged 1 commit into from
Dec 30, 2022

Conversation

borsch
Copy link
Member

@borsch borsch commented Dec 21, 2022

Internal option to control whether javax or jakarta package should be used. This option will allow much easier transition to never version of dependencies with jakarta support.

Example - #14276 rest-template to be migrated to jakarta while other libraries might still use javax packages in common templates

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Java @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10)
Java Spring @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09)

@borsch borsch force-pushed the use-jakarta-package branch from 378fe94 to a2f8e66 Compare December 21, 2022 17:13
@borsch borsch marked this pull request as ready for review December 21, 2022 17:17
@@ -576,7 +576,8 @@ public void processOpts() {
// The flag below should be set for all Java libraries, but the templates need to be ported
// one by one for each library.
supportsAdditionalPropertiesWithComposedSchema = true;

setUseJakartaEe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the plan to expose the option to users via the cli? SpringCodegen has the useSpringBoot3 indirection, which triggers the use of Jakarta EE.

Copy link
Member Author

Choose a reason for hiding this comment

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

as for now this would be internal config option. later I want to use this config for changes like this one - #14276

rest-template to be migrated to spring 6 which means jakarta should be used, but on the other hand rest-template shares common model.mustache with other libraries which still should use javax package.

that's the reason why this config option is internal - developer of library's template is aware whether javax or jakarta package to be used

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, got it. But the default should then be false setUseJakartaEe(false), otherwise this PR would activate jakarta EE for all JavaClientCodegen implementations.

Copy link
Member Author

Choose a reason for hiding this comment

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

ahhh. got you question) expand this part of code and you will notice that this is only for jersey 3 which already use jakarta package. by default this option is set to false (i.e. we are using javax package)

@cachescrubber
Copy link
Contributor

@borsch Thanks for applying this to all Java based Codegen implementation. LGTM.

Copy link
Contributor

@welshm welshm left a comment

Choose a reason for hiding this comment

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

Some of the mustaches probably could have been left as-is if they can't support Jakarta anyway, but it doesn't hurt to have the configuration

@@ -576,7 +576,8 @@ public void processOpts() {
// The flag below should be set for all Java libraries, but the templates need to be ported
// one by one for each library.
supportsAdditionalPropertiesWithComposedSchema = true;

setUseJakartaEe(true);
applyJavaxPackage();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... if you did setUseJakartaEe() before the super call, then you wouldn't also need to call applyJavaxPackage(). But then you'd need to duplicate the if statement logic... maybe just some documentation?

// When using `setJakertaEe()` you should also call `applyJavaxPackage()` to capture the property value.

Copy link
Member Author

Choose a reason for hiding this comment

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

@welshm I've slightly changed approach, please review one more time

@borsch borsch force-pushed the use-jakarta-package branch from a2f8e66 to 94038f3 Compare December 23, 2022 21:46
@borsch
Copy link
Member Author

borsch commented Dec 30, 2022

@wing328 could you please merge this one? This will allow easier update to Spring 6 for some libraries

@@ -6455,7 +6455,7 @@ public boolean convertPropertyToBoolean(String propertyKey) {
return result;
}

public void writePropertyBack(String propertyKey, boolean value) {
public void writePropertyBack(String propertyKey, Object value) {
Copy link
Member

Choose a reason for hiding this comment

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

FYI @OpenAPITools/generator-core-team

@wing328 wing328 merged commit 7c587ce into OpenAPITools:master Dec 30, 2022
@@ -27,9 +27,9 @@ import java.io.IOException;
import java.io.InputStream;

import java.net.URI;
import javax.net.ssl.SSLContext;
Copy link
Contributor

Choose a reason for hiding this comment

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

javax.net.ssl package ist unaffected by Jakarta EE.
This change should be reverted.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for spotting. I've create PR for fix this #14341

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