Search in sources :

Example 1 with Libraries

use of org.springframework.boot.loader.tools.Libraries 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)

Example 2 with Libraries

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

the class BuildImageMojo method buildImage.

private void buildImage() throws MojoExecutionException {
    Libraries libraries = getLibraries(Collections.emptySet());
    try {
        DockerConfiguration dockerConfiguration = (this.docker != null) ? this.docker.asDockerConfiguration() : null;
        BuildRequest request = getBuildRequest(libraries);
        Builder builder = new Builder(new MojoBuildLog(this::getLog), dockerConfiguration);
        builder.build(request);
    } catch (IOException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Builder(org.springframework.boot.buildpack.platform.build.Builder) Libraries(org.springframework.boot.loader.tools.Libraries) IOException(java.io.IOException) BuildRequest(org.springframework.boot.buildpack.platform.build.BuildRequest)

Example 3 with Libraries

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

the class RepackageMojo method repackage.

private void repackage() throws MojoExecutionException {
    Artifact source = getSourceArtifact(this.classifier);
    File target = getTargetFile(this.finalName, this.classifier, this.outputDirectory);
    Repackager repackager = getRepackager(source.getFile());
    Libraries libraries = getLibraries(this.requiresUnpack);
    try {
        LaunchScript launchScript = getLaunchScript();
        repackager.repackage(target, libraries, launchScript, parseOutputTimestamp());
    } catch (IOException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
    updateArtifact(source, target, repackager.getBackupFile());
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Repackager(org.springframework.boot.loader.tools.Repackager) Libraries(org.springframework.boot.loader.tools.Libraries) LaunchScript(org.springframework.boot.loader.tools.LaunchScript) DefaultLaunchScript(org.springframework.boot.loader.tools.DefaultLaunchScript) IOException(java.io.IOException) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

IOException (java.io.IOException)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 Libraries (org.springframework.boot.loader.tools.Libraries)3 File (java.io.File)2 Artifact (org.apache.maven.artifact.Artifact)2 BuildRequest (org.springframework.boot.buildpack.platform.build.BuildRequest)2 Builder (org.springframework.boot.buildpack.platform.build.Builder)2 DockerConfiguration (org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration)2 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 Log (org.apache.maven.plugin.logging.Log)1 Execute (org.apache.maven.plugins.annotations.Execute)1