Search in sources :

Example 11 with AssemblyConfiguration

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

the class JavaExecGeneratorTest method createAssemblyWithNoFatJarShouldAddDefaultFileSets.

@Test
public void createAssemblyWithNoFatJarShouldAddDefaultFileSets() {
    // When
    final AssemblyConfiguration result = new JavaExecGenerator(generatorContext).createAssembly();
    // Then
    assertThat(result).hasFieldOrPropertyWithValue("excludeFinalOutputArtifact", false).extracting(AssemblyConfiguration::getLayers).asList().hasSize(1).first().asInstanceOf(InstanceOfAssertFactories.type(Assembly.class)).extracting(Assembly::getFileSets).asList().hasSize(2);
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 12 with AssemblyConfiguration

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

the class JavaExecGeneratorTest method createAssemblyWithFatJarShouldAddDefaultFileSetsAndFatJar.

@Test
public void createAssemblyWithFatJarShouldAddDefaultFileSetsAndFatJar(@Mocked FatJarDetector fatJarDetector, @Mocked FatJarDetector.Result fjResult) {
    // Given
    // @formatter:off
    new Expectations() {

        {
            generatorContext.getProject().getBuildPackageDirectory();
            result = new File("");
            generatorContext.getProject().getBaseDirectory();
            result = new File("");
            fjResult.getArchiveFile();
            result = new File("fat.jar");
            fatJarDetector.scan();
            result = fjResult;
        }
    };
    // @formatter:on
    // When
    final AssemblyConfiguration result = new JavaExecGenerator(generatorContext).createAssembly();
    // Then
    assertThat(result).hasFieldOrPropertyWithValue("excludeFinalOutputArtifact", true).extracting(AssemblyConfiguration::getLayers).asList().hasSize(1).first().asInstanceOf(InstanceOfAssertFactories.type(Assembly.class)).extracting(Assembly::getFileSets).asList().hasSize(3).extracting("directory", "includes").containsExactlyInAnyOrder(tuple(new File("src/main/jkube-includes"), Collections.emptyList()), tuple(new File("src/main/jkube-includes/bin"), Collections.emptyList()), tuple(new File(""), Collections.singletonList("fat.jar")));
}
Also used : Expectations(mockit.Expectations) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 13 with AssemblyConfiguration

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

the class KarafGeneratorTest method customizeWithKarafMavenPluginShouldAddImageConfiguration.

@Test
public void customizeWithKarafMavenPluginShouldAddImageConfiguration(@Mocked Plugin plugin) {
    // Given
    final List<ImageConfiguration> originalImageConfigurations = new ArrayList<>();
    // @formatter:off
    new Expectations() {

        {
            plugin.getGroupId();
            result = "org.apache.karaf.tooling";
            minTimes = 0;
            plugin.getArtifactId();
            result = "karaf-maven-plugin";
            minTimes = 0;
            generatorContext.getProject().getPlugins();
            result = Collections.singletonList(plugin);
            minTimes = 0;
            generatorContext.getProject().getBuildDirectory();
            result = temporaryFolder.getRoot();
            generatorContext.getProject().getVersion();
            result = "1.33.7-SNAPSHOT";
            generatorContext.getConfig();
            result = new ProcessorConfig();
        }
    };
    // @formatter:on
    // When
    final List<ImageConfiguration> result = new KarafGenerator(generatorContext).customize(originalImageConfigurations, false);
    // Then
    assertThat(originalImageConfigurations, sameInstance(result));
    assertThat(result, hasSize(1));
    final ImageConfiguration imageConfiguration = result.iterator().next();
    assertThat(imageConfiguration.getName(), equalTo("%g/%a:%l"));
    assertThat(imageConfiguration.getAlias(), equalTo("karaf"));
    final BuildConfiguration bc = imageConfiguration.getBuildConfiguration();
    assertThat(bc.getTags(), contains("latest"));
    assertThat(bc.getPorts(), contains("8181", "8778"));
    assertThat(bc.getEnv(), hasEntry("DEPLOYMENTS_DIR", "/deployments"));
    assertThat(bc.getEnv(), hasEntry("KARAF_HOME", "/deployments/karaf"));
    final AssemblyConfiguration ac = bc.getAssembly();
    assertThat(ac.getName(), equalTo("deployments"));
    assertThat(ac.isExcludeFinalOutputArtifact(), equalTo(false));
    assertThat(ac.getLayers(), hasSize(1));
    assertThat(ac.getLayers().iterator().next().getFileSets(), contains(allOf(hasProperty("directory", equalTo(new File(temporaryFolder.getRoot(), "assembly"))), hasProperty("outputDirectory", equalTo(new File("karaf"))), hasProperty("directoryMode", equalTo("0775"))), allOf(hasProperty("directory", equalTo(temporaryFolder.getRoot().toPath().resolve("assembly").resolve("bin").toFile())), hasProperty("outputDirectory", equalTo(new File("karaf", "bin"))), hasProperty("fileMode", equalTo("0777")), hasProperty("directoryMode", equalTo("0775")))));
}
Also used : Expectations(mockit.Expectations) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Test(org.junit.Test)

Example 14 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method minimumRequiredFieldsWithAssemblyId.

/**
 * @see #minimumRequiredFields()
 */
@Test
public void minimumRequiredFieldsWithAssemblyId() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).build();
    final Assembly layer = Assembly.builder().id("layer-1").build();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(16);
    FileAssertions.assertThat(new File(outputDirectory, "layer-1")).exists().fileTree().containsExactlyInAnyOrder("deployments", "deployments/source-directory", "deployments/source-directory/1.txt", "deployments/source-directory/3.other", "deployments/source-directory/37", "deployments/source-directory/one", "deployments/source-directory/one/1.txt", "deployments/source-directory/one/3.other", "deployments/source-directory/one/37", "deployments/source-directory/two", "deployments/source-directory/two/1.txt", "deployments/source-directory/two/3.other", "deployments/source-directory/two/37", "deployments/source-directory/three", "deployments/source-directory/three/1.txt", "deployments/source-directory/three/3.other", "deployments/source-directory/three/37");
}
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 AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardHierarchicalInclude.

@Test
public void wildcardHierarchicalInclude() 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(3);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "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)

Aggregations

AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)41 Test (org.junit.Test)32 File (java.io.File)29 Assembly (org.eclipse.jkube.kit.common.Assembly)29 AssemblyFileSet (org.eclipse.jkube.kit.common.AssemblyFileSet)22 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)19 AssemblyFileSetUtils.processAssemblyFileSet (org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet)19 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)12 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)8 List (java.util.List)6 Expectations (mockit.Expectations)6 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 Nonnull (javax.annotation.Nonnull)5 AssemblyConfigurationUtils.getJKubeAssemblyFiles (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFiles)5 IOException (java.io.IOException)4 Map (java.util.Map)4 AssemblyConfigurationUtils.createDockerFileBuilder (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.createDockerFileBuilder)4 AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault)4 AssemblyConfigurationUtils.getJKubeAssemblyFileSets (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFileSets)4