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

fix(Spring CodeGen): Update missing and placeholder annotations #1045

Merged
merged 5 commits into from
Oct 4, 2022

Conversation

emmileaf
Copy link
Contributor

@emmileaf emmileaf commented Sep 27, 2022

In this PR:

  • Following feat(ast): extend support for annotation named parameters #1012,
    • updates annotation parameter placeholder strings in SpringAutoConfigClassComposer for parameters of type class
    • updates annotation parameter placeholder strings in SpringAutoConfigClassComposer for multiple parameters
    • adds @Qualifier annotations on variables
    • adds @NestedConfigurationProperty annotation on credentials field in SpringPropertiesClassComposer

@zhumin8 Do you have any preferences on whether I use this this branch/PR to also work on the other annotation TODOs in the code, or have the changes be separate for now? (Edit: will use this PR since they are pretty closely related) I also wasn't too sure what naming conventions to use for the variables, so would appreciate any feedback here as well.

Potential conflicts:
* With #1046 (Switching Spring dependencies from dynamic to static types)
* With #1044 (@Configuration(proxyBeanMethods = false) is no longer used in Spring Boot 2.7)

@conventional-commit-lint-gcf
Copy link

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@emmileaf emmileaf requested a review from zhumin8 September 27, 2022 20:56
Copy link
Contributor

@zhumin8 zhumin8 left a comment

Choose a reason for hiding this comment

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

LGTM! I just have two comments about reusing defined types.

  • About variable naming conventions, I think your naming looks good. I also try to spell-out the actual content as well as the ast type e.g. AssignmentExpr, and realize sometimes it can get quite long. In my draft code, you might still see some naming that's not comprehensive enough, feel free to change them. I will also try to do another cleanup later on.
  • On pr naming, @blakeli0 I've tried to follow "fix():...", "feat():..." but wonder if we have any guidelines on naming? Also, I'd like to add a "spring" label to these PRs if that does not interfere with any of the automated tasks?

@emmileaf emmileaf changed the title Update spring codegen annotations to use classes and parameters instead of strings Update spring codegen annotations Sep 28, 2022
@emmileaf emmileaf changed the title Update spring codegen annotations fix(Spring Codegen): Update missing and placeholder annotations Sep 28, 2022
@emmileaf emmileaf changed the title fix(Spring Codegen): Update missing and placeholder annotations fix(Spring CodeGen): Update missing and placeholder annotations Sep 28, 2022
@emmileaf
Copy link
Contributor Author

emmileaf commented Sep 29, 2022

Updated this PR with the requested changes as well as the two other annotation-related items. Also checked locally that there will be a couple of conflicts with both #1044 and #1046, so I’ll leave this PR open and resolve the conflicts once those two are merged into autoconfig-gen-draft2 (Edit: Likely merge order 1044 -> 1045 -> 1046, will resolve conflicts before merging this PR as needed)

@emmileaf emmileaf requested a review from zhumin8 September 29, 2022 13:13
@zhumin8 zhumin8 added the spring pr that's related to spring code gen, intend to merge into autoconfig-gen-draft2 branch. label Sep 29, 2022
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 10 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@emmileaf emmileaf marked this pull request as ready for review October 3, 2022 19:18
@emmileaf emmileaf requested review from a team as code owners October 3, 2022 19:18
Copy link
Contributor

@zhumin8 zhumin8 left a comment

Choose a reason for hiding this comment

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

Looks good!

@emmileaf emmileaf merged commit 9f44215 into autoconfig-gen-draft2 Oct 4, 2022
@emmileaf emmileaf deleted the autoconfig-gen-draft2-emmwang branch October 4, 2022 19:25
@@ -189,8 +190,9 @@ public void generatePropertiesTest() {
+ " @Bean\n"
+ " @ConditionalOnMissingBean\n"
+ " public EchoClient echoClient(\n"
+ " CredentialsProvider credentialsProvider,\n"
+ " TransportChannelProvider defaultTransportChannelProvider)\n"
+ " @Qualifier(\"googleCredentials\") CredentialsProvider credentialsProvider,\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Totally missed this: We want to add this @Qualifier so that when multiple services are present, there won't be conflict in which CredentialsProvider bean it takes. So need to rename googleCredentials() to [serviceName]Credentials() and match the name here. (same as defaultEchoTransportChannelProvider())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this - will address in a separate PR!

diegomarquezp pushed a commit that referenced this pull request Oct 22, 2022
* Updates annotation parameter placeholder strings in SpringAutoConfigClassComposer for parameters of type class
* Updates annotation parameter placeholder strings in SpringAutoConfigClassComposer for multiple parameters
* Adds @qualifier annotations on variables
* Adds @NestedConfigurationProperty annotation on credentials field in SpringPropertiesClassComposer
zhumin8 added a commit that referenced this pull request Nov 21, 2022
…tatic types instead of vapor references (#1046)

Adding Spring related dependencies to build files and use static types instead of vapor references. 
Benefit of this change:
- easier to test
- less code change needed for future changes (e.g. package change of classes).

One caveat is that because `gapic-generator-java` is brought into `googleapis` as `http_archive` code addition to `googleapis` is also needed to include these libraries. Add below code snippet to [WORKSPACE](https://github.com/googleapis/googleapis/blob/38e8b447d173909d3b2fe8fdc3e6cbb3c85442fd/WORKSPACE#L239-L245):
```
SPRING_MAVEN_ARTIFACTS = [
    "org.springframework.boot:spring-boot-starter:2.7.4",
    "com.google.cloud:spring-cloud-gcp-core:3.3.0",
]

maven_install(
    artifacts = PROTOBUF_MAVEN_ARTIFACTS + SPRING_MAVEN_ARTIFACTS,
    generate_compat_repositories = True,
    repositories = [
        "https://repo.maven.apache.org/maven2/",
    ],
)

```

------------
Updates:
- Updated pr with #1065, 
- Moved annotation classed added in #1045 to static types.
- Fixed conflicts from merged changes in #1093
- Moved logging classes added in #1053 to static types.
suztomo pushed a commit that referenced this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spring pr that's related to spring code gen, intend to merge into autoconfig-gen-draft2 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants