Search in sources :

Example 11 with AssemblyFileSet

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardIncludeAcrossDirectories.

@Test
public void wildcardIncludeAcrossDirectories() throws IOException {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**.txt").fileMode("0766").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(4);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/one", "source-directory/one/1.txt", "source-directory/two", "source-directory/two/1.txt", "source-directory/three", "source-directory/three/1.txt");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 12 with AssemblyFileSet

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method withRelativeSourceAndDirectoryExcludes.

@Test
public void withRelativeSourceAndDirectoryExcludes() throws Exception {
    // Given
    final File quickstartDirectory = new File(sourceDirectory, "quickstarts/directory");
    FileUtils.forceMkdir(quickstartDirectory);
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(new File(quickstartDirectory, "../../")).outputDirectory(new File(".")).fileMode("0764").exclude("quickstarts{/**,}").exclude("three/**").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(13);
    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");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 13 with AssemblyFileSet

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method sourceDoesNotExist.

/**
 * Has AssemblyFileSet#directory and AssemblyConfiguration#targetDir options.
 *
 * Source directory doesn't exist
 *
 * Should do nothing.
 */
@Test
public void sourceDoesNotExist() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(new File(sourceDirectory, "non-existent")).build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).isEmpty();
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).doesNotExist();
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 14 with AssemblyFileSet

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method fileSetDirectoryAndRelativeOutputDirectory.

/**
 * No options provided except of the AssemblyFileSet#directory, relative outputDirectory and AssemblyConfiguration#targetDir.
 *
 * Should copy contents of AssemblyFileSet#directory to the outputDirectory in a relative subdirectory with path
 * composed of AssemblyConfiguration#targetDir and the relative outputDirectory.
 */
@Test
public void fileSetDirectoryAndRelativeOutputDirectory() throws Exception {
    // Given
    final File relativeOutputDirectory = new File("relative-output");
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(relativeOutputDirectory).build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("MyNameIsAl").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("relative-output", "relative-output/1.txt", "relative-output/3.other", "relative-output/37", "relative-output/one", "relative-output/one/1.txt", "relative-output/one/3.other", "relative-output/one/37", "relative-output/two", "relative-output/two/1.txt", "relative-output/two/3.other", "relative-output/two/37", "relative-output/three", "relative-output/three/1.txt", "relative-output/three/3.other", "relative-output/three/37").doesNotContainSequence("source-directory");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 15 with AssemblyFileSet

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardIncludeAndExcludeAcrossDirectories.

@Test
public void wildcardIncludeAndExcludeAcrossDirectories() throws IOException {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**.*").exclude("**.txt").fileMode("0766").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(4);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/3.other", "source-directory/one", "source-directory/one/3.other", "source-directory/two", "source-directory/two/3.other", "source-directory/three", "source-directory/three/3.other");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Aggregations

AssemblyFileSet (org.eclipse.jkube.kit.common.AssemblyFileSet)33 Test (org.junit.Test)30 File (java.io.File)26 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)21 AssemblyFileSetUtils.processAssemblyFileSet (org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet)19 Assembly (org.eclipse.jkube.kit.common.Assembly)18 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)18 Path (java.nio.file.Path)6 HashMap (java.util.HashMap)2 Nonnull (javax.annotation.Nonnull)2 GeneratorContext (org.eclipse.jkube.generator.api.GeneratorContext)2 IOException (java.io.IOException)1 FileSystems (java.nio.file.FileSystems)1 Files (java.nio.file.Files)1 PathMatcher (java.nio.file.PathMatcher)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Objects (java.util.Objects)1