Search in sources :

Example 1 with ImagePackager

use of org.springframework.boot.loader.tools.ImagePackager in project spring-boot by spring-projects.

the class BuildImageMojo method getBuildRequest.

private BuildRequest getBuildRequest(Libraries libraries) throws MojoExecutionException {
    ImagePackager imagePackager = new ImagePackager(getArchiveFile(), getBackupFile());
    Function<Owner, TarArchive> content = (owner) -> getApplicationContent(owner, libraries, imagePackager);
    Image image = (this.image != null) ? this.image : new Image();
    if (image.name == null && this.imageName != null) {
        image.setName(this.imageName);
    }
    if (image.builder == null && this.imageBuilder != null) {
        image.setBuilder(this.imageBuilder);
    }
    if (image.runImage == null && this.runImage != null) {
        image.setRunImage(this.runImage);
    }
    if (image.cleanCache == null && this.cleanCache != null) {
        image.setCleanCache(this.cleanCache);
    }
    if (image.pullPolicy == null && this.pullPolicy != null) {
        image.setPullPolicy(this.pullPolicy);
    }
    if (image.publish == null && this.publish != null) {
        image.setPublish(this.publish);
    }
    if (image.network == null && this.network != null) {
        image.setNetwork(this.network);
    }
    if (image.publish != null && image.publish && publishRegistryNotConfigured()) {
        throw new MojoExecutionException("Publishing an image requires docker.publishRegistry to be configured");
    }
    return customize(image.getBuildRequest(this.project.getArtifact(), content));
}
Also used : AbstractBuildLog(org.springframework.boot.buildpack.platform.build.AbstractBuildLog) TotalProgressEvent(org.springframework.boot.buildpack.platform.docker.TotalProgressEvent) Parameter(org.apache.maven.plugins.annotations.Parameter) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TarConstants(org.apache.commons.compress.archivers.tar.TarConstants) Execute(org.apache.maven.plugins.annotations.Execute) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) Mojo(org.apache.maven.plugins.annotations.Mojo) LayoutFactory(org.springframework.boot.loader.tools.LayoutFactory) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Duration(java.time.Duration) Artifact(org.apache.maven.artifact.Artifact) LifecyclePhase(org.apache.maven.plugins.annotations.LifecyclePhase) ResolutionScope(org.apache.maven.plugins.annotations.ResolutionScope) ZipEntry(java.util.zip.ZipEntry) OutputStream(java.io.OutputStream) DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) ImagePackager(org.springframework.boot.loader.tools.ImagePackager) PullPolicy(org.springframework.boot.buildpack.platform.build.PullPolicy) BuildLog(org.springframework.boot.buildpack.platform.build.BuildLog) Builder(org.springframework.boot.buildpack.platform.build.Builder) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Log(org.apache.maven.plugin.logging.Log) Creator(org.springframework.boot.buildpack.platform.build.Creator) Libraries(org.springframework.boot.loader.tools.Libraries) File(java.io.File) Consumer(java.util.function.Consumer) BuildRequest(org.springframework.boot.buildpack.platform.build.BuildRequest) Owner(org.springframework.boot.buildpack.platform.io.Owner) EntryWriter(org.springframework.boot.loader.tools.EntryWriter) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) Owner(org.springframework.boot.buildpack.platform.io.Owner) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ImagePackager(org.springframework.boot.loader.tools.ImagePackager)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 ZipEntry (java.util.zip.ZipEntry)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)1 TarConstants (org.apache.commons.compress.archivers.tar.TarConstants)1 Artifact (org.apache.maven.artifact.Artifact)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Log (org.apache.maven.plugin.logging.Log)1 Execute (org.apache.maven.plugins.annotations.Execute)1 LifecyclePhase (org.apache.maven.plugins.annotations.LifecyclePhase)1 Mojo (org.apache.maven.plugins.annotations.Mojo)1 Parameter (org.apache.maven.plugins.annotations.Parameter)1 ResolutionScope (org.apache.maven.plugins.annotations.ResolutionScope)1