use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class BuildUtilTest method extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull.
@Test
public void extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull() {
// Given
final BuildConfiguration buildConfiguration = BuildConfiguration.builder().assembly(new AssemblyConfiguration()).build();
// When
final String result = extractBaseFromConfiguration(buildConfiguration);
// Then
assertThat(result).isNull();
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyConfigurationUtils method getAssemblyConfigurationOrCreateDefault.
@Nonnull
static AssemblyConfiguration getAssemblyConfigurationOrCreateDefault(@Nullable BuildConfiguration buildConfiguration) {
final AssemblyConfiguration ac = Optional.ofNullable(buildConfiguration).map(BuildConfiguration::getAssembly).orElse(AssemblyConfiguration.builder().build());
final AssemblyConfiguration.AssemblyConfigurationBuilder builder = ac.toBuilder();
final String name;
if (StringUtils.isBlank(ac.getName())) {
builder.name(DEFAULT_NAME);
name = DEFAULT_NAME;
} else {
name = ac.getName();
}
if (StringUtils.isBlank(ac.getTargetDir())) {
builder.targetDir(LINUX_FILE_SEPARATOR.concat(name));
}
return builder.build();
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class WebAppGenerator method createAssembly.
private AssemblyConfiguration createAssembly(AppServerHandler handler) {
final File sourceFile = Objects.requireNonNull(JKubeProjectUtil.getFinalOutputArtifact(getProject()), "Final output artifact file was not detected");
final String targetFilename;
final String extension = FilenameUtils.getExtension(sourceFile.getName());
final String path = getConfig(Config.PATH);
if (path.equals("/") || isBlank(path)) {
targetFilename = String.format("ROOT.%s", extension);
} else {
targetFilename = String.format("%s.%s", path.replaceAll("[\\\\/]", ""), extension);
}
final AssemblyConfiguration.AssemblyConfigurationBuilder builder = AssemblyConfiguration.builder();
builder.name(handler.getAssemblyName()).targetDir(getDeploymentDir(handler)).excludeFinalOutputArtifact(true).inline(Assembly.builder().file(AssemblyFile.builder().source(sourceFile).destName(targetFilename).outputDirectory(new File(".")).build()).build());
String user = getUser(handler);
if (user != null) {
builder.user(user);
}
return builder.build();
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method assemblyConfigurationHasNoTargetDir_shouldThrowException.
@Test
public void assemblyConfigurationHasNoTargetDir_shouldThrowException() {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final NullPointerException result = Assert.assertThrows(NullPointerException.class, () -> processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac));
// Then
assertThat(result).hasMessage("Assembly Configuration target dir is required");
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method fileSetDirectoryAndOutputDirectoryResolvingToSelf.
/**
* Has AssemblyFileSet with directory and outputDirectory relative path resolving to self.
* Has AssemblyConfiguration targetDir.
*
* Should copy <b>contents</b> of AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the
* AssemblyConfiguration#targetDir.
*/
@Test
public void fileSetDirectoryAndOutputDirectoryResolvingToSelf() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(new File(".")).build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("NotImportant").targetDir("deployments").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).hasSize(16);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("1.txt", "3.other", "37", "one", "one/1.txt", "one/3.other", "one/37", "two", "two/1.txt", "two/3.other", "two/37", "three", "three/1.txt", "three/3.other", "three/37").doesNotContainSequence("source-directory");
}
Aggregations