use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieMavenCompilerFactoryTest method jgitBeforeAndKieAndLogAfterDecoratorTest.
@Test
public void jgitBeforeAndKieAndLogAfterDecoratorTest() {
final AFCompiler jgitBeforeAndLogAfter = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.UPDATE_JGIT_BEFORE_BUILD, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.ENABLE_LOGGING));
assertThat(jgitBeforeAndLogAfter).isInstanceOf(JGITCompilerBeforeDecorator.class);
AFCompiler kieAfterDecorator = ((JGITCompilerBeforeDecorator) jgitBeforeAndLogAfter).getCompiler();
assertThat(kieAfterDecorator).isInstanceOf(KieAfterDecorator.class);
AFCompiler outputLofAfterDecorator = ((KieAfterDecorator) kieAfterDecorator).getCompiler();
assertThat(outputLofAfterDecorator).isInstanceOf(OutputLogAfterDecorator.class);
AFCompiler baseMavenCompiler = ((OutputLogAfterDecorator) outputLofAfterDecorator).getCompiler();
assertThat(baseMavenCompiler).isInstanceOf(BaseMavenCompiler.class);
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieMavenCompilerFactoryTest method jGitBeforeDecoratorTest.
@Test
public void jGitBeforeDecoratorTest() {
final AFCompiler jgitBefore = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.UPDATE_JGIT_BEFORE_BUILD));
assertThat(jgitBefore).isInstanceOf(JGITCompilerBeforeDecorator.class);
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieMavenCompilerFactoryTest method jgitBeforeAndKieAndLogAndClasspathAfterTest.
@Test
public void jgitBeforeAndKieAndLogAndClasspathAfterTest() {
AFCompiler jgitBeforeAndLogAfter = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.UPDATE_JGIT_BEFORE_BUILD, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_BUILD_CLASSPATH));
assertThat(jgitBeforeAndLogAfter).isInstanceOf(JGITCompilerBeforeDecorator.class);
AFCompiler kieAfterDecorator = ((JGITCompilerBeforeDecorator) jgitBeforeAndLogAfter).getCompiler();
assertThat(kieAfterDecorator).isInstanceOf(KieAfterDecorator.class);
AFCompiler outputLofAfterDecorator = ((KieAfterDecorator) kieAfterDecorator).getCompiler();
assertThat(outputLofAfterDecorator).isInstanceOf(OutputLogAfterDecorator.class);
AFCompiler classpathAfter = ((OutputLogAfterDecorator) outputLofAfterDecorator).getCompiler();
assertThat(classpathAfter).isInstanceOf(ClasspathDepsAfterDecorator.class);
AFCompiler baseMavenCompiler = ((ClasspathDepsAfterDecorator) classpathAfter).getCompiler();
assertThat(baseMavenCompiler).isInstanceOf(BaseMavenCompiler.class);
}
use of org.kie.workbench.common.services.backend.compiler.AFCompiler in project kie-wb-common by kiegroup.
the class KieDefaultMavenIncrementalCompilerTest method testIncrementalWithPluginEnabledThreeTime.
@Test
public void testIncrementalWithPluginEnabledThreeTime() throws Exception {
tmpRoot = Files.createTempDirectory("repo");
// NIO creation and copy content
Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_DIR);
// end NIO
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.FALSE);
CompilationResponse res = compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
assertThat(res.isSuccessful()).isTrue();
res = compiler.compile(req);
assertThat(res.isSuccessful()).isTrue();
res = compiler.compile(req);
assertThat(res.isSuccessful()).isTrue();
Path incrementalConfiguration = Paths.get(tmp.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.AFCompiler 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