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

add a module for Spring Boot 3 AOT #2457

Merged
merged 6 commits into from
Dec 2, 2022

Conversation

joshlong
Copy link
Contributor

this supercedes my last PR. in this example I've preserved Spring Framework 5 / Spring Boot 2 / Java 8 support in the client-java-spring-integration module, adding only one text file for Spring Boot 3 support.

I've also created a new module, client-java-spring-aot-integration, that contributes GraalVm hints using Spring Boot 3's AOT engine. This module depends on Spring Framework 6 / Spring Boot 3 / Java 17 / the third party Reflections library.

I've built a trivial controller here https://github.com/kubernetes-native-java/controllers-101 and linked it against the -aot module in this PR, and it works :)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 22, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 22, 2022
return (generationContext, beanFactoryInitializationCode) -> {
RuntimeHints hints = generationContext.getRuntimeHints();
String[] classNames = new String[]{
"com.google.gson.JsonElement",//
Copy link
Member

Choose a reason for hiding this comment

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

these class names need to be secured by unit-test, in case the linked classes are renamed/moved in the future. we can do this in a follow-up.

<!--
todo : we don't need this after 24 november, 2022
-->
<repositories>
Copy link
Member

Choose a reason for hiding this comment

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

nit:how about we lift/centralize these repository declarations to the parent pom?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they won't be required after the 24th. no need to add them at all, afaict

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wait until after the 24th and get these removed.

<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
Copy link
Member

Choose a reason for hiding this comment

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

nit: move the versioned dependency to the parent pom and let the children modules inherit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea

Copy link
Member

@yue9944882 yue9944882 left a comment

Choose a reason for hiding this comment

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

can you run the formatter so that Verify Source Format job can pass?

@yue9944882
Copy link
Member

@joshlong the new module will block the compilation of test jobs running on platforms older than java17, i think we need to explicitly exclude spring-aot from these compatibility tests (e.g. either by setting --pl "!spring-aot" when running maven cmd or declaring a new profile in the parent pom). and then we need to copy/paste a separate test job for coveringspring-aot on java17 platform from the existing ones. i opened #2459 to show the expected edits on the github action configurations, can you incorporate/rebase the pull?

@joshlong
Copy link
Contributor Author

joshlong commented Nov 22, 2022

can you run the formatter so that Verify Source Format job can pass?

what formatter?

@joshlong
Copy link
Contributor Author

ive addressed most of the issues, i think. i hope this works :) I think you mean mvn spotless:apply for the formatted, but I'm not sure. i ran that, tho.

@@ -22,12 +22,34 @@ jobs:
java-version: 8.0.x
- name: Verify Format and License
run: mvn spotless:check
legacy-build:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd really rather not maintain two different build targets, it's a recipe for drift and cut/paste errors.

Is there a way that we can combine them together with a conditional depending on the java version, that should be possible.

Copy link
Member

Choose a reason for hiding this comment

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

sure they can be merged into one conditional target, i updated #2459 to show how it works. @joshlong by any chance can you rebase again onto my latest commit?

pom.xml Outdated
@@ -561,5 +562,21 @@ limitations under the License.
<module>fluent-gen</module>
</modules>
</profile>
<profile>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if it is possible in a pom, but is there a way to inherit this? I'd really prefer to avoid duplication if we can avoid it.

Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure about that, now it's already declared in the root-level pom. as far as i know, it's not inheriting from any other project/places.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.0.0-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we wait until this is released, I'd rather not depend on a snapshot version.

Copy link
Contributor Author

@joshlong joshlong Nov 23, 2022

Choose a reason for hiding this comment

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

Absolutely ;) that'll be on Thursday this week. Happy thanksgiving if you celebrate! I am certainly grateful for everything y'all are doing in this great project

Copy link
Member

Choose a reason for hiding this comment

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

let's switch to non-snapshot release after that

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

pull this version up to the parent pom (this may be a problem in all of our poms...)

@yue9944882
Copy link
Member

I think you mean mvn spotless:apply for the formatted

@joshlong exactly, looks like all the tests passed now

@joshlong
Copy link
Contributor Author

Hi - i just updated the PR to use Spring Boot 3 GA! Happy day!

The PR removes all mentions of snapshots and snapshot repositories. I also avoid redundantly declaring the Spring Boot BOM in the child module, overriding the spring-boot.version property instead.

Also, I am not sure if this was intentional or if I missed something in my earlier PR, but I noticed that the spring-aot module wasn't among those enumerated in the <modules> section in the top-most pom.xml so I added that.

@yue9944882 yue9944882 force-pushed the boot3-aot branch 2 times, most recently from b859f45 to 985765a Compare November 28, 2022 05:17
Signed-off-by: yue9944882 <291271447@qq.com>
mvn clean test -q -B --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
if [ $(grep -E '^(8|11)\.' <<< '${{ matrix.java }}') ]; then
# some module doesn't compile on java platform lower than 17, need to skip them by specifying a profile
MODS_OVERRIDES='-pl !spring-aot'
Copy link
Member

Choose a reason for hiding this comment

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

excluding spring-aot for java8 and java11 build ^^^

@yue9944882
Copy link
Member

@brendandburns @joshlong i appended another commit to this thread so that the test workflow can pass after we bump java version to 17. the java 8/11 compatibility is meanwhile assured by #2457 (comment)

@joshlong
Copy link
Contributor Author

whats the next step?

@yue9944882
Copy link
Member

@joshlong it looks like https://github.com/kubernetes-client/java/pull/2457/files#r1029896501 hasn't been resolved yet, can you move the plugin declaration to the root?

@joshlong
Copy link
Contributor Author

joshlong commented Dec 1, 2022

@joshlong it looks like https://github.com/kubernetes-client/java/pull/2457/files#r1029896501 hasn't been resolved yet, can you move the plugin declaration to the root?

Hi - what version? The spring.boot.version? We don't want the global version to be 3.0, right? we need 2.x for everything except this module. (or am I missing something?)

and the rest of the XML in that pom.xml is just a copy and paste of whatever is in your other pom.xml. I'm happy that this PR is contributing to the discussion around healthy refactorings to your build structure, but it's above my paygrade :) please do whatever you need to do to the build so that you're happy, I just want to see this thing merged so I can stop worrying about it. it's been many months, after all, since this discussion started.

@yue9944882
Copy link
Member

and the rest of the XML in that pom.xml is just a copy and paste of whatever is in your other pom.xml

i think @brendandburns is talking about the version of the jacoco plugin, but yeah there're some other pom.xml duplicating the plugin declaration. we can lift them to the parent pom through out the project in a follow-up.

Copy link
Member

@yue9944882 yue9944882 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

ready to merge it, before that holding this pull a few days if @brendandburns has additional review comments

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 2, 2022
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 2, 2022
@brendandburns brendandburns removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 2, 2022
@brendandburns
Copy link
Contributor

/lgtm
/approve

We can do the pom cleanup in a different PR.

@joshlong it would be great if we could get your example controller merged into the examples directory.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, joshlong, yue9944882

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [brendandburns,yue9944882]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit ce32410 into kubernetes-client:master Dec 2, 2022
@joshlong
Copy link
Contributor Author

joshlong commented Dec 5, 2022

I'll get the example controller cleaned up and send a separate PR.

It was a lot of fun working with y'all so far. Thanks for allowing me the opportunity to contribute, even if ever so slightly, to your much-appreciated efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants