use of org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms in project kie-wb-common by kiegroup.
the class DefaultIncrementalCompilerEnabler method process.
@Override
public ProcessedPoms process(final CompilationRequest req) {
if (!isValidConfiguration) {
return new ProcessedPoms(Boolean.FALSE, Collections.emptyList());
}
Path mainPom = Paths.get(URI.create(FILE_URI + req.getKieCliRequest().getWorkingDirectory() + "/" + POM_NAME));
if (!Files.isReadable(mainPom)) {
return new ProcessedPoms(Boolean.FALSE, Collections.emptyList());
}
PomPlaceHolder placeHolder = editor.readSingle(mainPom);
// check if the main pom is already scanned and edited
Boolean isPresent = isPresent(placeHolder);
if (placeHolder.isValid() && !isPresent) {
// recursive NIO search in all subfolders
List<String> pomsList = MavenUtils.searchPoms(mainPom.getParent());
boolean result = false;
if (pomsList.size() > 0) {
result = processFoundPoms(pomsList, req);
}
return new ProcessedPoms(result, pomsList);
} else {
return new ProcessedPoms(Boolean.FALSE, Collections.emptyList());
}
}
use of org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms in project kie-wb-common by kiegroup.
the class DefaultIncrementalCompilerEnablerTest method processTest.
@Test
public void processTest() {
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);
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);
}
use of org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms 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>");
}
Aggregations