Search in sources :

Example 36 with AFCompiler

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

the class KieMavenCompilerFactoryTest method classpathDepsAfterDecoratorTest.

@Test
public void classpathDepsAfterDecoratorTest() {
    final AFCompiler classpathAfter = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_BUILD_CLASSPATH));
    assertThat(classpathAfter).isInstanceOf(ClasspathDepsAfterDecorator.class);
}
Also used : AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) Test(org.junit.Test)

Example 37 with AFCompiler

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

the class KieClassLoaderProviderTest method compileProjectInRepo.

private CompilationResponse compileProjectInRepo(String... mavenPhases) throws IOException {
    tmpRoot = Files.createTempDirectory("repo");
    tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_KIE_MULTIMODULE_CLASSLOADER_DIR);
    uberfireTmp = Paths.get(tmp.toAbsolutePath().toString());
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(new HashSet<>());
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(uberfireTmp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, mavenPhases, Boolean.FALSE);
    return compiler.compile(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 38 with AFCompiler

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

the class KieDefaultMavenIncrementalCompilerTest method compileProjectInRepo.

private CompilationResponse compileProjectInRepo(String... mavenPhases) throws IOException {
    tmpRoot = Files.createTempDirectory("repo");
    temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.DUMMY_DIR);
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_INCREMENTAL_BUILD));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, mavenPhases, Boolean.FALSE);
    return compiler.compile(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 39 with AFCompiler

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

the class KieMetadataTest method compileAndLoadKieJarMetadataAllResourcesPackagedJar.

@Ignore("https://issues.redhat.com/browse/AF-2741\n" + "https://issues.redhat.com/browse/AF-2892")
// AF-1459 it tooks 30% of the time of the time spent by all module's test (108), alone it took 30 sec
@Test
public void compileAndLoadKieJarMetadataAllResourcesPackagedJar() throws Exception {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     */
    Path temp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_ALL_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(temp);
    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(temp, 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();
    Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
    assertThat(rulesBP).hasSize(6);
    Map<String, TypeMetaInfo> typesMI = kieModuleMetaInfo.getTypeMetaInfos();
    // This is a "magic number" test and may or may not be valid since changes
    // to the mechanism for generating classes, especially in PMML processing,
    // may cause this value to change.
    assertThat(typesMI).hasSize(22);
    Optional<KieModule> kieModuleOptional = res.getKieModule();
    assertThat(kieModuleOptional).isPresent();
    assertThat(res.getDependenciesAsURI()).hasSize(4);
    KieModule kModule = kieModuleOptional.get();
    KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
    assertThat(kieModuleMetaData).isNotNull();
}
Also used : Path(org.uberfire.java.nio.file.Path) EnumSet(java.util.EnumSet) Set(java.util.Set) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) KieModuleMetaData(org.kie.scanner.KieModuleMetaData) KieModuleMetaDataImpl(org.kie.scanner.KieModuleMetaDataImpl) TypeMetaInfo(org.drools.core.rule.TypeMetaInfo) 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)

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