Search in sources :

Example 1 with PomPlaceHolder

use of org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.PomPlaceHolder 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 PomPlaceHolder

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

the class DefaultIncrementalCompilerEnabler method processFoundPoms.

private boolean processFoundPoms(List<String> poms, CompilationRequest request) {
    boolean result = true;
    for (String pom : poms) {
        Path tmpPom = Paths.get(URI.create(FILE_URI + pom));
        PomPlaceHolder tmpPlaceHolder = editor.readSingle(tmpPom);
        if (!isPresent(tmpPlaceHolder)) {
            result = result && editor.write(tmpPom, request);
        }
    }
    return result;
}
Also used : Path(org.uberfire.java.nio.file.Path) PomPlaceHolder(org.kie.workbench.common.services.backend.compiler.impl.pomprocessor.PomPlaceHolder)

Aggregations

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