Search in sources :

Example 21 with AssemblyFileSet

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

the class WildflyJARGenerator method addAdditionalFiles.

@Override
protected List<AssemblyFileSet> addAdditionalFiles() {
    List<AssemblyFileSet> set = super.addAdditionalFiles();
    if (localRepoCache != null) {
        Path parentDir;
        Path repoDir = localRepoCache;
        if (localRepoCache.isAbsolute()) {
            parentDir = localRepoCache.getParent();
        } else {
            repoDir = getProject().getBaseDirectory().toPath().resolve(localRepoCache);
            parentDir = repoDir.getParent();
        }
        if (Files.notExists(repoDir)) {
            throw new RuntimeException("Error, WildFly bootable JAR generator can't retrieve " + "generated maven local cache, directory " + repoDir + " doesn't exist.");
        }
        set.add(AssemblyFileSet.builder().directory(parentDir.toFile()).include(localRepoCache.getFileName().toString()).outputDirectory(new File(".")).fileMode("0640").build());
    }
    return set;
}
Also used : Path(java.nio.file.Path) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File)

Example 22 with AssemblyFileSet

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

the class WildflyJARGeneratorTest method slimServer.

@Test
public void slimServer(@Mocked final JavaProject project) throws IOException {
    Map<String, Object> options = new HashMap<>();
    Map<String, String> pluginOptions = new HashMap();
    options.put(PLUGIN_OPTIONS, pluginOptions);
    pluginOptions.put(JBOSS_MAVEN_DIST, null);
    pluginOptions.put(JBOSS_MAVEN_REPO, "target" + File.separator + "myrepo");
    // 
    Path tmpDir = Files.createTempDirectory("bootable-jar-test-project");
    Path targetDir = tmpDir.resolve("target");
    Path repoDir = targetDir.resolve("myrepo");
    Files.createDirectories(repoDir);
    try {
        GeneratorContext ctx = contextForSlimServer(project, options, tmpDir);
        WildflyJARGenerator generator = new WildflyJARGenerator(ctx);
        List<String> extraOptions = generator.getExtraJavaOptions();
        assertNotNull(extraOptions);
        assertEquals(2, extraOptions.size());
        assertEquals("-Djava.net.preferIPv4Stack=true", extraOptions.get(0));
        assertEquals("-Dmaven.repo.local=/deployments/myrepo", extraOptions.get(1));
        List<AssemblyFileSet> files = generator.addAdditionalFiles();
        assertFalse(files.isEmpty());
        AssemblyFileSet set = files.get(files.size() - 1);
        assertEquals(targetDir.toFile(), set.getDirectory());
        assertEquals(1, set.getIncludes().size());
        assertEquals("myrepo", set.getIncludes().get(0));
    } finally {
        Files.delete(repoDir);
        Files.delete(targetDir);
        Files.delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) GeneratorContext(org.eclipse.jkube.generator.api.GeneratorContext) Test(org.junit.Test)

Example 23 with AssemblyFileSet

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

the class OpenLibertyGeneratorTest method addAdditionalFiles.

@Test
public void addAdditionalFiles() {
    // When
    final List<AssemblyFileSet> result = new OpenLibertyGenerator(context).addAdditionalFiles();
    // Then
    assertThat(result).extracting(AssemblyFileSet::getDirectory).containsExactlyInAnyOrder(new File("src/main/jkube-includes"), new File("src/main/jkube-includes/bin"), new File("src/main/liberty/config"));
}
Also used : AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Example 24 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet 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");
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 25 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet 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");
}
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