Search in sources :

Example 6 with BaseMavenCompiler

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

the class ClasspathDepsAfterDecoratorTest method compileTest.

@Test
public void compileTest() {
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    ClasspathDepsAfterDecorator decorator = new ClasspathDepsAfterDecorator(new BaseMavenCompiler(true, false));
    CompilationResponse res = decorator.compile(req);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(res.isSuccessful()).isTrue();
        softly.assertThat(res.getDependencies()).hasSize(4);
    });
}
Also used : DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) 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 7 with BaseMavenCompiler

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

the class KieAfterDecoratorTest method compileWithouKieMavenPlugin.

@Test
public void compileWithouKieMavenPlugin() throws Exception {
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, createdNewPrjInRepo("normal-dummy", ResourcesConstants.DUMMY), new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
    KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(kieRes.isSuccessful()).isTrue();
        softly.assertThat(kieRes.getMavenOutput()).isEmpty();
        softly.assertThat(kieRes.getKieModule()).isNotNull();
        softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
    });
}
Also used : DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) 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) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Example 8 with BaseMavenCompiler

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

the class KieAfterDecoratorTest method compileWithOverrideTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileWithOverrideTest() throws Exception {
    Map<Path, InputStream> override = new HashMap<>();
    Path path = Paths.get(tmpRoot + "/src/main/java/org/kie/maven/plugin/test/Person.java");
    InputStream input = new FileInputStream(new File(ResourcesConstants.KJAR_2_SINGLE_RESOURCES_OVERRIDE + "/src/main/java/org/kie/maven/plugin/test/Person.java"));
    override.put(path, input);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
    KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req, override);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(kieRes.isSuccessful()).isTrue();
        softly.assertThat(kieRes.getMavenOutput()).isEmpty();
        softly.assertThat(kieRes.getKieModule()).isNotNull();
        softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
    });
}
Also used : Path(org.uberfire.java.nio.file.Path) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) File(java.io.File) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) FileInputStream(java.io.FileInputStream) 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) Ignore(org.junit.Ignore) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Example 9 with BaseMavenCompiler

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

the class KieAfterDecoratorTest method compileTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileTest() {
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
    KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(kieRes.isSuccessful()).isTrue();
        softly.assertThat(kieRes.getMavenOutput()).isEmpty();
        softly.assertThat(kieRes.getKieModule()).isNotNull();
        softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
    });
}
Also used : DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) 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) Ignore(org.junit.Ignore) BaseCompilerTest(org.kie.workbench.common.services.backend.compiler.BaseCompilerTest) Test(org.junit.Test)

Example 10 with BaseMavenCompiler

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

the class KieMavenCompilerFactory method createAndAddNewCompiler.

private static <T extends CompilationResponse> AFCompiler<T> createAndAddNewCompiler(Set<KieDecorator> decorators) {
    boolean enableIncremental = decorators.contains(KieDecorator.ENABLE_INCREMENTAL_BUILD);
    boolean enableLogging = decorators.contains(KieDecorator.ENABLE_LOGGING);
    // Order of the construction of the decorators matters, DO not change the order.
    AFCompiler compiler = new BaseMavenCompiler(enableIncremental, enableLogging);
    if (decorators.contains(KieDecorator.STORE_BUILD_CLASSPATH)) {
        compiler = new ClasspathDepsAfterDecorator(compiler);
    }
    if (decorators.contains(KieDecorator.ENABLE_LOGGING)) {
        compiler = new OutputLogAfterDecorator(compiler);
    }
    if (decorators.contains(KieDecorator.STORE_KIE_OBJECTS)) {
        compiler = new KieAfterDecorator(compiler);
    }
    if (decorators.contains(KieDecorator.UPDATE_JGIT_BEFORE_BUILD)) {
        compiler = new JGITCompilerBeforeDecorator(compiler);
    }
    return compiler;
}
Also used : KieAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.KieAfterDecorator) ClasspathDepsAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.ClasspathDepsAfterDecorator) JGITCompilerBeforeDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.JGITCompilerBeforeDecorator) OutputLogAfterDecorator(org.kie.workbench.common.services.backend.compiler.impl.decorators.OutputLogAfterDecorator) BaseMavenCompiler(org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler)

Aggregations

BaseMavenCompiler (org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler)14 Test (org.junit.Test)12 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)12 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)12 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)12 CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)8 Path (org.uberfire.java.nio.file.Path)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)4 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)4 File (java.io.File)3 FileSystem (org.uberfire.java.nio.file.FileSystem)3 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)3 Ignore (org.junit.Ignore)2 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)2 ClasspathDepsAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.ClasspathDepsAfterDecorator)2 KieAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.KieAfterDecorator)2 OutputLogAfterDecorator (org.kie.workbench.common.services.backend.compiler.impl.decorators.OutputLogAfterDecorator)2