Search in sources :

Example 1 with AssemblyMode

use of org.eclipse.jkube.kit.common.AssemblyMode in project jkube by eclipse.

the class AssemblyManager method createAssemblyArchive.

private void createAssemblyArchive(AssemblyConfiguration assemblyConfig, JKubeConfiguration params, BuildDirs buildDirs, ArchiveCompression compression, Map<Assembly, List<AssemblyFileEntry>> layers) throws IOException {
    if (layers.isEmpty()) {
        return;
    }
    AssemblyConfigurationSource source = new AssemblyConfigurationSource(params, buildDirs, assemblyConfig);
    JKubeBuildTarArchiver jkubeTarArchiver = new JKubeBuildTarArchiver();
    AssemblyMode buildMode = assemblyConfig.getMode();
    try {
        layers.values().stream().flatMap(List::stream).filter(afe -> StringUtils.isNotBlank(afe.getFileMode())).forEach(jkubeTarArchiver::setFileMode);
        jkubeTarArchiver.createArchive(source.getOutputDirectory(), buildDirs, compression);
    } catch (IOException e) {
        String error = "Failed to create assembly for docker image " + " (with mode '" + buildMode + "'): " + e.getMessage() + ".";
        if (params.getProject().getArtifact() == null) {
            error += " If you include the build artifact please ensure that you have " + "built the artifact before with 'mvn package' (should be available in the target/ dir). " + "Please see the documentation (section \"Assembly\") for more information.";
        }
        throw new IOException(error, e);
    }
}
Also used : JKubeProjectUtil(org.eclipse.jkube.kit.common.util.JKubeProjectUtil) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) AssemblyConfigurationUtils.createDockerFileBuilder(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.createDockerFileBuilder) DockerFileUtil(org.eclipse.jkube.kit.build.api.helper.DockerFileUtil) StringUtils(org.apache.commons.lang3.StringUtils) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) LinkedHashMap(java.util.LinkedHashMap) AssemblyConfigurationUtils.getJKubeAssemblyFiles(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFiles) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) Map(java.util.Map) FileUtil(org.eclipse.jkube.kit.common.util.FileUtil) AssemblyMode(org.eclipse.jkube.kit.common.AssemblyMode) Nonnull(javax.annotation.Nonnull) JavaProject(org.eclipse.jkube.kit.common.JavaProject) DockerFileBuilder(org.eclipse.jkube.kit.config.image.build.DockerFileBuilder) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) Properties(java.util.Properties) AssemblyFileUtils.resolveSourceFile(org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.resolveSourceFile) Files(java.nio.file.Files) ArchiveCompression(org.eclipse.jkube.kit.common.archive.ArchiveCompression) BufferedWriter(java.io.BufferedWriter) AssemblyFileUtils.getAssemblyFileOutputDirectory(org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.getAssemblyFileOutputDirectory) FileWriter(java.io.FileWriter) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) IOException(java.io.IOException) AssemblyConfigurationUtils.getJKubeAssemblyFileSets(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFileSets) Collectors(java.util.stream.Collectors) File(java.io.File) AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault) KitLogger(org.eclipse.jkube.kit.common.KitLogger) List(java.util.List) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) Assembly(org.eclipse.jkube.kit.common.Assembly) JKubeTarArchiver(org.eclipse.jkube.kit.common.archive.JKubeTarArchiver) Optional(java.util.Optional) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) AssemblyMode(org.eclipse.jkube.kit.common.AssemblyMode) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException)

Aggregations

BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 StandardCopyOption (java.nio.file.StandardCopyOption)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 StringUtils (org.apache.commons.lang3.StringUtils)1 AssemblyConfigurationUtils.createDockerFileBuilder (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.createDockerFileBuilder)1 AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault)1 AssemblyConfigurationUtils.getJKubeAssemblyFileSets (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFileSets)1