Search in sources :

Example 36 with KieCompilationResponse

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

the class MavenRestHandler method postAsync.

/**
 * Endpoint to ask an async build
 */
@POST
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public void postAsync(@Suspended AsyncResponse ar, @HeaderParam("project") String projectRepo, @HeaderParam("mavenrepo") String mavenRepoPath, @HeaderParam("settings_xml") String settingsXmlPath) throws Exception {
    CompletableFuture<KieCompilationResponse> response = compilerService.build(projectRepo, mavenRepoPath, settingsXmlPath);
    response.whenCompleteAsync((kieCompilationResponse, throwable) -> {
        if (throwable != null) {
            logger.error(throwable.getMessage());
            ar.resume(Response.serverError().build());
        } else {
            byte[] bytes = RestUtils.serialize(new DefaultHttpCompilationResponse(kieCompilationResponse));
            ar.resume(Response.ok(bytes).build());
        }
    });
}
Also used : DefaultHttpCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultHttpCompilationResponse) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 37 with KieCompilationResponse

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

the class CompilerOffProcessServiceTest method offProcessServiceCompileAsyncTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void offProcessServiceCompileAsyncTest() throws Exception {
    CompilerOffprocessService service = new CompilerOffprocessServiceImpl(executor, queueProvider);
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjPath);
    String uuid = UUID.randomUUID().toString();
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    CompletableFuture<KieCompilationResponse> futureRes = service.compile(req);
    logger.info("offProcessOneBuildAsyncTest build completed");
    KieCompilationResponse res = futureRes.get();
    assertThat(res).isNotNull();
    assertThat(res.isSuccessful()).isTrue();
    assertThat(res.getMavenOutput()).isNotEmpty();
    DefaultKieCompilationResponse kres = (DefaultKieCompilationResponse) res;
    assertThat(uuid).isEqualToIgnoringCase(kres.getRequestUUID());
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilerOffprocessServiceImpl(org.kie.workbench.common.services.backend.compiler.offprocess.service.impl.CompilerOffprocessServiceImpl) 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) DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) Ignore(org.junit.Ignore) CompilerChronicleCoordinatorTest(org.kie.workbench.common.services.backend.compiler.offprocess.CompilerChronicleCoordinatorTest) Test(org.junit.Test)

Example 38 with KieCompilationResponse

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

the class DefaultLocalExecutor method internalBuild.

private CompletableFuture<KieCompilationResponse> internalBuild(Path projectPath, String mavenRepoPath, boolean skipProjectDepCreation, String[] args) {
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(projectPath);
    AFCompiler compiler = getCompiler(projectPath);
    CompilationRequest req = getDefaultRequest(mavenRepoPath, info, skipProjectDepCreation, args);
    return CompletableFuture.supplyAsync(() -> ((KieCompilationResponse) compiler.compile(req)), executor);
}
Also used : WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) 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)

Example 39 with KieCompilationResponse

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

the class DefaultLocalExecutor method internalBuild.

private CompletableFuture<KieCompilationResponse> internalBuild(Path projectPath, String mavenRepoPath, String settingXML, boolean skipProjectDepCreation, String goal, Map<Path, InputStream> override) {
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(projectPath);
    AFCompiler compiler = getCompiler(projectPath);
    CompilationRequest req;
    if (settingXML != null) {
        req = getDefaultRequest(mavenRepoPath, info, skipProjectDepCreation, new String[] { MavenCLIArgs.ALTERNATE_USER_SETTINGS + settingXML, goal });
    } else {
        req = getDefaultRequest(mavenRepoPath, info, skipProjectDepCreation, new String[] { goal });
    }
    return CompletableFuture.supplyAsync(() -> ((KieCompilationResponse) compiler.compile(req, override)), executor);
}
Also used : WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) 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)

Example 40 with KieCompilationResponse

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

the class DefaultLocalExecutorTest method buildNonExistentProject.

@Test
public void buildNonExistentProject() throws Exception {
    DefaultLocalExecutor executor = new DefaultLocalExecutor(executorService);
    CompletableFuture<KieCompilationResponse> futureRes = executor.build(tmpRoot, mavenRepoPath, TestUtilMaven.getSettingsFile());
    KieCompilationResponse res = futureRes.get();
    assertThat(res.isSuccessful()).isFalse();
}
Also used : KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Aggregations

KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)65 Test (org.junit.Test)58 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)48 Ignore (org.junit.Ignore)30 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)17 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)13 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)12 Path (org.uberfire.java.nio.file.Path)11 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)7 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 KieModuleMetaInfo (org.drools.core.rule.KieModuleMetaInfo)6 KieModule (org.kie.api.builder.KieModule)6 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 InputStream (java.io.InputStream)5 HashMap (java.util.HashMap)5 BaseMavenCompiler (org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ExecutionException (java.util.concurrent.ExecutionException)3 ExecutorService (java.util.concurrent.ExecutorService)3