KEMBAR78
chore: bake Java formatter into image by JoeWang1127 · Pull Request #3271 · googleapis/sdk-platform-java · GitHub
Skip to content

Conversation

@JoeWang1127
Copy link
Contributor

In this PR:

  • Bake Java formatter into image.

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Oct 3, 2024
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: s Pull request size is small. labels Oct 3, 2024
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: l Pull request size is large. labels Oct 3, 2024
ARG OWLBOT_CLI_COMMITTISH=ac84fa5c423a0069bbce3d2d869c9730c8fdf550
ARG PROTOC_VERSION=25.5
ARG GRPC_VERSION=1.67.1
ARG JAVA_FORMAT_VERSION=1.7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can upgrade the formatter, the latest version is 1.23.0.

It will cause code formatting so it's better in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree that it should be tracked differently. However, I think the newer versions of formatter are not compatible with Java 8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fomatter is not part of client library and we should be able use a new version of Java to run it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it is a jar, I think it still needs to be run with Java. I see that we are currently using Java 21 in our build file, but we probably want to use a lower version to guarantee the compatibility since our client library still supports Java 8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this repo has a check to verify the compiled code is compatible with Java 8 (maven profile should make sure of that). Of course, we can change it to Java8 as well.

On the other hand, running generator/formatter jar only requires JRE which I think we can choose a different version from JDK. We can optimize the image to only include a JRE but not a JDK.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Oct 3, 2024
@JoeWang1127 JoeWang1127 marked this pull request as ready for review October 4, 2024 13:19
@JoeWang1127 JoeWang1127 requested a review from blakeli0 October 4, 2024 13:19
RUN ln -sf ${NODE_PATH}/* /usr/local/bin

# download the Java formatter
ADD https://maven-central.storage-download.googleapis.com/maven2/com/google/googlejavaformat/google-java-format/${JAVA_FORMAT_VERSION}/google-java-format-${JAVA_FORMAT_VERSION}-all-deps.jar \
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably need to be downloaded from Airlock as well, but definitely a separate PR. cc: @suztomo.

if [[ ! -f "${required_tool}" ]]; then
>&2 echo "File ${required_tool} not found in the "
>&2 echo "filesystem. Please configure your environment and store the "
>&2 echo "generator jar in this location"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this logic is reused now, we should update the wording from "generator jar" to something more generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't need this sh anymore once we move to hermetic build image in showcase right? Or at least it should be much simpler, things like downloading jars would not be needed anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll cleanup these files when I'm working on b/325061217

@sonarqubecloud
Copy link

@sonarqubecloud
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 SonarCloud

@JoeWang1127 JoeWang1127 requested a review from blakeli0 October 11, 2024 14:09
@JoeWang1127 JoeWang1127 merged commit 259e9f7 into main Oct 11, 2024
49 of 50 checks passed
@JoeWang1127 JoeWang1127 deleted the chore/bake-formattor branch October 11, 2024 16:18
jinseopkim0 added a commit that referenced this pull request Oct 11, 2024
In this PR:
- Bake Java formatter into image.

---------

Thank you for opening a Pull Request! Before submitting your PR, please
read our [contributing
guidelines](https://github.com/googleapis/gapic-generator-java/blob/main/CONTRIBUTING.md).

There are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a
[bug/issue](https://github.com/googleapis/gapic-generator-java/issues/new/choose)
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com>
Co-authored-by: cloud-java-bot <cloud-java-bot@google.com>
diegomarquezp added a commit that referenced this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants