Skip to content

fix(hermetic-build): use public maven metadata for latest version inference #3853

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

Merged
merged 3 commits into from
Jun 30, 2025

Conversation

diegomarquezp
Copy link
Contributor

Currently, the get_latest_released_version() function returns 2.59.0 for gapic-generator-java. This is not correct and is due to an ongoing issue with Maven.
This PR uses the alternative maven-metadata.xml files instead, which contains a metadata/versioning/latest entry always pointing to the latest version.

[hi on] diegomarquezp:~$ function get_latest_released_version() {
    local group_id=$1
    local artifact_id=$2
    group_id_url_path="$(sed 's|\.|/|g' <<< "${group_id}")"
    url="https://repo1.maven.org/maven2/${group_id_url_path}/${artifact_id}/maven-metadata.xml"
    xml_content=$(curl -s --fail "${url}")
    latest=$(xmllint --xpath 'metadata/versioning/latest/text()' - <<< "${xml_content}")
    if [[ -z "${latest}" ]]; then
        echo "The latest version of ${group_id}:${artifact_id} is empty."
        echo "The returned json from maven.org is invalid: ${json_content}"
        exit 1
    else
        echo "${latest}"
    fi
}
[hi on] diegomarquezp:~$ get_latest_released_version com.google.api gapic-generator-java
2.60.0

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Jun 30, 2025
@diegomarquezp
Copy link
Contributor Author

Follow up: HW libraries without hermetic build (e.g. java-bigquery).

JoeWang1127
JoeWang1127 previously approved these changes Jun 30, 2025
suztomo
suztomo previously approved these changes Jun 30, 2025
Copy link
Member

@suztomo suztomo 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 check xmllint is available in the container before merging this?

@diegomarquezp diegomarquezp dismissed stale reviews from suztomo and JoeWang1127 via 5e51016 June 30, 2025 20:27
@diegomarquezp
Copy link
Contributor Author

Can you check xmllint is available in the container before merging this?

Confirming manually in java-storage: googleapis/java-storage#3181
The action resulted in xmllint: command not found

Installing using sudo apt install -y libxml2-utils solves the problem.

I modified the template.

Thanks a lot for the catch, @suztomo!

@suztomo
Copy link
Member

suztomo commented Jun 30, 2025

Thank you.

@diegomarquezp diegomarquezp enabled auto-merge (squash) June 30, 2025 20:36
Copy link

Copy link

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@diegomarquezp diegomarquezp merged commit 0be1e96 into main Jun 30, 2025
57 of 60 checks passed
@diegomarquezp diegomarquezp deleted the fix-maven-search-template branch June 30, 2025 20:51
mpeddada1 pushed a commit that referenced this pull request Jul 8, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>2.60.1</summary>

##
[2.60.1](v2.60.0...v2.60.1)
(2025-07-08)


### Bug Fixes

* **hermetic-build:** use public maven metadata for latest version
inference
([#3853](#3853))
([0be1e96](0be1e96))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants