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();
});
}
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();
});
}
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>");
}
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);
});
}
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);
});
}
Aggregations