Search in sources :

Example 1 with PomPlaceHolder

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

the class DefaultIncrementalCompilerEnabler method process.

@Override
public ProcessedPoms process(final CompilationRequest req) {
    Path mainPom = Paths.get(req.getInfo().getPrjPath().toString(), 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) {
        List<String> pomsList = new ArrayList<>();
        MavenUtils.searchPoms(Paths.get(req.getInfo().getPrjPath().toString()), // recursive NIO search in all subfolders
        pomsList);
        if (pomsList.size() > 0) {
            processFoundPoms(pomsList, req);
        }
        return new ProcessedPoms(Boolean.TRUE, 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.ProcessedPoms) ArrayList(java.util.ArrayList) PomPlaceHolder(org.kie.workbench.common.services.backend.compiler.impl.PomPlaceHolder)

Example 2 with PomPlaceHolder

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

the class DefaultIncrementalCompilerEnabler method processFoundPoms.

private void processFoundPoms(List<String> poms, CompilationRequest request) {
    for (String pom : poms) {
        Path tmpPom = Paths.get(pom);
        PomPlaceHolder tmpPlaceHolder = editor.readSingle(tmpPom);
        if (!isPresent(tmpPlaceHolder)) {
            editor.write(tmpPom, request);
        }
    }
    Path mainPom = Paths.get(request.getInfo().getPrjPath().toAbsolutePath().toString(), POM_NAME);
    request.getInfo().lateAdditionEnhancedMainPomFile(mainPom);
}
Also used : Path(org.uberfire.java.nio.file.Path) PomPlaceHolder(org.kie.workbench.common.services.backend.compiler.impl.PomPlaceHolder)

Aggregations

PomPlaceHolder (org.kie.workbench.common.services.backend.compiler.impl.PomPlaceHolder)2 Path (org.uberfire.java.nio.file.Path)2 ArrayList (java.util.ArrayList)1 ProcessedPoms (org.kie.workbench.common.services.backend.compiler.impl.ProcessedPoms)1