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

Add JavaContainerBuilder to jib core #1347

Merged
merged 22 commits into from
Dec 20, 2018
Merged

Conversation

TadCordle
Copy link
Contributor

@TadCordle TadCordle commented Dec 14, 2018

Fixes #1212.

Adds a JavaContainerBuilder class that can be used to build Java-specific containers. Example usage:

JavaContainerBuilder.fromDistroless()
  .addClasses(Paths.get("application/classes"))
  .addResources(Paths.get("application/resources"))
  .addDependencies(
      Paths.get("application/dependencies/dependency.jar"),
      Paths.get("application/dependencies/dependency2.jar"),
      Paths.get("application/dependencies/dependency3-SNAPSHOT.jar)) // Separates snapshots to their own layer
  .addToClasspath(Paths.get("extra/classpath/dir")) // Adds to extra layer, but also adds new directory to classpath
  .setJvmFlags("-Xms512m", "-Xdebug")
  .setMainClass("HelloWorld")
  .toContainerBuilder()
  .containerize(...);

Potential followup issues:

  • Add a WarContainerBuilder for WAR-specific case, or adjust JavaContainerBuilder to support WARs
  • Use JavaContainerBuilder in Gradle/MavenLayerConfigurations

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

Sorry if this has been discussed, but for all of these, what if there are duplicate file names?

@chanseokoh
Copy link
Member

Sorry if this has been discussed, but for all of these, what if there are duplicate file names?

I mean I know what happens (only the last file will win and survive), e.g.,

  .addToClasspath("/loser/messages.properties",
                  "/winner/messages.properties")

so my question is if this is what we really intended, and if so, I think we should explain it in the Javadocs.

@TadCordle
Copy link
Contributor Author

@chanseokoh I can't remember where it was discussed, but I think this is intended behavior, and you are correct that I did forget to mention it in the javadocs. Will fix.

@coollog
Copy link
Contributor

coollog commented Dec 20, 2018

This LGTM - let's follow up this with having our plugins use this new API and make sure everything works the same as before.

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

Since @coollog said LGTM, let's just try. We can iterate if needed.

@TadCordle TadCordle merged commit c8c6396 into master Dec 20, 2018
@TadCordle TadCordle deleted the i1212-javacontainerbuilder branch December 20, 2018 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants