public class JavaContainerBuilder
extends java.lang.Object
JibContainerBuilder
for containerizing Java applications.Modifier and Type | Method and Description |
---|---|
JavaContainerBuilder |
addClasses(java.nio.file.Path classFilesDirectory)
Adds the contents of a classes directory to the image.
|
JavaContainerBuilder |
addClasses(java.nio.file.Path classFilesDirectory,
java.util.function.Predicate<java.nio.file.Path> pathFilter)
Adds the contents of a classes directory to the image.
|
JavaContainerBuilder |
addDependencies(java.util.List<java.nio.file.Path> dependencyFiles)
Adds dependency JARs to the image.
|
JavaContainerBuilder |
addDependencies(java.nio.file.Path... dependencyFiles)
Adds dependency JARs to the image.
|
JavaContainerBuilder |
addJvmFlag(java.lang.String jvmFlag)
Adds a JVM flag to use when starting the application.
|
JavaContainerBuilder |
addJvmFlags(java.util.List<java.lang.String> jvmFlags)
Adds JVM flags to use when starting the application.
|
JavaContainerBuilder |
addJvmFlags(java.lang.String... jvmFlags)
Adds JVM flags to use when starting the application.
|
JavaContainerBuilder |
addResources(java.nio.file.Path resourceFilesDirectory)
Adds the contents of a resources directory to the image.
|
JavaContainerBuilder |
addResources(java.nio.file.Path resourceFilesDirectory,
java.util.function.Predicate<java.nio.file.Path> pathFilter)
Adds the contents of a resources directory to the image.
|
JavaContainerBuilder |
addToClasspath(java.util.List<java.nio.file.Path> otherFiles)
Adds additional files to the classpath.
|
JavaContainerBuilder |
addToClasspath(java.nio.file.Path... otherFiles)
Adds additional files to the classpath.
|
static JavaContainerBuilder |
from(ImageReference baseImageReference)
Creates a new
JavaContainerBuilder with the specified base image reference. |
static JavaContainerBuilder |
from(RegistryImage registryImage)
Creates a new
JavaContainerBuilder with the specified base image. |
static JavaContainerBuilder |
from(java.lang.String baseImageReference)
Creates a new
JavaContainerBuilder with the specified base image reference. |
static JavaContainerBuilder |
fromDistroless()
Creates a new
JavaContainerBuilder that uses distroless java as the base image. |
JavaContainerBuilder |
setMainClass(java.lang.String mainClass)
Sets the main class used to start the application on the image.
|
JibContainerBuilder |
toContainerBuilder()
Returns a new
JibContainerBuilder using the parameters specified on the JavaContainerBuilder . |
public static JavaContainerBuilder fromDistroless() throws InvalidImageReferenceException
JavaContainerBuilder
that uses distroless java as the base image. For
more information on gcr.io/distroless/java
, see the distroless repository.JavaContainerBuilder
InvalidImageReferenceException
- if creating the base image reference failspublic static JavaContainerBuilder from(java.lang.String baseImageReference) throws InvalidImageReferenceException
JavaContainerBuilder
with the specified base image reference.baseImageReference
- the base image referenceJavaContainerBuilder
InvalidImageReferenceException
- if baseImageReference
is invalidpublic static JavaContainerBuilder from(ImageReference baseImageReference)
JavaContainerBuilder
with the specified base image reference.baseImageReference
- the base image referenceJavaContainerBuilder
public static JavaContainerBuilder from(RegistryImage registryImage)
JavaContainerBuilder
with the specified base image.registryImage
- the RegistryImage
that defines base container registry and
credentialsJavaContainerBuilder
public JavaContainerBuilder addDependencies(java.util.List<java.nio.file.Path> dependencyFiles) throws java.io.IOException
dependencyFiles
- the list of dependency JARs to add to the imagejava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addDependencies(java.nio.file.Path... dependencyFiles) throws java.io.IOException
dependencyFiles
- the list of dependency JARs to add to the imagejava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addResources(java.nio.file.Path resourceFilesDirectory) throws java.io.IOException
resourceFilesDirectory
- the directory containing the project's resourcesjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addResources(java.nio.file.Path resourceFilesDirectory, java.util.function.Predicate<java.nio.file.Path> pathFilter) throws java.io.IOException
resourceFilesDirectory
- the directory containing the project's resourcespathFilter
- filter that determines which files (not directories) should be addedjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addClasses(java.nio.file.Path classFilesDirectory) throws java.io.IOException
classFilesDirectory
- the directory containing the class filesjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addClasses(java.nio.file.Path classFilesDirectory, java.util.function.Predicate<java.nio.file.Path> pathFilter) throws java.io.IOException
classFilesDirectory
- the directory containing the class filespathFilter
- filter that determines which files (not directories) should be addedjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addToClasspath(java.util.List<java.nio.file.Path> otherFiles) throws java.io.IOException
otherFiles
contains a directory, the files
within are added recursively, maintaining the directory structure. For files in otherFiles
, files with duplicate filenames will be overwritten (e.g. if otherFiles
contains '/loser/messages.txt' and '/winner/messages.txt', only the second 'messages.txt' is
added.otherFiles
- the list of files to addjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addToClasspath(java.nio.file.Path... otherFiles) throws java.io.IOException
otherFiles
contains a directory, the files
within are added recursively, maintaining the directory structure. For files in otherFiles
, files with duplicate filenames will be overwritten (e.g. if otherFiles
contains '/loser/messages.txt' and '/winner/messages.txt', only the second 'messages.txt' is
added.otherFiles
- the list of files to addjava.io.IOException
- if adding the layer failspublic JavaContainerBuilder addJvmFlag(java.lang.String jvmFlag)
jvmFlag
- the JVM flag to addpublic JavaContainerBuilder addJvmFlags(java.util.List<java.lang.String> jvmFlags)
jvmFlags
- the list of JVM flags to addpublic JavaContainerBuilder addJvmFlags(java.lang.String... jvmFlags)
jvmFlags
- the list of JVM flags to addpublic JavaContainerBuilder setMainClass(java.lang.String mainClass)
.class
files, use MainClassFinder
.mainClass
- the main class used to start the applicationMainClassFinder
public JibContainerBuilder toContainerBuilder()
JibContainerBuilder
using the parameters specified on the JavaContainerBuilder
.JibContainerBuilder
using the parameters specified on the JavaContainerBuilder