Search in sources :

Example 11 with AssemblyFile

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

the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSame.

@Test
public void getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSame() throws IOException {
    // Given
    assumeFalse(isWindows());
    final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("/")).build();
    final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
    // When
    final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
    // Then
    assertEquals("/", result.getAbsolutePath());
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 12 with AssemblyFile

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

the class AssemblyFileUtilsTest method resolveSourceFileRelativeSourceShouldReturnComputedPath.

@Test
public void resolveSourceFileRelativeSourceShouldReturnComputedPath() throws IOException {
    // Given
    final File baseDirectory = temporaryFolder.newFolder("base");
    final AssemblyFile af = AssemblyFile.builder().source(new File("some-file.txt")).build();
    // When
    final File result = AssemblyFileUtils.resolveSourceFile(baseDirectory, af);
    // Then
    final String expectedPath = baseDirectory.toPath().resolve("some-file.txt").toAbsolutePath().toString();
    assertEquals(expectedPath, result.getAbsolutePath());
}
Also used : AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 13 with AssemblyFile

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

the class AssemblyFileUtils method getAssemblyFileOutputDirectory.

public static File getAssemblyFileOutputDirectory(AssemblyFile assemblyFile, File outputDirectoryForRelativePaths, Assembly layer, AssemblyConfiguration assemblyConfiguration) {
    final File outputDirectory;
    Objects.requireNonNull(assemblyFile.getOutputDirectory(), "Assembly Configuration output dir is required");
    if (assemblyFile.getOutputDirectory().isAbsolute()) {
        outputDirectory = assemblyFile.getOutputDirectory();
    } else if (StringUtils.isBlank(layer.getId())) {
        Objects.requireNonNull(assemblyConfiguration.getTargetDir(), "Assembly Configuration target dir is required");
        outputDirectory = new File(outputDirectoryForRelativePaths, assemblyConfiguration.getTargetDir()).toPath().resolve(assemblyFile.getOutputDirectory().toPath()).toFile();
    } else {
        Objects.requireNonNull(assemblyConfiguration.getTargetDir(), "Assembly Configuration target dir is required");
        outputDirectory = new File(new File(outputDirectoryForRelativePaths, layer.getId()), assemblyConfiguration.getTargetDir()).toPath().resolve(assemblyFile.getOutputDirectory().toPath()).toFile();
    }
    return outputDirectory;
}
Also used : AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File)

Aggregations

AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)13 File (java.io.File)12 Test (org.junit.Test)11 Assembly (org.eclipse.jkube.kit.common.Assembly)6 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)6 Expectations (mockit.Expectations)1 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)1 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)1 AssemblyFileUtils.resolveSourceFile (org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.resolveSourceFile)1 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)1