Skip to content

Conversation

@emmileaf
Copy link
Contributor

@emmileaf emmileaf commented Oct 13, 2022

This PR updates and moves three pieces of naming-related logic in spring codegen into util methods:

  • getSpringPropertyPrefix (e.g. com.google.cloud.vision.v1.spring.auto.image-annotator)

    • Replaced earlier use of libname due to ambiguity (see comment)
  • getLibName (e.g. vision)

    • Intended for descriptive purposes
    • Includes three options considered by design doc - currently this PR implements option 2 (parse from package name) with the intention to switch to option 3 (parse from default host) in alignment with SampleGen
  • getSpringPackageName (e.g. com.google.cloud.vision.v1.spring)

    • Since this was also used in a couple of places, extracted to util in case of future need to update

Dependencies:

@emmileaf emmileaf added the spring pr that's related to spring code gen, intend to merge into autoconfig-gen-draft2 branch. label Oct 13, 2022
@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/

1 similar comment
@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
Copy link
Contributor Author

Two questions for perhaps an initial review related to the code changes here:

  1. Would we prefer to have this PR wait on the switch to parseDefaultHost in getLibName, or make the change later in a separate PR?
  2. I saw that the work in feat(Spring CodeGen): write pom.xml with SpringWriter. #1057 also needs things like the client library name (descriptive title vs. short name), group, and version. Would it make sense for these parsing logic (or at least the tentative version) to also be added under Utils?

In parsing version, for example, perhaps we could also align with SampleGen’s approach:https://github.com/googleapis/gapic-generator-java/blob/d222af10cd6345e0a3660353d7d667e917be67ec/src/main/java/com/google/api/generator/gapic/composer/Composer.java#L194-L205

@zhumin8
Copy link
Contributor

zhumin8 commented Oct 17, 2022

  1. I think it makes sense to make the change later in a separate PR, consider parseDefaultHost exposure may need to wait a bit.
  2. As for feat(Spring CodeGen): write pom.xml with SpringWriter. #1057, I would suggest you not to worry about it in this pr. I will align later in that pr separately when possible. The client library coordinates likely needs to be acquired outside of gapic-gen from sources like this metadata, and the library name in Spring Starter to produced can align with parseDefaultHost in getLibName.

@emmileaf
Copy link
Contributor Author

@zhumin8 Sounds good! In that case I’ll keep both items as out of scope for this PR and mark it ready for review.

(Side note for Sonar: the missing code coverage for these utils should improve after #1059 adds package info composer tests)

@emmileaf emmileaf marked this pull request as ready for review October 17, 2022 15:30
@emmileaf emmileaf requested a review from a team October 17, 2022 15:30
@emmileaf emmileaf requested a review from a team as a code owner October 17, 2022 15:30
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.

Just minor comments.

Utils.springPropertyPrefix(libName, service.name()),
libName + "/" + service.name())));
Utils.getSpringPropertyPrefix(packageName, service.name()),
Utils.getLibName(context))));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still want service.name() some where in the description, as this block is generated per service. So for client lib with multiple services like vision, description for enabling each service is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops - thanks for catching this!

JarEntry jarEntry =
new JarEntry(String.format("%s/additional-spring-configuration-metadata.json", path));
String libName = Utils.getLibName(context);
String packageName = context.services().get(0).pakkage();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do you mind also extract this to Utils? It's only one line, but just in case of future changes.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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

58.3% 58.3% Coverage
0.0% 0.0% Duplication

@emmileaf emmileaf requested a review from zhumin8 October 18, 2022 13:46
@emmileaf emmileaf merged commit 07dfa79 into autoconfig-gen-draft2 Oct 18, 2022
@emmileaf emmileaf deleted the autoconfig-naming branch October 18, 2022 14:37
zhumin8 added a commit that referenced this pull request Oct 26, 2022
This is a draft to generate pom.xml for Spring Starters modules. The placeholders in this generated file will be replaced in spring-cloud-gcp when triggering the generation (e.g. via script)

Update: updated to use utils added in #1061
We'll likely need to make more changes to pom generation depending on the project structure on spring-cloud-gcp side. But I'd like to merge this in first, and iterate as needed together with spring-cloud-gcp side.
suztomo pushed a commit that referenced this pull request Mar 21, 2023
… to v2.17.0 (#1061)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.errorprone:error_prone_annotations](https://errorprone.info) ([source](https://togithub.com/google/error-prone)) | `2.16` -> `2.17.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.errorprone:error_prone_annotations/2.17.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.errorprone:error_prone_annotations/2.17.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.errorprone:error_prone_annotations/2.17.0/compatibility-slim/2.16)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.errorprone:error_prone_annotations/2.17.0/confidence-slim/2.16)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>google/error-prone</summary>

### [`v2.17.0`](https://togithub.com/google/error-prone/releases/tag/v2.17.0): Error Prone 2.17.0

[Compare Source](https://togithub.com/google/error-prone/compare/v2.16...v2.17.0)

New Checkers:

-   [`AvoidObjectArrays`](https://errorprone.info/bugpattern/AvoidObjectArrays)
-   [`Finalize`](https://errorprone.info/bugpattern/Finalize)
-   [`IgnoredPureGetter`](https://errorprone.info/bugpattern/IgnoredPureGetter)
-   [`ImpossibleNullComparison`](https://errorprone.info/bugpattern/ProtoFieldNullComparison)
-   [`MathAbsoluteNegative`](https://errorprone.info/bugpattern/MathAbsoluteNegative)
-   [`NewFileSystem`](https://errorprone.info/bugpattern/NewFileSystem)
-   [`StatementSwitchToExpressionSwitch`](https://errorprone.info/bugpattern/StatementSwitchToExpressionSwitch)
-   [`UnqualifiedYield`](https://errorprone.info/bugpattern/UnqualifiedYield)

Fixed issues: [#&#8203;2321](https://togithub.com/google/error-prone/issues/2321), [#&#8203;3144](https://togithub.com/google/error-prone/issues/3144), [#&#8203;3297](https://togithub.com/google/error-prone/issues/3297), [#&#8203;3428](https://togithub.com/google/error-prone/issues/3428), [#&#8203;3437](https://togithub.com/google/error-prone/issues/3437), [#&#8203;3462](https://togithub.com/google/error-prone/issues/3462), [#&#8203;3482](https://togithub.com/google/error-prone/issues/3482), [#&#8203;3494](https://togithub.com/google/error-prone/issues/3494)

**Full Changelog**: https://togithub.com/google/error-prone/compare/v2.16...v2.17.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
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