Search in sources :

Example 11 with AFCompiler

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

the class KieMetadataTest method compileAndloadKieJarSingleMetadataWithPackagedJar.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileAndloadKieJarSingleMetadataWithPackagedJar() throws Exception {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     */
    Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES);
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
    if (!res.isSuccessful()) {
        List<String> msgs = res.getMavenOutput();
        for (String msg : msgs) {
            logger.info(msg);
        }
    }
    assertThat(res.isSuccessful()).isTrue();
    Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
    assertThat(metaDataOptional).isPresent();
    KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
    assertThat(kieModuleMetaInfo).isNotNull();
    Optional<KieModule> kieModuleOptional = res.getKieModule();
    assertThat(kieModuleOptional).isPresent();
    KieModule kModule = kieModuleOptional.get();
    assertThat(res.getDependenciesAsURI()).hasSize(4);
    KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
    assertThat(kieModuleMetaData).isNotNull();
// comment if you want read the log file after the test run
}
Also used : Path(org.uberfire.java.nio.file.Path) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) KieModuleMetaData(org.kie.scanner.KieModuleMetaData) KieModuleMetaDataImpl(org.kie.scanner.KieModuleMetaDataImpl) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) KieModuleMetaInfo(org.drools.core.rule.KieModuleMetaInfo) 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) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) KieModule(org.kie.api.builder.KieModule) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with AFCompiler

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

the class KieMetadataTest method compileAndloadKieJarSingleMetadata.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileAndloadKieJarSingleMetadata() {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     */
    try {
        Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES);
        final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
        WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
        CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
        KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
        TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
        if (!res.isSuccessful()) {
            List<String> msgs = res.getMavenOutput();
            for (String msg : msgs) {
                logger.info(msg);
            }
        }
        assertThat(res.isSuccessful()).isTrue();
        Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
        assertThat(metaDataOptional).isPresent();
        KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
        assertThat(kieModuleMetaInfo).isNotNull();
        Optional<KieModule> kieModuleOptional = res.getKieModule();
        assertThat(kieModuleOptional).isPresent();
        assertThat(res.getDependenciesAsURI()).hasSize(4);
    // comment if you want read the log file after the test run
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) KieModuleMetaInfo(org.drools.core.rule.KieModuleMetaInfo) 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) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) KieModule(org.kie.api.builder.KieModule) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with AFCompiler

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

the class ArchetypeTest method testArchetypeGenerate.

@Test
public void testArchetypeGenerate() throws Exception {
    Path tmpRoot = Files.createTempDirectory("repo");
    Path tmp = Paths.get(tmpRoot.toAbsolutePath().toString());
    assertThat(isDirEmpty(tmpRoot)).isTrue();
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(tmp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath.toAbsolutePath().toString(), info, new String[] { MavenConfig.ARCHETYPE_GENERATE, MavenConfig.ARCHETYPE_GENERATE_BLANK, MavenConfig.GROUP_ID + groupId, MavenConfig.ARTIFACT_ID + artifactId, MavenConfig.ARCHETYPE_ARTIFACT_ID + archetypeArtifactId }, Boolean.TRUE);
    CompilationResponse res = compiler.compile(req);
    TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmpRoot, res, this.getClass(), testName);
    assertThat(res.isSuccessful()).isTrue();
    assertThat(res.getMavenOutput().size()).isGreaterThan(0);
    assertThat(isDirEmpty(tmpRoot)).isFalse();
    Path prj = Paths.get(tmpRoot.toAbsolutePath().toString(), artifactId);
    assertThat(isDirEmpty(prj)).isFalse();
    Path appDir = Paths.get(prj.toAbsolutePath().toString(), "/src/main/java/" + (groupId.replace(".", "/")));
    assertThat(isDirEmpty(appDir)).isFalse();
    Path testDir = Paths.get(prj.toAbsolutePath().toString(), "/src/test/java/" + (groupId.replace(".", "/")));
    assertThat(isDirEmpty(testDir)).isFalse();
    Path pom = Paths.get(tmpRoot.toAbsolutePath().toString(), artifactId + "/pom.xml");
    assertThat(Files.exists(pom)).isTrue();
    TestUtil.rm(tmpRoot.toFile());
}
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 14 with AFCompiler

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

the class DefaultRemoteExecutor method internalBuild.

private CompletableFuture<KieCompilationResponse> internalBuild(String projectPath, String mavenRepoPath, String settingsXmlPath, boolean skipProjectDepCreation, String goal) {
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(projectPath));
    AFCompiler compiler = getCompiler(projectPath);
    CompilationRequest req;
    if (settingsXmlPath != null) {
        req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.ALTERNATE_USER_SETTINGS + settingsXmlPath, goal }, skipProjectDepCreation);
    } else {
        req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { goal }, skipProjectDepCreation);
    }
    return runInItsOwnThread(compiler, req);
}
Also used : 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)

Example 15 with AFCompiler

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

the class DefaultLocalExecutor method setupCompileInfo.

private CompilerAggregateEntryCache setupCompileInfo(Path workingDir) {
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.UPDATE_JGIT_BEFORE_BUILD, KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(workingDir);
    return new CompilerAggregateEntryCache(compiler, info);
}
Also used : WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler)

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