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());
}
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());
}
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;
}
Aggregations