Search in sources :

Example 21 with CompilationRequest

use of org.kie.workbench.common.services.backend.compiler.CompilationRequest 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 22 with CompilationRequest

use of org.kie.workbench.common.services.backend.compiler.CompilationRequest 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 23 with CompilationRequest

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

the class DefaultIncrementalCompilerEnablerTest method processDisabledMavenDefaultCompilerTest.

@Test
public void processDisabledMavenDefaultCompilerTest() {
    Properties props = loadProperties("IncrementalCompiler.properties");
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    byte[] encoded = Files.readAllBytes(Paths.get(tmpRoot + "/dummy/pom.xml"));
    String pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
    assertThat(pomAsAstring).doesNotContain(TestConstants.KIE_TAKARI_LIFECYCLE_ARTIFACT);
    assertThat(pomAsAstring).doesNotContain(TestConstants.MAVEN_ARTIFACT);
    IncrementalCompilerEnabler enabler = new DefaultIncrementalCompilerEnabler();
    ProcessedPoms poms = enabler.process(req);
    assertThat(poms).isNotNull();
    assertThat(poms.getResult()).isTrue();
    assertThat(poms.getProjectPoms()).hasSize(1);
    String pom = poms.getProjectPoms().get(0);
    assertThat(pom).isEqualTo(tmpRoot.toString() + "/dummy/pom.xml");
    encoded = Files.readAllBytes(Paths.get(tmpRoot + "/dummy/pom.xml"));
    pomAsAstring = new String(encoded, StandardCharsets.UTF_8);
    assertThat(pomAsAstring).contains(TestConstants.KIE_TAKARI_LIFECYCLE_ARTIFACT);
    assertThat(pomAsAstring).contains(TestConstants.MAVEN_ARTIFACT);
    String mavenCompilerVersion = props.getProperty(ConfigurationKey.MAVEN_COMPILER_PLUGIN_VERSION.name());
    assertThat(pomAsAstring).contains("<version>" + mavenCompilerVersion + "</version>");
}
Also used : ProcessedPoms(org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) Properties(java.util.Properties) 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 24 with CompilationRequest

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

the class OutputLogAfterDecoratorTest method compileFailedTest.

@Test
public void compileFailedTest() throws Exception {
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, createdNewPrjInRepo("dummy-fail", ResourcesConstants.DUMMY_FAIL_DEPS_SIMPLE), new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    OutputLogAfterDecorator decorator = new OutputLogAfterDecorator(new BaseMavenCompiler(true, true));
    CompilationResponse res = decorator.compile(req);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(res.isSuccessful()).isFalse();
        softly.assertThat(res.getMavenOutput().size()).isGreaterThan(0);
    });
}
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 25 with CompilationRequest

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

the class OutputLogAfterDecoratorTest method compileWithOverrideTest.

@Test
public void compileWithOverrideTest() throws Exception {
    Map<Path, InputStream> override = new HashMap<>();
    org.uberfire.java.nio.file.Path path = org.uberfire.java.nio.file.Paths.get(tmpRoot + "/src/main/java/dummy/DummyOverride.java");
    InputStream input = new FileInputStream(new File(ResourcesConstants.DUMMY_OVERRIDE + "/src/main/java/dummy/DummyOverride.java"));
    override.put(path, input);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
    OutputLogAfterDecorator decorator = new OutputLogAfterDecorator(new BaseMavenCompiler(true, true));
    CompilationResponse res = decorator.compile(req, override);
    SoftAssertions.assertSoftly(softly -> {
        softly.assertThat(res.isSuccessful()).isTrue();
        softly.assertThat(res.getMavenOutput().size()).isGreaterThan(0);
    });
}
Also used : Path(org.uberfire.java.nio.file.Path) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Path(org.uberfire.java.nio.file.Path) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) FileInputStream(java.io.FileInputStream) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) File(java.io.File) 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)

Aggregations

CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)43 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)43 Test (org.junit.Test)34 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)30 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)24 CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)23 Path (org.uberfire.java.nio.file.Path)19 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)16 BaseMavenCompiler (org.kie.workbench.common.services.backend.compiler.impl.BaseMavenCompiler)12 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)12 HashMap (java.util.HashMap)10 Ignore (org.junit.Ignore)10 File (java.io.File)9 JGitFileSystem (org.uberfire.java.nio.fs.jgit.JGitFileSystem)8 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)6 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