use of io.syndesis.integration.api.IntegrationProjectGenerator in project syndesis by syndesisio.
the class ProjectGeneratorTest method generate.
// *****************************
// Helpers
// *****************************
private Path generate(Integration integration, ProjectGeneratorConfiguration generatorConfiguration, TestResourceManager resourceManager) throws IOException {
final IntegrationProjectGenerator generator = new ProjectGenerator(generatorConfiguration, resourceManager, getMavenProperties());
try (InputStream is = generator.generate(integration)) {
Path ret = testFolder.newFolder("integration-project").toPath();
try (TarArchiveInputStream tis = new TarArchiveInputStream(is)) {
TarArchiveEntry tarEntry = tis.getNextTarEntry();
// tarIn is a TarArchiveInputStream
while (tarEntry != null) {
// create a file with the same name as the tarEntry
File destPath = new File(ret.toFile(), tarEntry.getName());
if (tarEntry.isDirectory()) {
destPath.mkdirs();
} else {
destPath.getParentFile().mkdirs();
destPath.createNewFile();
try (BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(destPath))) {
IOUtils.copy(tis, bout);
}
}
tarEntry = tis.getNextTarEntry();
}
}
return ret;
}
}
use of io.syndesis.integration.api.IntegrationProjectGenerator in project syndesis by syndesisio.
the class Application method generate.
@SuppressWarnings("PMD.UseProperClassLoader")
private void generate(Integration integration, File targetDir) throws IOException {
ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration();
IntegrationProjectGenerator generator = new ProjectGenerator(configuration, new EmptyIntegrationResourceManager(), mavenProperties);
Path dir = targetDir.toPath();
Files.createDirectories(dir);
Files.write(dir.resolve("pom.xml"), generator.generatePom(integration));
dir = dir.resolve("src/main/java/io/syndesis/example");
Files.createDirectories(dir);
ClassPathResource resource = new ClassPathResource("io/syndesis/integration/project/generator/templates/Application.java.mustache");
try (InputStream is = resource.getInputStream()) {
Files.write(dir.resolve("Application.java"), IOUtils.toByteArray(is));
}
}
Aggregations