use of org.kie.workbench.common.services.backend.compiler.CompilationResponse 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.CompilationResponse 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.CompilationResponse in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method testIsValidMavenHome.
@Test
public void testIsValidMavenHome() throws Exception {
CompilationResponse res = compileProjectInRepo(MavenCLIArgs.VERSION);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
}
use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method testIncrementalWithPluginEnabled.
@Test
public void testIncrementalWithPluginEnabled() throws Exception {
CompilationResponse res = compileProjectInRepo(MavenCLIArgs.COMPILE);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
Path incrementalConfiguration = Paths.get(temp.toAbsolutePath().toString(), "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
assertThat(incrementalConfiguration.toFile()).exists();
}
use of org.kie.workbench.common.services.backend.compiler.CompilationResponse in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method testCheckIncrementalWithChanges.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void testCheckIncrementalWithChanges() throws Exception {
String alternateSettingsAbsPath = TestUtilMaven.getSettingsFile();
tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_KIE_INCREMENTAL);
// end NIO
// compiler
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.TRUE);
CompilationResponse res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
// checks
assertThat(res.isSuccessful()).isTrue();
List<String> fileNames = new ArrayList<>();
// impl
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(temp + "/target/classes/dummy"))) {
for (Path path : directoryStream) {
fileNames.add(path.toString());
}
}
assertThat(fileNames).hasSize(2);
String dummyJava;
if (fileNames.get(0).endsWith("Dummy.class")) {
dummyJava = fileNames.get(0);
} else {
dummyJava = fileNames.get(1);
}
long dummyJavaSize = Paths.get(dummyJava).toFile().length();
List<String> output = res.getMavenOutput();
assertThat(isTextPresent(output, "Previous incremental build state does not exist, performing full build")).isTrue();
assertThat(isTextPresent(output, "Compiled 2 out of 2 sources ")).isTrue();
Files.delete(Paths.get(temp + "/src/main/java/dummy/DummyA.java"));
// overwrite the class with a new version with two additional methods and one int variable
Files.write(Paths.get(temp + "/src/main/java/dummy/Dummy.java"), Files.readAllBytes(Paths.get("src/test/projects/Dummy.java")));
// second compilation
res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
// checks
assertThat(res.isSuccessful()).isTrue();
fileNames = new ArrayList<>();
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(temp + "/target/classes/dummy"))) {
for (Path path : directoryStream) {
fileNames.add(path.toString());
}
}
assertThat(fileNames).hasSize(1);
assertThat(fileNames.get(0)).endsWith("Dummy.class");
long dummyJavaSizeAfterChanges = Paths.get(dummyJava).toFile().length();
assertThat(dummyJavaSize).isLessThan(dummyJavaSizeAfterChanges);
output = res.getMavenOutput();
assertThat(isTextPresent(output, "Performing incremental build")).isTrue();
assertThat(isTextPresent(output, "Compiled 1 out of 1 sources ")).isTrue();
}
Aggregations