Skip to content

feat(internal/container/java): generate pom.xml files#2682

Merged
meltsufin merged 3 commits intomainfrom
java-pom
Oct 27, 2025
Merged

feat(internal/container/java): generate pom.xml files#2682
meltsufin merged 3 commits intomainfrom
java-pom

Conversation

@meltsufin
Copy link
Copy Markdown
Member

Add creation of pom.xml files for the generated Java client libraries. We assume that the google-cloud-pom-parent and google-cloud-jar-parent are published from a separate repository. For now, the version is hard-coded in the templates. The intent here is that we will no longer have to distinguish between libraries in the monorepo vs split repos in terms of parent poms.

run-genrate-library.sh is also updated to not only generate the sample library, but to build it as well.

Fixes #2657

…ibraries

Add creation of `pom.xml` files for the generated Java client libraries.
We assume that the `google-cloud-pom-parent` and `google-cloud-jar-parent` are published from a separate repository. For now, the version is hard-coded in the templates.

`run-genrate-library.sh` is also updated to not only generate the sample library, but to build it as well.

Fixes #2657
@meltsufin
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the functionality to generate pom.xml files for Java client libraries, which is a great step towards standardizing the build process for both monorepo and split-repo libraries. The implementation uses Go templates to create the various pom.xml files (parent, BOM, proto, gRPC, and the main library). The accompanying tests with golden files are well-structured and provide good coverage for the new functionality.

I've identified a few areas for improvement in the pom.go file related to efficiency and code consistency. These suggestions aim to reduce redundant operations and improve maintainability. Overall, this is a solid contribution.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 89.61039% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.94%. Comparing base (2d86463) to head (2b79c9f).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/container/java/pom/pom.go 90.78% 7 Missing and 7 partials ⚠️
internal/container/java/generate/generator.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2682      +/-   ##
==========================================
+ Coverage   86.80%   86.94%   +0.14%     
==========================================
  Files         117      118       +1     
  Lines        9631     9911     +280     
==========================================
+ Hits         8360     8617     +257     
- Misses        903      915      +12     
- Partials      368      379      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@meltsufin meltsufin marked this pull request as ready for review October 27, 2025 18:39
@meltsufin meltsufin requested a review from a team as a code owner October 27, 2025 18:39
@meltsufin meltsufin requested a review from suztomo October 27, 2025 18:39
suztomo
suztomo previously approved these changes Oct 27, 2025
@suztomo
Copy link
Copy Markdown
Member

suztomo commented Oct 27, 2025

I asked Gemini about special cases:

  • java-iam: The directory is java-iam, but the artifactId in its pom.xml is google-iam-policy. The iam part matches, but the artifactId has the -policy suffix that is not in the
    directory name.
  • java-accesscontextmanager: The directory is java-accesscontextmanager, but the artifactId is google-identity-accesscontextmanager-parent. The directory is missing the identity
    part.
  • java-iam-admin: The directory is java-iam-admin, but the artifactId is google-iam-admin-parent. The directory is missing the google part.

I believe the current logic misses the "google-maps-" and "google-shopping-" artifacts.

@meltsufin
Copy link
Copy Markdown
Member Author

I asked Gemini about special cases:

  • java-iam: The directory is java-iam, but the artifactId in its pom.xml is google-iam-policy. The iam part matches, but the artifactId has the -policy suffix that is not in the
    directory name.
  • java-accesscontextmanager: The directory is java-accesscontextmanager, but the artifactId is google-identity-accesscontextmanager-parent. The directory is missing the identity
    part.
  • java-iam-admin: The directory is java-iam-admin, but the artifactId is google-iam-admin-parent. The directory is missing the google part.

I believe the current logic misses the "google-maps-" and "google-shopping-" artifacts.

Thanks for pointing these out, but I would like to deal with the special cases separately from this PR.

@meltsufin meltsufin merged commit 50b95f2 into main Oct 27, 2025
8 checks passed
@meltsufin meltsufin deleted the java-pom branch October 27, 2025 20:46
ldetmer added a commit that referenced this pull request Nov 6, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: not available
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest
<details><summary>librarian: 1.0.0</summary>

##
[1.0.0](v0.5.0...v1.0.0)
(2025-11-06)

### Features

* Remove `..._gax` dependency (#2713)
([01675b7](01675b72))

* add context to Librarian PRs (#2698)
([0523329](0523329a))

* add a package comment linter (#2712)
([1bd3e32](1bd3e32e))

* generate pom.xml files (#2682)
([50b95f2](50b95f20))

* add test-container test logic (#2656)
([514cf7e](514cf7e5))

* improve rust-publish logging (#2671)
([585ed50](585ed50b))

* write a timing log at the end of update-image (#2771)
([5fc9e3b](5fc9e3b6))

* migrate Java container from sdk-platform-java (#2670)
([69ac47f](69ac47fd))

* switch to original head after running update-image (#2696)
([7a3e404](7a3e404a))

* format bulk commit from other sources in release notes (#2665)
([7c52da2](7c52da2b))

* enable multi-version API generation (#2699)
([86c5250](86c52507))

* release stage to update pom.xml files (#2772)
([be56755](be567550))

* use proto presence info to generate null-safe code (#2726)
([e36fb81](e36fb81a))

* Base messages in google_cloud_protobuf (#2660)
([e607ea6](e607ea63))

### Bug Fixes

* retry Github 503 requests up to 3 times (#2650)
([09468fa](09468faf))

* Changed docs to ConfigurationException (#2697)
([0950c1e](0950c1e3))

* fix the reference to the old &#34;librariangen&#34; folder (#2677)
([09dc53f](09dc53fe))

* run godoclint via golangci-lint (#2751)
([264a6a0](264a6a0e))

* pass context as the first argument (#2769)
([298a3bd](298a3bd8))

* Move HTTP client creation to `_gax` (#2672)
([4968d63](4968d63d))

* deduplicate bulk commits (#2758)
([4dfae9a](4dfae9ae))

* Support additional api paths for an existing library (#2666)
([50046f5](50046f55))

* remove stray TODO (#2748)
([5072f0e](5072f0e0))

* omit status field when empty (#2654)
([572ae4f](572ae4f3))

* use T.Context in tests (#2768)
([7e7cd2d](7e7cd2dd))

* wrap error to provide more context for commitAndPush (#2767)
([a2a41a4](a2a41a4a))

* use t.Fatal in tests for proper failure handling (#2759)
([cdabb28](cdabb287))

* enforce removal before copying library files (#2765)
([d5ac6c8](d5ac6c87))

* change log level to debug (#2798)
([f042d0b](f042d0bd))

* change path to `doc.go` in docgen test (#2700)
([fd6bae4](fd6bae40))

### Documentation

* use consistent library id in flags and examples (#2770)
([87a1005](87a10056))

</details>
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.

Java: Implement POMs generation

2 participants