Search in sources :

Example 1 with ProcessedPoms

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

the class BaseMavenCompiler method compileSync.

@Override
public T compileSync(CompilationRequest req) {
    if (logger.isDebugEnabled()) {
        logger.debug("KieCompilationRequest:{}", req);
    }
    if (!req.getInfo().getEnhancedMainPomFile().isPresent()) {
        ProcessedPoms processedPoms = enabler.process(req);
        if (!processedPoms.getResult()) {
            return buildDefaultCompilationResponse(Boolean.FALSE, "Processing poms failed", Collections.emptyList());
        }
    }
    req.getKieCliRequest().getRequest().setLocalRepositoryPath(req.getMavenRepo());
    /**
     *         The classworld is now Created in the NioMavenCompiler and in the DefaultMaven compielr for this reasons:
     *         problem: https://stackoverflow.com/questions/22410706/error-when-execute-mavencli-in-the-loop-maven-embedder
     *         problem:https://stackoverflow.com/questions/40587683/invocation-of-mavencli-fails-within-a-maven-plugin
     *         solution:https://dev.eclipse.org/mhonarc/lists/sisu-users/msg00063.html
     */
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    ClassWorld kieClassWorld = new ClassWorld("plexus.core", getClass().getClassLoader());
    int exitCode = cli.doMain(req.getKieCliRequest(), kieClassWorld);
    Thread.currentThread().setContextClassLoader(original);
    if (exitCode == 0) {
        return (T) buildDefaultCompilationResponse(Boolean.TRUE);
    } else {
        return (T) buildDefaultCompilationResponse(Boolean.FALSE);
    }
}
Also used : ProcessedPoms(org.kie.workbench.common.services.backend.compiler.impl.ProcessedPoms) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld)

Example 2 with ProcessedPoms

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

Aggregations

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