Search in sources :

Example 11 with DefaultCompilationRequest

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest 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 12 with DefaultCompilationRequest

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.

the class DefaultMavenIncrementalCompilerTest method testIsValidMavenHome.

@Test
public void testIsValidMavenHome() throws Exception {
    Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_DIR);
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(new HashSet<>());
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.VERSION }, Boolean.TRUE);
    CompilationResponse res = compiler.compile(req);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
}
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) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Test(org.junit.Test)

Example 13 with DefaultCompilationRequest

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.

the class DefaultMavenIncrementalCompilerTest method testError.

@Test
public void testError() throws Exception {
    Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_KIE_MULTIMODULE_UNTOUCHED_WITH_ERROR_DIR);
    // compiler
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.ENABLE_INCREMENTAL_BUILD));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE, MavenCLIArgs.FAIL_NEVER }, Boolean.TRUE);
    CompilationResponse res = compiler.compile(req);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(temp, res, this.getClass(), testName);
    // checks
    assertThat(res.isSuccessful()).isTrue();
    List<String> fileNames = new ArrayList<>();
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(temp + "/dummyA/target/classes/dummy"))) {
        for (Path path : directoryStream) {
            fileNames.add(path.toString());
        }
    }
    assertThat(fileNames).hasSize(1);
    String dummyAJava = null;
    if (fileNames.get(0).endsWith("DummyA.class")) {
        dummyAJava = fileNames.get(0);
    }
    assertThat(dummyAJava).isNotNull();
    fileNames = new ArrayList<>();
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(temp + "/dummyB/target/classes/dummy"))) {
        for (Path path : directoryStream) {
            fileNames.add(path.toString());
        }
    }
    assertThat(fileNames).hasSize(1);
    String dummyBJava = null;
    if (fileNames.get(0).endsWith("DummyB.class")) {
        dummyBJava = fileNames.get(0);
    }
    assertThat(dummyBJava).isNotNull();
    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();
    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) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Test(org.junit.Test)

Example 14 with DefaultCompilationRequest

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.

the class JGITCompilerBeforeDecoratorTest method compileWithEmptyOverrideTest.

@Test
public void compileWithEmptyOverrideTest() throws Exception {
    final FileSystem fileSystem = createFileSystem("myrepo");
    // Compile the repo
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(fileSystem.getPath("/"));
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE }, Boolean.TRUE);
    Map<Path, InputStream> override = new HashMap<>();
    JGITCompilerBeforeDecorator compiler = new JGITCompilerBeforeDecorator(new BaseMavenCompiler(true, false));
    CompilationResponse res = compiler.compile(req, override);
    final java.nio.file.Path tempPath = ((Git) compiler.getGitMap().get(fileSystem)).getRepository().getDirectory().toPath().getParent();
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tempPath, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    Path incrementalConfiguration = Paths.get(tempPath.toUri() + TARGET_TAKARI_PLUGIN);
    assertThat(incrementalConfiguration.toFile()).exists();
    TestUtil.rm(tempPath.toFile());
}
Also used : Path(org.uberfire.java.nio.file.Path) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) JGitFileSystem(org.uberfire.java.nio.fs.jgit.JGitFileSystem) FileSystem(org.uberfire.java.nio.file.FileSystem) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) Path(org.uberfire.java.nio.file.Path) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Example 15 with DefaultCompilationRequest

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest in project kie-wb-common by kiegroup.

the class ServerIPCImpl method build.

private static DefaultKieCompilationResponseOffProcess build(String prjPath, String mavenRepo, String alternateSettingsAbsPath, String uuid) {
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_KIE_OBJECTS));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get("file://" + prjPath));
    CompilationRequest req;
    if (StringUtils.isNotEmpty(alternateSettingsAbsPath)) {
        req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.DEPENDENCY_RESOLVE, MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    } else {
        req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.DEPENDENCY_RESOLVE, MavenCLIArgs.COMPILE }, Boolean.FALSE, uuid);
    }
    KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
    return new DefaultKieCompilationResponseOffProcess(res);
}
Also used : DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) 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) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)

Aggregations

DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)60 Test (org.junit.Test)51 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)47 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)40 Path (org.uberfire.java.nio.file.Path)36 CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)23 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)21 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)16 HashMap (java.util.HashMap)15 File (java.io.File)14 Ignore (org.junit.Ignore)14 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)14 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)13 BaseMavenCompiler (org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler)12 URI (java.net.URI)8 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)6 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 KieModuleMetaInfo (org.drools.core.rule.KieModuleMetaInfo)6 Git (org.eclipse.jgit.api.Git)6