Search in sources :

Example 1 with ProcessedPoms

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());
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ProcessedPoms(org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms) PomPlaceHolder(org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.PomPlaceHolder)

Example 2 with ProcessedPoms

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);
}
Also used : ProcessedPoms(org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) 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 3 with ProcessedPoms

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

Aggregations

ProcessedPoms (org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.ProcessedPoms)3 Test (org.junit.Test)2 BaseCompilerTest (org.kie.workbench.common.services.backend.compiler.BaseCompilerTest)2 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)2 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)2 Properties (java.util.Properties)1 PomPlaceHolder (org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.PomPlaceHolder)1 Path (org.uberfire.java.nio.file.Path)1