Search in sources :

Example 6 with AFCompiler

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);
}
Also used : KieAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.KieAfterDecorator) JGITCompilerBeforeDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.JGITCompilerBeforeDecorator) OutputLogAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.OutputLogAfterDecorator) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) Test(org.junit.Test)

Example 7 with AFCompiler

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);
}
Also used : AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) Test(org.junit.Test)

Example 8 with AFCompiler

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);
}
Also used : KieAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.KieAfterDecorator) JGITCompilerBeforeDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.JGITCompilerBeforeDecorator) ClasspathDepsAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.ClasspathDepsAfterDecorator) OutputLogAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.OutputLogAfterDecorator) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) Test(org.junit.Test)

Example 9 with AFCompiler

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();
}
Also used : Path(org.uberfire.java.nio.file.Path) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Test(org.junit.Test)

Example 10 with AFCompiler

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();
}
Also used : Path(org.uberfire.java.nio.file.Path) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) ArrayList(java.util.ArrayList) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)39 Test (org.junit.Test)27 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)26 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)24 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)24 Path (org.uberfire.java.nio.file.Path)14 CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)13 KieAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.KieAfterDecorator)8 OutputLogAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.OutputLogAfterDecorator)7 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)7 File (java.io.File)6 HashMap (java.util.HashMap)6 Ignore (org.junit.Ignore)5 ClasspathDepsAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.ClasspathDepsAfterDecorator)5 JGITCompilerBeforeDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.JGITCompilerBeforeDecorator)5 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)5 URI (java.net.URI)4 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)3 KieModuleMetaInfo (org.drools.core.rule.KieModuleMetaInfo)3 Git (org.eclipse.jgit.api.Git)3