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