use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method testIncrementalWithPluginEnabled.
@Test
public void testIncrementalWithPluginEnabled() throws Exception {
Path tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path temp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
TestUtil.copyTree(Paths.get("src/test/projects/dummy"), temp);
// end NIO
AFCompiler compiler = KieMavenCompilerFactory.getCompiler(KieDecorator.NONE);
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE }, new HashMap<>(), Boolean.FALSE);
CompilationResponse res = compiler.compileSync(req);
if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(), "KieDefaultMavenIncrementalCompilerTest.testIncrementalWithPluginEnabled");
}
Assert.assertTrue(res.isSuccessful());
Path incrementalConfiguration = Paths.get(temp.toAbsolutePath().toString(), "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
Assert.assertTrue(incrementalConfiguration.toFile().exists());
TestUtil.rm(tmpRoot.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class KieMavenOutputTest method testOutputWithTakari.
@Test
public void testOutputWithTakari() throws Exception {
Path tmpRoot = Files.createTempDirectory("repo");
Path tmpNio = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
TestUtil.copyTree(Paths.get("src/test/projects/dummy"), tmpNio);
Path tmp = Paths.get(tmpNio.toAbsolutePath().toString());
AFCompiler compiler = KieMavenCompilerFactory.getCompiler(KieDecorator.LOG_OUTPUT_AFTER);
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE }, new HashMap<>(), Boolean.TRUE);
CompilationResponse res = compiler.compileSync(req);
if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(), "KieMavenOutputTest.testOutputWithTakari");
}
assertTrue(res.isSuccessful());
assertTrue(res.getMavenOutput().isPresent());
assertTrue(res.getMavenOutput().get().size() > 0);
TestUtil.rm(tmpRoot.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class JGITCompilerBeforeDecorator method compileSync.
@Override
public T compileSync(CompilationRequest _req) {
final Path path = _req.getInfo().getPrjPath();
final CompilationRequest req;
Git repo;
if (path.getFileSystem() instanceof JGitFileSystem) {
final JGitFileSystem fs = (JGitFileSystem) path.getFileSystem();
if (!gitMap.containsKey(fs)) {
repo = JGitUtils.tempClone(fs, _req.getRequestUUID());
gitMap.put(fs, repo);
}
repo = gitMap.get(fs);
JGitUtils.applyBefore(repo);
req = new DefaultCompilationRequest(_req.getMavenRepo(), new WorkspaceCompilationInfo(Paths.get(repo.getRepository().getDirectory().toPath().getParent().resolve(path.getFileName().toString()).normalize().toUri())), _req.getOriginalArgs(), _req.getMap(), _req.getLogRequested());
} else {
req = _req;
}
return compiler.compileSync(req);
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class DefaultIncrementalCompilerEnablerTest method testReadPomsInaPrjTest.
@Test
public void testReadPomsInaPrjTest() throws Exception {
FileSystemProvider fs = FileSystemProviders.getDefaultProvider();
Path tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path temp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy"));
TestUtil.copyTree(Paths.get("src/test/projects/dummy_multimodule_untouched"), temp);
// end NIO
Path tmp = Paths.get(tmpRoot.toAbsolutePath().toString(), "dummy");
Path mainPom = Paths.get(temp.toAbsolutePath().toString(), "pom.xml");
byte[] encoded = Files.readAllBytes(Paths.get(temp.toAbsolutePath().toString(), "pom.xml"));
String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE }, new HashMap<>(), Boolean.FALSE);
DefaultIncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler(Compilers.JAVAC);
Assert.assertTrue(enabler.process(req).getResult());
encoded = Files.readAllBytes(Paths.get(mainPom.toString()));
pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
Assert.assertTrue(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
assertFalse(pomAsAstring.contains("kie-takari-plugin"));
TestUtil.rm(tmpRoot.toFile());
}
use of org.kie.workbench.common.services.backend.compiler.nio.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.
the class DefaultMavenCompilerTest method buildWithCloneTest.
@Test
public void buildWithCloneTest() throws Exception {
final String repoName = "myrepo";
final JGitFileSystem fs = (JGitFileSystem) ioService.newFileSystem(URI.create("git://" + repoName), new HashMap<String, Object>() {
{
put("init", Boolean.TRUE);
put("internal", Boolean.TRUE);
}
});
ioService.startBatch(fs);
ioService.write(fs.getPath("/dummy/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/pom.xml").toPath())));
ioService.write(fs.getPath("/dummy/dummyA/src/main/java/dummy/DummyA.java"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/src/main/java/dummy/DummyA.java").toPath())));
ioService.write(fs.getPath("/dummy/dummyB/src/main/java/dummy/DummyB.java"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/src/main/java/dummy/DummyB.java").toPath())));
ioService.write(fs.getPath("/dummy/dummyA/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/pom.xml").toPath())));
ioService.write(fs.getPath("/dummy/dummyB/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/pom.xml").toPath())));
ioService.endBatch();
Path tmpRootCloned = Files.createTempDirectory("cloned");
Path tmpCloned = Files.createDirectories(Paths.get(tmpRootCloned.toString(), "dummy"));
final File gitClonedFolder = new File(tmpCloned.toFile(), ".clone.git");
final Git cloned = Git.cloneRepository().setURI(fs.getGit().getRepository().getDirectory().toURI().toString()).setBare(false).setDirectory(gitClonedFolder).call();
assertNotNull(cloned);
// Compile the repo
AFCompiler compiler = MavenCompilerFactory.getCompiler(Decorator.LOG_OUTPUT_AFTER);
Path prjFolder = Paths.get(gitClonedFolder + "/dummy/");
byte[] encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
Assert.assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjFolder);
CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(), info, new String[] { MavenCLIArgs.COMPILE }, new HashMap<>(), Boolean.TRUE);
CompilationResponse res = compiler.compileSync(req);
if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(), "KieDefaultMavenCompilerOnInMemoryFSTest.buildWithCloneTest");
}
assertTrue(res.getMavenOutput().isPresent());
assertTrue(res.isSuccessful());
Path incrementalConfiguration = Paths.get(prjFolder + "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
assertTrue(incrementalConfiguration.toFile().exists());
encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
assertTrue(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));
TestUtil.rm(tmpRootCloned.toFile());
}
Aggregations