Skip to content

Conversation

meltsufin
Copy link
Member

@meltsufin meltsufin commented Oct 7, 2025

This change introduces the initial scaffolding for librariangen, a containerized Go application that will serve as the Java-specific code generator within the Librarian pipeline.

The primary goal of this change is to establish the foundational components for the Java language container, including:

  • A new librariangen CLI application: Written in Go, this will be the entry point for Java code generation tasks invoked by Librarian. It currently includes basic command dispatching and support for --version.
  • A multi-stage Dockerfile: This creates a minimal container image for librariangen.
  • Unit tests and CI: A new GitHub Actions workflow has been added to build and test the librariangen executable.

This scaffolding is the first step in implementing the full code generation logic within the Librarian system, eventually replacing the Java hermetic code generation system.

The code is largely adapted from the Go language container at https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen.

Fixes: googleapis/librarian#2500

@meltsufin meltsufin requested a review from suztomo October 7, 2025 20:04
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Oct 7, 2025
The Docker build and test steps were moved from the GitHub Actions workflow to a local script. This is because the base Docker image is not accessible from GitHub Actions.

The CI workflow now only runs the Go tests. The new `build-docker-and-test.sh` script can be used to build the Docker image and run the version check locally.
Copy link

sonarqubecloud bot commented Oct 7, 2025

Copy link

sonarqubecloud bot commented Oct 7, 2025

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

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.

The "internal" folder having only librariangen folder is strange. It's because we are not going to move other internal things (such as "hermetic_build") to the folder.

Shall we remove the "internal" folder?

For example, Python team's Dockerfile is at https://github.com/googleapis/google-cloud-python/tree/main/.generator.

"testing"
)

func TestRun(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

The argument parsing logic is to be in the shared module, so that each language container doesn't need to implement the argument parsing logic and its tests. https://github.com/googleapis/librarian/pull/2489/files#diff-704975122c152b21ff033c97bc92e9f3dc765402bf278620a3f88df835a9dd43R41

Copy link
Member

Choose a reason for hiding this comment

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

So you don't have to write many test cases for argument parsing.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's great, but let's integrate that in when it's ready.

@suztomo
Copy link
Member

suztomo commented Oct 8, 2025

It's nice that this started with small.

@meltsufin
Copy link
Member Author

The "internal" folder having only librariangen folder is strange. It's because we are not going to move other internal things (such as "hermetic_build") to the folder.

Shall we remove the "internal" folder?

For example, Python team's Dockerfile is at https://github.com/googleapis/google-cloud-python/tree/main/.generator.

This is a Go convention for non-exported packages that is enforced by the compiler and I think it's appropriate for our use-case: https://go.dev/doc/go1.4#internalpackages.

@meltsufin meltsufin requested a review from suztomo October 8, 2025 14:00
@suztomo
Copy link
Member

suztomo commented Oct 8, 2025

@meltsufin Thank you for the info. The "internal" folder or its parent doesn't have go.mod. I'm not sure the "internal" is recognized as a package. Would you be willing to experiment the "internal" folder is indeed following https://go.dev/doc/go1.4#internalpackages ? I think it's a matter of whether a symbol var Hello = "World" in internal/librariangen/main.go is visible by another program or not.

(In another go program's go.sum you would declare require https://github.com/googleapis/sdk-platform-java/internal/librariangen a407d733df5650041d4bfe01b4dd49f78fe175cf and try to reference the symbol librariangen.Hello)

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.

(Approving this to unblock the work) I still want to know the "internal" experiment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java: Create Dockerfile for Java language container
2 participants