Skip to content
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

feat: generate native image metadata during tar assembly #1831

Closed
wants to merge 19 commits into from

Conversation

mpeddada1
Copy link
Contributor

@mpeddada1 mpeddada1 commented Jul 6, 2023

This is an alternate approach to #1812. Instead of editing the Writer class, we are generating the reflect-config.json file at a later stage, i.e when the library tar is being assembled.

In this implementation:

The _gapic_pkg_tar_impl implementation package tar.gz files for proto-google-, gapic-google- and grpc-google-*. Before the compressed tarballs for each of these directories are created, we implement some logic to

  1. Iterate through all the java files in these directories.
  2. Derive the class name and package name for each .java file to build a string of the format, com.google.cloud.speech.v2.SpeechClient
  3. Add the string to reflect-config.json along with a set of fixed parameters in the format that is recognizable to the native image compiler:
[ 
 {
    "name": "com.google.cloud.speech.v2.SpeechSettings",
    "queryAllMethods": true,
    "queryAllPublicConstructors": true,
    "queryAllDeclaredMethods": true,
    "queryAllPublicMethods": true,
    "allDeclaredClasses": true,
    "allPublicClasses": true
  }
...
]

Local Testing

  • Follow instructions in the development guide to use the SNAPSHOT version of the gapic-generator-java.
  • At the root of the googleapis repo, run bazel build //google/cloud/speech/v2:google-cloud-speech-v2-java to generate an compressed tar for the desired. client library.

** TODOs**

  • Add logic to parse the nested classes.

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Jul 6, 2023

#TODO: Use awk to extract classes inside java class. Such as: awk '/public class/' Classes.java
if [[ {package_dir_path} == *proto-google-cloud-* ]] || [[ {package_dir_path} == *gapic-google-cloud-* ]] || [[ {package_dir_path} == *grpc-google-cloud-* ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update this PR to:

  • Also apply to Showcase client generation
  • Invoke the showcase native image tests (free if rebasing on ci: showcase native check #1833)
  • Remove the RunReachabilityHandlersConcurrently argument
  • Remove the Feature classes using reachability handlers

@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 Jul 7, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jul 7, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jul 7, 2023

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jul 7, 2023

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mpeddada1
Copy link
Contributor Author

Closing in favor of #1841

@mpeddada1 mpeddada1 closed this Jul 24, 2023
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.

2 participants