Skip to content

feat(internal/librarian/java): add entries to versions.txt for new modules#4967

Open
perashanid wants to merge 2 commits intogoogleapis:mainfrom
perashanid:feat/java-versions-txt-4927
Open

feat(internal/librarian/java): add entries to versions.txt for new modules#4967
perashanid wants to merge 2 commits intogoogleapis:mainfrom
perashanid:feat/java-versions-txt-4927

Conversation

@perashanid
Copy link
Copy Markdown
Contributor

This PR adds functionality to automatically update versions.txt when new Java modules are generated. This is needed during migration when release-please is still in use.

Changes Made:

Modified generatePomsIfMissing to track newly created modules and call updateVersionsFile after generating POMs
Added updateVersionsFile function that appends entries to versions.txt for new modules
The function handles creating the file if it doesn't exist, appending to existing content, and avoiding duplicate entries
Format used: module-name:0.0.0:version-SNAPSHOT where 0.0.0 is the initial released version for new modules

Technical Implementation:

When new proto-, grpc-, or gapic client modules are generated, their artifact IDs are collected
The updateVersionsFile function reads the existing versions.txt to avoid duplicates
New entries are appended with format: module:0.0.0:library-version-SNAPSHOT
The file is created in the repository root (parent directory of the library directory)

Testing:

Added comprehensive test coverage in TestUpdateVersionsFile with scenarios for:

  • Creating new versions.txt file
  • Appending to existing file
  • Skipping duplicate modules
  • Adding multiple new modules at once

All existing pom-related tests pass
No linting or diagnostic issues

Fixes #4927

@perashanid perashanid requested a review from a team as a code owner March 31, 2026 21:59
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 logic to automatically update the versions.txt file when new Java modules are generated. It includes a new updateVersionsFile function and corresponding unit tests. The review feedback suggests simplifying the file-reading logic to avoid redundant system calls and improving test assertions by using cmp.Diff to align with the project's style guide.

- Simplify file reading by using os.ReadFile directly and checking os.IsNotExist
- Use cmp.Diff for test assertions following project style guide
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: add entry to versions.txt if new modules added

1 participant