feat(internal/librarian/java): support alternate license header files#6311
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for alternate license headers in Java modules by adding an AlternateHeaders configuration field and updating the post-processing logic to read from this file if provided. The review feedback focuses on improving test robustness by using bytes.HasPrefix instead of bytes.Contains to verify headers, optimizing the license text retrieval to return []byte directly to avoid unnecessary string conversions, and properly wrapping errors.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for configuring alternate license headers in Java modules. It adds an alternate_headers field to the configuration schema and the JavaModule struct, and updates the post-processing logic to read and apply the alternate header text from the specified file path. Comprehensive unit tests have been added to verify this new behavior, including error handling for missing header files. No review comments were provided, so there is no additional feedback to address.
Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [0.21.0](v0.20.0...v0.21.0) (2026-06-16) ### Features * **internal/librarian/java:** source google-cloud-pom-parent in pom.xml templates ([#6432](#6432)) ([c5718f4](c5718f4)) * **internal/librarian/java:** support alternate license header files ([#6311](#6311)) ([e7222b1](e7222b1)) * **internal/librarian/nodejs:** add client_documentation_override to migrate ([#6310](#6310)) ([cb8b040](cb8b040)) * **internal/librarian/python:** update gapic-generator to 1.35.0 ([#6427](#6427)) ([c3a780e](c3a780e)) * **internal/librarian:** enable structured logging with slog ([#6363](#6363)) ([458a738](458a738)), closes [#6338](#6338) * **internal/postprocessing:** add copyFile function ([#6364](#6364)) ([8aa57f0](8aa57f0)), closes [#6295](#6295) * **internal/postprocessing:** add removeFile function ([#6371](#6371)) ([9e471eb](9e471eb)), closes [#6296](#6296) * **internal/postprocessing:** add replace and replaceRegex functions ([#6412](#6412)) ([ece3aff](ece3aff)), closes [#6297](#6297) * **librarian:** sync to release-please in add command ([#6346](#6346)) ([f1103ae](f1103ae)) * **sidekick/rust:** add `gcp.resource.destination.id` and fix incorrect `gcp.longrunning.done` status in lro traces ([#6275](#6275)) ([0648f55](0648f55)) * **sidekick/swift:** improve snippet body ([#6434](#6434)) ([dcb6e6c](dcb6e6c)) * **sidekick/swift:** LRO snippets ([#6431](#6431)) ([be95a09](be95a09)) ### Bug Fixes * **.github/workflows:** fix outdated Java tools path in integration job ([#6372](#6372)) ([72a5447](72a5447)) * **golang:** fix onboarding versionless paths ([#6435](#6435)) ([acd1c2b](acd1c2b)) * **internal/postprocessing:** return error for missing files in RemoveFile ([#6408](#6408)) ([4a0e81b](4a0e81b)) * **librarian/internal/java:** preserve released_version for non-snapshot versions during tidy ([#6426](#6426)) ([034374c](034374c)) * **sdk.yaml:** enable java sql v1beta4 dual transport ([#6437](#6437)) ([ac320d3](ac320d3)) * **sidekick/rust:** add clippy allow for BigQuery request methods ([#6373](#6373)) ([cc804c9](cc804c9)) --- 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>
…googleapis#6311) Added support for custom external alternate license header files during Java code regeneration. When `alternate_headers` is configured with a relative file path in the library's `java` configuration block, Librarian reads that file and appends its contents as the license header instead of the standard header. A temporary, backwards-compatible migration check ensures monolithic libraries retain their existing skip behavior until their config is updated. There will be two f/u PRs: the first in google-cloud-java to add the property and the header. The second in librarian to remove the monolithic block since (I think) it only applies to grafeas, and just rely on the alternate headers path. For googleapis#6178 --------- Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [0.21.0](googleapis/librarian@v0.20.0...v0.21.0) (2026-06-16) ### Features * **internal/librarian/java:** source google-cloud-pom-parent in pom.xml templates ([googleapis#6432](googleapis#6432)) ([c5718f4](googleapis@c5718f4)) * **internal/librarian/java:** support alternate license header files ([googleapis#6311](googleapis#6311)) ([e7222b1](googleapis@e7222b1)) * **internal/librarian/nodejs:** add client_documentation_override to migrate ([googleapis#6310](googleapis#6310)) ([cb8b040](googleapis@cb8b040)) * **internal/librarian/python:** update gapic-generator to 1.35.0 ([googleapis#6427](googleapis#6427)) ([c3a780e](googleapis@c3a780e)) * **internal/librarian:** enable structured logging with slog ([googleapis#6363](googleapis#6363)) ([458a738](googleapis@458a738)), closes [googleapis#6338](googleapis#6338) * **internal/postprocessing:** add copyFile function ([googleapis#6364](googleapis#6364)) ([8aa57f0](googleapis@8aa57f0)), closes [googleapis#6295](googleapis#6295) * **internal/postprocessing:** add removeFile function ([googleapis#6371](googleapis#6371)) ([9e471eb](googleapis@9e471eb)), closes [googleapis#6296](googleapis#6296) * **internal/postprocessing:** add replace and replaceRegex functions ([googleapis#6412](googleapis#6412)) ([ece3aff](googleapis@ece3aff)), closes [googleapis#6297](googleapis#6297) * **librarian:** sync to release-please in add command ([googleapis#6346](googleapis#6346)) ([f1103ae](googleapis@f1103ae)) * **sidekick/rust:** add `gcp.resource.destination.id` and fix incorrect `gcp.longrunning.done` status in lro traces ([googleapis#6275](googleapis#6275)) ([0648f55](googleapis@0648f55)) * **sidekick/swift:** improve snippet body ([googleapis#6434](googleapis#6434)) ([dcb6e6c](googleapis@dcb6e6c)) * **sidekick/swift:** LRO snippets ([googleapis#6431](googleapis#6431)) ([be95a09](googleapis@be95a09)) ### Bug Fixes * **.github/workflows:** fix outdated Java tools path in integration job ([googleapis#6372](googleapis#6372)) ([72a5447](googleapis@72a5447)) * **golang:** fix onboarding versionless paths ([googleapis#6435](googleapis#6435)) ([acd1c2b](googleapis@acd1c2b)) * **internal/postprocessing:** return error for missing files in RemoveFile ([googleapis#6408](googleapis#6408)) ([4a0e81b](googleapis@4a0e81b)) * **librarian/internal/java:** preserve released_version for non-snapshot versions during tidy ([googleapis#6426](googleapis#6426)) ([034374c](googleapis@034374c)) * **sdk.yaml:** enable java sql v1beta4 dual transport ([googleapis#6437](googleapis#6437)) ([ac320d3](googleapis@ac320d3)) * **sidekick/rust:** add clippy allow for BigQuery request methods ([googleapis#6373](googleapis#6373)) ([cc804c9](googleapis@cc804c9)) --- 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>
…c libraries (googleapis#6481) Final F/U PR described in googleapis#6311. This PR "flips the switch" so that if a library has alternate_headers, we should see it in the library. Otherwise keeps other monolithic libraries stable. Fixes googleapis#6178
Added support for custom external alternate license header files during Java code regeneration.
When
alternate_headersis configured with a relative file path in the library'sjavaconfiguration block, Librarian reads that file and appends its contents as the license header instead of the standard header. A temporary, backwards-compatible migration check ensures monolithic libraries retain their existing skip behavior until their config is updated.There will be two f/u PRs: the first in google-cloud-java to add the property and the header. The second in librarian to remove the monolithic block since (I think) it only applies to grafeas, and just rely on the alternate headers path.
For #6178