@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>"); }
@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); Boolean isPresent = isPresent(placeHolder); if (placeHolder.isValid() && !isPresent) { 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()); } }
DefaultIncrementalCompilerEnabler implements IncrementalCompilerEnabler { @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); Boolean isPresent = isPresent(placeHolder); if (placeHolder.isValid() && !isPresent) { 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()); } } }
DefaultIncrementalCompilerEnabler implements IncrementalCompilerEnabler { @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); Boolean isPresent = isPresent(placeHolder); if (placeHolder.isValid() && !isPresent) { 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()); } } DefaultIncrementalCompilerEnabler(); }
DefaultIncrementalCompilerEnabler implements IncrementalCompilerEnabler { @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); Boolean isPresent = isPresent(placeHolder); if (placeHolder.isValid() && !isPresent) { 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()); } } DefaultIncrementalCompilerEnabler(); @Override ProcessedPoms process(final CompilationRequest req); Set<PomPlaceHolder> getHistory(); Boolean cleanHistory(); }
DefaultIncrementalCompilerEnabler implements IncrementalCompilerEnabler { @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); Boolean isPresent = isPresent(placeHolder); if (placeHolder.isValid() && !isPresent) { 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()); } } DefaultIncrementalCompilerEnabler(); @Override ProcessedPoms process(final CompilationRequest req); Set<PomPlaceHolder> getHistory(); Boolean cleanHistory();  }