Example usage for org.apache.maven.execution MavenExecutionRequest REACTOR_FAIL_NEVER

List of usage examples for org.apache.maven.execution MavenExecutionRequest REACTOR_FAIL_NEVER

Introduction

In this page you can find the example usage for org.apache.maven.execution MavenExecutionRequest REACTOR_FAIL_NEVER.

Prototype

String REACTOR_FAIL_NEVER

To view the source code for org.apache.maven.execution MavenExecutionRequest REACTOR_FAIL_NEVER.

Click Source Link

Usage

From source file:org.commonjava.emb.boot.embed.EMBEmbedder.java

License:Apache License

public int formatErrorOutput(final EMBExecutionRequest request, final MavenExecutionResult result) {
    if (result.hasExceptions()) {
        final ExceptionHandler handler = new DefaultExceptionHandler();

        final Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;/* w  ww  . ja va2s. com*/

        for (final Throwable exception : result.getExceptions()) {
            final ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary, references, "", shouldShowErrors);

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        logger.error("");

        if (!shouldShowErrors) {
            logger.error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!logger.isDebugEnabled()) {
            logger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            logger.error("");
            logger.error("For more information about the errors and possible solutions"
                    + ", please read the following articles:");

            for (final Map.Entry<String, String> entry : references.entrySet()) {
                logger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            logger.error("");
            logger.error("After correcting the problems, you can resume the build with the command");
            logger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(request.getReactorFailureBehavior())) {
            logger.info("Build failures were ignored.");

            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}

From source file:org.commonjava.emb.boot.main.EMBMain.java

License:Apache License

protected EMBExecutionRequest populateRequest(final CliRequest cliRequest) throws EMBEmbeddingException {
    // cliRequest.builder.build();

    final EMBExecutionRequest request = cliRequest.request;
    final CommandLine commandLine = cliRequest.commandLine;
    final String workingDirectory = cliRequest.workingDirectory;
    final boolean debug = cliRequest.builder.shouldShowDebug();
    final boolean quiet = cliRequest.builder.shouldBeQuiet();
    final boolean showErrors = cliRequest.builder.shouldShowErrors();

    // ----------------------------------------------------------------------
    // Now that we have everything that we need we will fire up plexus and
    // bring the maven component to life for use.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.BATCH_MODE)) {
        request.setInteractiveMode(false);
        cliRequest.builder.embConfiguration().nonInteractive();
    }//from www  .j  av  a2  s.c o m

    boolean noSnapshotUpdates = false;
    if (commandLine.hasOption(CLIManager.SUPRESS_SNAPSHOT_UPDATES)) {
        noSnapshotUpdates = true;
    }

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    @SuppressWarnings("unchecked")
    final List<String> goals = commandLine.getArgList();

    boolean recursive = true;

    // this is the default behavior.
    String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;

    if (commandLine.hasOption(CLIManager.NON_RECURSIVE)) {
        recursive = false;
    }

    if (commandLine.hasOption(CLIManager.FAIL_FAST)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;
    } else if (commandLine.hasOption(CLIManager.FAIL_AT_END)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END;
    } else if (commandLine.hasOption(CLIManager.FAIL_NEVER)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER;
    }

    if (commandLine.hasOption(CLIManager.OFFLINE)) {
        request.setOffline(true);
    }

    boolean updateSnapshots = false;

    if (commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS)) {
        updateSnapshots = true;
    }

    String globalChecksumPolicy = null;

    if (commandLine.hasOption(CLIManager.CHECKSUM_FAILURE_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL;
    } else if (commandLine.hasOption(CLIManager.CHECKSUM_WARNING_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN;
    }

    final File baseDirectory = new File(workingDirectory, "").getAbsoluteFile();

    // ----------------------------------------------------------------------
    // Profile Activation
    // ----------------------------------------------------------------------

    final List<String> activeProfiles = new ArrayList<String>();

    final List<String> inactiveProfiles = new ArrayList<String>();

    if (commandLine.hasOption(CLIManager.ACTIVATE_PROFILES)) {
        final String[] profileOptionValues = commandLine.getOptionValues(CLIManager.ACTIVATE_PROFILES);
        if (profileOptionValues != null) {
            for (int i = 0; i < profileOptionValues.length; ++i) {
                final StringTokenizer profileTokens = new StringTokenizer(profileOptionValues[i], ",");

                while (profileTokens.hasMoreTokens()) {
                    final String profileAction = profileTokens.nextToken().trim();

                    if (profileAction.startsWith("-") || profileAction.startsWith("!")) {
                        inactiveProfiles.add(profileAction.substring(1));
                    } else if (profileAction.startsWith("+")) {
                        activeProfiles.add(profileAction.substring(1));
                    } else {
                        activeProfiles.add(profileAction);
                    }
                }
            }
        }
    }

    ArtifactTransferListener transferListener;

    if (request.isInteractiveMode()) {
        transferListener = new InteractiveTransferListener(cliRequest.builder.standardOut());
    } else {
        transferListener = new BatchTransferListener(cliRequest.builder.standardOut());
    }

    transferListener.setShowChecksumEvents(false);

    String alternatePomFile = null;
    if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
        alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
    }

    int loggingLevel;

    if (debug) {
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
    } else if (quiet) {
        // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level.
        // Ideally, we could use Warn across the board
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_ERROR;
        // TODO:Additionally, we can't change the mojo level because the component key includes the version and it
        // isn't known ahead of time. This seems worth changing.
    } else {
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO;
    }

    File userToolchainsFile;
    if (commandLine.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) {
        userToolchainsFile = new File(commandLine.getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS));
        userToolchainsFile = resolveFile(userToolchainsFile, workingDirectory);
    } else {
        userToolchainsFile = EMBMain.DEFAULT_USER_TOOLCHAINS_FILE;
    }

    request.setBaseDirectory(baseDirectory).setGoals(goals).setSystemProperties(cliRequest.systemProperties)
            .setUserProperties(cliRequest.userProperties).setReactorFailureBehavior(reactorFailureBehaviour)
            // default: fail fast
            .setRecursive(recursive)
            // default: true
            .setShowErrors(showErrors).addActiveProfiles(activeProfiles)
            // optional
            .addInactiveProfiles(inactiveProfiles)
            // optional
            .setLoggingLevel(loggingLevel)
            // default: batch mode which goes along with interactive
            .setUpdateSnapshots(updateSnapshots)
            // default: false
            .setNoSnapshotUpdates(noSnapshotUpdates)
            // default: false
            .setGlobalChecksumPolicy(globalChecksumPolicy)
            // default: warn
            .setUserToolchainsFile(userToolchainsFile);

    if (alternatePomFile != null) {
        final File pom = resolveFile(new File(alternatePomFile), workingDirectory);

        request.setPom(pom);
    } else {
        final File pom = cliRequest.builder.modelProcessor().locatePom(baseDirectory);
        cliRequest.builder.resetContainer();

        if (pom.isFile()) {
            request.setPom(pom);
        }
    }

    if ((request.getPom() != null) && (request.getPom().getParentFile() != null)) {
        request.setBaseDirectory(request.getPom().getParentFile());
    }

    if (commandLine.hasOption(CLIManager.RESUME_FROM)) {
        request.setResumeFrom(commandLine.getOptionValue(CLIManager.RESUME_FROM));
    }

    if (commandLine.hasOption(CLIManager.PROJECT_LIST)) {
        final String projectList = commandLine.getOptionValue(CLIManager.PROJECT_LIST);
        final String[] projects = StringUtils.split(projectList, ",");
        request.setSelectedProjects(Arrays.asList(projects));
    }

    if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && !commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);
    } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM);
    } else if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_BOTH);
    }

    String localRepoProperty = request.getUserProperties().getProperty(EMBMain.LOCAL_REPO_PROPERTY);

    if (localRepoProperty == null) {
        localRepoProperty = request.getSystemProperties().getProperty(EMBMain.LOCAL_REPO_PROPERTY);
    }

    if (localRepoProperty != null) {
        request.setLocalRepositoryPath(localRepoProperty);
    }

    final String threadConfiguration = commandLine.hasOption(CLIManager.THREADS)
            ? commandLine.getOptionValue(CLIManager.THREADS)
            : request.getSystemProperties().getProperty(EMBMain.THREADS_DEPRECATED); // TODO: Remove
                                                                                                                                                                                                                   // this setting.
                                                                                                                                                                                                                   // Note that the
                                                                                                                                                                                                                   // int-tests use
                                                                                                                                                                                                                   // it

    if (threadConfiguration != null) {
        request.setPerCoreThreadCount(threadConfiguration.contains("C"));
        if (threadConfiguration.contains("W")) {
            LifecycleWeaveBuilder.setWeaveMode(request.getUserProperties());
        }
        request.setThreadCount(threadConfiguration.replace("C", "").replace("W", "").replace("auto", ""));
    }

    return request;
}

From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java

License:Apache License

protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException {
    MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest());

    eventSpyDispatcher.onEvent(request);

    MavenExecutionResult result = maven.execute(request);

    eventSpyDispatcher.onEvent(result);/*w  w w.  j  ava 2  s. c om*/

    eventSpyDispatcher.close();

    if (result.hasExceptions()) {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;

        for (Throwable exception : result.getExceptions()) {
            ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary, references, "", cliRequest.isShowErrors());

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        slf4jLogger.error("");

        if (!cliRequest.isShowErrors()) {
            slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!slf4jLogger.isDebugEnabled()) {
            slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            slf4jLogger.error("");
            slf4jLogger.error("For more information about the errors and possible solutions"
                    + ", please read the following articles:");

            for (Map.Entry<String, String> entry : references.entrySet()) {
                slf4jLogger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            slf4jLogger.error("");
            slf4jLogger.error("After correcting the problems, you can resume the build with the command");
            slf4jLogger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER
                .equals(cliRequest.getRequest().getReactorFailureBehavior())) {
            slf4jLogger.info("Build failures were ignored.");
            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java

License:Apache License

protected MavenExecutionRequest populateRequest(AFCliRequest cliRequest, MavenExecutionRequest request) {

    CommandLine commandLine = cliRequest.getCommandLine();
    String workingDirectory = cliRequest.getWorkingDirectory();
    boolean quiet = cliRequest.isQuiet();
    boolean showErrors = cliRequest.isShowErrors();

    String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
    for (String deprecatedOption : deprecatedOptions) {
        if (commandLine.hasOption(deprecatedOption)) {
            slf4jLogger.warn("Command line option -" + deprecatedOption
                    + " is deprecated and will be removed in future Maven versions.");
        }/*w  w w  . j a va 2 s.c  o  m*/
    }

    // ----------------------------------------------------------------------
    // Now that we have everything that we need we will fire up plexus and
    // bring the maven component to life for use.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.BATCH_MODE)) {
        request.setInteractiveMode(false);
    }

    boolean noSnapshotUpdates = false;
    if (commandLine.hasOption(CLIManager.SUPRESS_SNAPSHOT_UPDATES)) {
        noSnapshotUpdates = true;
    }

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    @SuppressWarnings("unchecked")
    List<String> goals = commandLine.getArgList();

    boolean recursive = true;

    // this is the default behavior.
    String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;

    if (commandLine.hasOption(CLIManager.NON_RECURSIVE)) {
        recursive = false;
    }

    if (commandLine.hasOption(CLIManager.FAIL_FAST)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;
    } else if (commandLine.hasOption(CLIManager.FAIL_AT_END)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END;
    } else if (commandLine.hasOption(CLIManager.FAIL_NEVER)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER;
    }

    if (commandLine.hasOption(CLIManager.OFFLINE)) {
        request.setOffline(true);
    }

    boolean updateSnapshots = false;

    if (commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS)) {
        updateSnapshots = true;
    }

    String globalChecksumPolicy = null;

    if (commandLine.hasOption(CLIManager.CHECKSUM_FAILURE_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL;
    } else if (commandLine.hasOption(CLIManager.CHECKSUM_WARNING_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN;
    }

    File baseDirectory = new File(workingDirectory, "").getAbsoluteFile();

    // ----------------------------------------------------------------------
    // Profile Activation
    // ----------------------------------------------------------------------

    List<String> activeProfiles = new ArrayList<String>();

    List<String> inactiveProfiles = new ArrayList<String>();

    if (commandLine.hasOption(CLIManager.ACTIVATE_PROFILES)) {
        String[] profileOptionValues = commandLine.getOptionValues(CLIManager.ACTIVATE_PROFILES);
        if (profileOptionValues != null) {
            for (String profileOptionValue : profileOptionValues) {
                StringTokenizer profileTokens = new StringTokenizer(profileOptionValue, ",");

                while (profileTokens.hasMoreTokens()) {
                    String profileAction = profileTokens.nextToken().trim();

                    if (profileAction.startsWith("-") || profileAction.startsWith("!")) {
                        inactiveProfiles.add(profileAction.substring(1));
                    } else if (profileAction.startsWith("+")) {
                        activeProfiles.add(profileAction.substring(1));
                    } else {
                        activeProfiles.add(profileAction);
                    }
                }
            }
        }
    }

    TransferListener transferListener;

    if (quiet) {
        transferListener = new QuietMavenTransferListener();
    } else if (request.isInteractiveMode() && !cliRequest.getCommandLine().hasOption(CLIManager.LOG_FILE)) {
        //
        // If we're logging to a file then we don't want the console transfer listener as it will spew
        // download progress all over the place
        //
        transferListener = getConsoleTransferListener();
    } else {
        transferListener = getBatchTransferListener();
    }

    ExecutionListener executionListener = new ExecutionEventLogger();

    if (eventSpyDispatcher != null) {
        executionListener = eventSpyDispatcher.chainListener(executionListener);
    }

    String alternatePomFile = null;
    if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
        alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
    }

    request.setBaseDirectory(baseDirectory).setGoals(goals)
            .setSystemProperties(cliRequest.getSystemProperties())
            .setUserProperties(cliRequest.getUserProperties())
            .setReactorFailureBehavior(reactorFailureBehaviour) // default: fail fast
            .setRecursive(recursive) // default: true
            .setShowErrors(showErrors) // default: false
            .addActiveProfiles(activeProfiles) // optional
            .addInactiveProfiles(inactiveProfiles) // optional
            .setExecutionListener(executionListener).setTransferListener(transferListener) // default: batch mode which goes along with interactive
            .setUpdateSnapshots(updateSnapshots) // default: false
            .setNoSnapshotUpdates(noSnapshotUpdates) // default: false
            .setGlobalChecksumPolicy(globalChecksumPolicy) // default: warn
            .setMultiModuleProjectDirectory(new File(cliRequest.getMultiModuleProjectDirectory()));

    if (alternatePomFile != null) {
        File pom = resolveFile(new File(alternatePomFile.trim()), workingDirectory);
        if (pom.isDirectory()) {
            pom = new File(pom, "pom.xml");
        }

        request.setPom(pom);
    } else if (modelProcessor != null) {
        File pom = modelProcessor.locatePom(baseDirectory);

        if (pom.isFile()) {
            request.setPom(pom);
        }
    }

    if ((request.getPom() != null) && (request.getPom().getParentFile() != null)) {
        request.setBaseDirectory(request.getPom().getParentFile());
    }

    if (commandLine.hasOption(CLIManager.RESUME_FROM)) {
        request.setResumeFrom(commandLine.getOptionValue(CLIManager.RESUME_FROM));
    }

    if (commandLine.hasOption(CLIManager.PROJECT_LIST)) {
        String[] projectOptionValues = commandLine.getOptionValues(CLIManager.PROJECT_LIST);

        List<String> inclProjects = new ArrayList<String>();
        List<String> exclProjects = new ArrayList<String>();

        if (projectOptionValues != null) {
            for (String projectOptionValue : projectOptionValues) {
                StringTokenizer projectTokens = new StringTokenizer(projectOptionValue, ",");

                while (projectTokens.hasMoreTokens()) {
                    String projectAction = projectTokens.nextToken().trim();

                    if (projectAction.startsWith("-") || projectAction.startsWith("!")) {
                        exclProjects.add(projectAction.substring(1));
                    } else if (projectAction.startsWith("+")) {
                        inclProjects.add(projectAction.substring(1));
                    } else {
                        inclProjects.add(projectAction);
                    }
                }
            }
        }

        request.setSelectedProjects(inclProjects);
        request.setExcludedProjects(exclProjects);
    }

    if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && !commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);
    } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM);
    } else if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_BOTH);
    }

    String localRepoProperty = request.getUserProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);

    if (localRepoProperty == null) {
        localRepoProperty = request.getSystemProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);
    }

    if (localRepoProperty != null) {
        request.setLocalRepositoryPath(localRepoProperty);
    }

    request.setCacheNotFound(true);
    request.setCacheTransferError(false);

    //
    // Builder, concurrency and parallelism
    //
    // We preserve the existing methods for builder selection which is to look for various inputs in the threading
    // configuration. We don't have an easy way to allow a pluggable builder to provide its own configuration
    // parameters but this is sufficient for now. Ultimately we want components like Builders to provide a way to
    // extend the command line to accept its own configuration parameters.
    //
    final String threadConfiguration = commandLine.hasOption(CLIManager.THREADS)
            ? commandLine.getOptionValue(CLIManager.THREADS)
            : request.getSystemProperties().getProperty(MavenCli.THREADS_DEPRECATED); // TODO: Remove this setting. Note that the int-tests use it

    if (threadConfiguration != null) {
        //
        // Default to the standard multithreaded builder
        //
        request.setBuilderId("multithreaded");

        if (threadConfiguration.contains("C")) {
            request.setDegreeOfConcurrency(calculateDegreeOfConcurrencyWithCoreMultiplier(threadConfiguration));
        } else {
            request.setDegreeOfConcurrency(Integer.valueOf(threadConfiguration));
        }
    }

    //
    // Allow the builder to be overriden by the user if requested. The builders are now pluggable.
    //
    if (commandLine.hasOption(CLIManager.BUILDER)) {
        request.setBuilderId(commandLine.getOptionValue(CLIManager.BUILDER));
    }

    return request;
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.AFMavenCli.java

License:Apache License

protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException {

    MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest());

    eventSpyDispatcher.onEvent(request);

    MavenExecutionResult result = maven.execute(request);

    eventSpyDispatcher.onEvent(result);/* w  w  w . j  a  v a2  s .  c  o  m*/

    eventSpyDispatcher.close();

    if (result.hasExceptions()) {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;

        for (Throwable exception : result.getExceptions()) {
            ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary, references, "", cliRequest.isShowErrors());

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        slf4jLogger.error("");

        if (!cliRequest.isShowErrors()) {
            slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!slf4jLogger.isDebugEnabled()) {
            slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            slf4jLogger.error("");
            slf4jLogger.error("For more information about the errors and possible solutions"
                    + ", please read the following articles:");

            for (Entry<String, String> entry : references.entrySet()) {
                slf4jLogger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            slf4jLogger.error("");
            slf4jLogger.error("After correcting the problems, you can resume the build with the command");
            slf4jLogger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER
                .equals(cliRequest.getRequest().getReactorFailureBehavior())) {
            slf4jLogger.info("Build failures were ignored.");
            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java

License:Apache License

protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException {
    MavenExecutionRequest request = reusableExecutionRequestPopulator.populateDefaults(cliRequest.getRequest());

    reusableEventSpyDispatcher.onEvent(request);

    MavenExecutionResult result = reusableMaven.execute(request);

    reusableEventSpyDispatcher.onEvent(result);

    reusableEventSpyDispatcher.close();/*w w w  . jav a 2s  .  c  om*/

    if (result.hasExceptions()) {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;

        for (Throwable exception : result.getExceptions()) {
            ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary, references, "", cliRequest.isShowErrors());

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        reusableSlf4jLogger.error("");

        if (!cliRequest.isShowErrors()) {
            reusableSlf4jLogger
                    .error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!reusableSlf4jLogger.isDebugEnabled()) {
            reusableSlf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            reusableSlf4jLogger.error("");
            reusableSlf4jLogger.error("For more information about the errors and possible solutions"
                    + ", please read the following articles:");

            for (Entry<String, String> entry : references.entrySet()) {
                reusableSlf4jLogger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            reusableSlf4jLogger.error("");
            reusableSlf4jLogger
                    .error("After correcting the problems, you can resume the build with the command");
            reusableSlf4jLogger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER
                .equals(cliRequest.getRequest().getReactorFailureBehavior())) {
            reusableSlf4jLogger.info("Build failures were ignored.");
            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java

License:Apache License

protected MavenExecutionRequest populateRequest(AFCliRequest cliRequest, MavenExecutionRequest request) {

    CommandLine commandLine = cliRequest.getCommandLine();
    String workingDirectory = cliRequest.getWorkingDirectory();
    boolean quiet = cliRequest.isQuiet();
    boolean showErrors = cliRequest.isShowErrors();

    String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
    for (String deprecatedOption : deprecatedOptions) {
        if (commandLine.hasOption(deprecatedOption)) {
            reusableSlf4jLogger.warn("Command line option -" + deprecatedOption
                    + " is deprecated and will be removed in future Maven versions.");
        }/*from  w w  w  . jav  a  2  s  . com*/
    }

    // ----------------------------------------------------------------------
    // Now that we have everything that we need we will fire up plexus and
    // bring the maven component to life for use.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.BATCH_MODE)) {
        request.setInteractiveMode(false);
    }

    boolean noSnapshotUpdates = false;
    if (commandLine.hasOption(CLIManager.SUPRESS_SNAPSHOT_UPDATES)) {
        noSnapshotUpdates = true;
    }

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    @SuppressWarnings("unchecked")
    List<String> goals = commandLine.getArgList();

    boolean recursive = true;

    // this is the default behavior.
    String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;

    if (commandLine.hasOption(CLIManager.NON_RECURSIVE)) {
        recursive = false;
    }

    if (commandLine.hasOption(CLIManager.FAIL_FAST)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;
    } else if (commandLine.hasOption(CLIManager.FAIL_AT_END)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END;
    } else if (commandLine.hasOption(CLIManager.FAIL_NEVER)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER;
    }

    if (commandLine.hasOption(CLIManager.OFFLINE)) {
        request.setOffline(true);
    }

    boolean updateSnapshots = false;

    if (commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS)) {
        updateSnapshots = true;
    }

    String globalChecksumPolicy = null;

    if (commandLine.hasOption(CLIManager.CHECKSUM_FAILURE_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL;
    } else if (commandLine.hasOption(CLIManager.CHECKSUM_WARNING_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN;
    }

    File baseDirectory = new File(workingDirectory, "").getAbsoluteFile();

    // ----------------------------------------------------------------------
    // Profile Activation
    // ----------------------------------------------------------------------

    List<String> activeProfiles = new ArrayList<String>();

    List<String> inactiveProfiles = new ArrayList<String>();

    if (commandLine.hasOption(CLIManager.ACTIVATE_PROFILES)) {
        String[] profileOptionValues = commandLine.getOptionValues(CLIManager.ACTIVATE_PROFILES);
        if (profileOptionValues != null) {
            for (String profileOptionValue : profileOptionValues) {
                StringTokenizer profileTokens = new StringTokenizer(profileOptionValue, ",");

                while (profileTokens.hasMoreTokens()) {
                    String profileAction = profileTokens.nextToken().trim();

                    if (profileAction.startsWith("-") || profileAction.startsWith("!")) {
                        inactiveProfiles.add(profileAction.substring(1));
                    } else if (profileAction.startsWith("+")) {
                        activeProfiles.add(profileAction.substring(1));
                    } else {
                        activeProfiles.add(profileAction);
                    }
                }
            }
        }
    }

    TransferListener transferListener;

    if (quiet) {
        transferListener = new QuietMavenTransferListener();
    } else if (request.isInteractiveMode() && !cliRequest.getCommandLine().hasOption(CLIManager.LOG_FILE)) {
        //
        // If we're logging to a file then we don't want the console transfer listener as it will spew
        // download progress all over the place
        //
        transferListener = getConsoleTransferListener();
    } else {
        transferListener = getBatchTransferListener();
    }

    ExecutionListener executionListener = new ExecutionEventLogger();

    if (reusableEventSpyDispatcher != null) {
        executionListener = reusableEventSpyDispatcher.chainListener(executionListener);
    }

    String alternatePomFile = null;
    if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
        alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
    }

    request.setBaseDirectory(baseDirectory).setGoals(goals)
            .setSystemProperties(cliRequest.getSystemProperties())
            .setUserProperties(cliRequest.getUserProperties())
            .setReactorFailureBehavior(reactorFailureBehaviour) // default: fail fast
            .setRecursive(recursive) // default: true
            .setShowErrors(showErrors) // default: false
            .addActiveProfiles(activeProfiles) // optional
            .addInactiveProfiles(inactiveProfiles) // optional
            .setExecutionListener(executionListener).setTransferListener(transferListener) // default: batch mode which goes along with interactive
            .setUpdateSnapshots(updateSnapshots) // default: false
            .setNoSnapshotUpdates(noSnapshotUpdates) // default: false
            .setGlobalChecksumPolicy(globalChecksumPolicy) // default: warn
            .setMultiModuleProjectDirectory(new File(cliRequest.getMultiModuleProjectDirectory()));

    if (alternatePomFile != null) {
        File pom = resolveFile(new File(alternatePomFile.trim()), workingDirectory);
        if (pom.isDirectory()) {
            pom = new File(pom, "pom.xml");
        }

        request.setPom(pom);
    } else if (reusableModelProcessor != null) {
        File pom = reusableModelProcessor.locatePom(baseDirectory);

        if (pom.isFile()) {
            request.setPom(pom);
        }
    }

    if ((request.getPom() != null) && (request.getPom().getParentFile() != null)) {
        request.setBaseDirectory(request.getPom().getParentFile());
    }

    if (commandLine.hasOption(CLIManager.RESUME_FROM)) {
        request.setResumeFrom(commandLine.getOptionValue(CLIManager.RESUME_FROM));
    }

    if (commandLine.hasOption(CLIManager.PROJECT_LIST)) {
        String[] projectOptionValues = commandLine.getOptionValues(CLIManager.PROJECT_LIST);

        List<String> inclProjects = new ArrayList<String>();
        List<String> exclProjects = new ArrayList<String>();

        if (projectOptionValues != null) {
            for (String projectOptionValue : projectOptionValues) {
                StringTokenizer projectTokens = new StringTokenizer(projectOptionValue, ",");

                while (projectTokens.hasMoreTokens()) {
                    String projectAction = projectTokens.nextToken().trim();

                    if (projectAction.startsWith("-") || projectAction.startsWith("!")) {
                        exclProjects.add(projectAction.substring(1));
                    } else if (projectAction.startsWith("+")) {
                        inclProjects.add(projectAction.substring(1));
                    } else {
                        inclProjects.add(projectAction);
                    }
                }
            }
        }

        request.setSelectedProjects(inclProjects);
        request.setExcludedProjects(exclProjects);
    }

    if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && !commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);
    } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM);
    } else if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_BOTH);
    }

    String localRepoProperty = request.getUserProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);

    if (localRepoProperty == null) {
        localRepoProperty = request.getSystemProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);
    }

    if (localRepoProperty != null) {
        request.setLocalRepositoryPath(localRepoProperty);
    }

    request.setCacheNotFound(true);
    request.setCacheTransferError(false);

    //
    // Builder, concurrency and parallelism
    //
    // We preserve the existing methods for builder selection which is to look for various inputs in the threading
    // configuration. We don't have an easy way to allow a pluggable builder to provide its own configuration
    // parameters but this is sufficient for now. Ultimately we want components like Builders to provide a way to
    // extend the command line to accept its own configuration parameters.
    //
    final String threadConfiguration = commandLine.hasOption(CLIManager.THREADS)
            ? commandLine.getOptionValue(CLIManager.THREADS)
            : request.getSystemProperties().getProperty(MavenCli.THREADS_DEPRECATED); // TODO: Remove this setting. Note that the int-tests use it

    if (threadConfiguration != null) {
        //
        // Default to the standard multithreaded builder
        //
        request.setBuilderId("multithreaded");

        if (threadConfiguration.contains("C")) {
            request.setDegreeOfConcurrency(calculateDegreeOfConcurrencyWithCoreMultiplier(threadConfiguration));
        } else {
            request.setDegreeOfConcurrency(Integer.valueOf(threadConfiguration));
        }
    }

    //
    // Allow the builder to be overriden by the user if requested. The builders are now pluggable.
    //
    if (commandLine.hasOption(CLIManager.BUILDER)) {
        request.setBuilderId(commandLine.getOptionValue(CLIManager.BUILDER));
    }

    return request;
}

From source file:org.topdesk.maven.tracker.MavenCli.java

License:Apache License

private int execute(CliRequest cliRequest) {
    MavenExecutionResult result = maven.execute(cliRequest.request);

    if (result.hasExceptions()) {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;// w ww .j ava 2s  .  com

        for (Throwable exception : result.getExceptions()) {
            ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary, references, "", cliRequest.showErrors);

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        logger.error("");

        if (!cliRequest.showErrors) {
            logger.error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!logger.isDebugEnabled()) {
            logger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            logger.error("");
            logger.error("For more information about the errors and possible solutions"
                    + ", please read the following articles:");

            for (Map.Entry<String, String> entry : references.entrySet()) {
                logger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            logger.error("");
            logger.error("After correcting the problems, you can resume the build with the command");
            logger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(cliRequest.request.getReactorFailureBehavior())) {
            logger.info("Build failures were ignored.");

            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}

From source file:org.topdesk.maven.tracker.MavenCli.java

License:Apache License

private MavenExecutionRequest populateRequest(CliRequest cliRequest) {
    MavenExecutionRequest request = cliRequest.request;
    CommandLine commandLine = cliRequest.commandLine;
    String workingDirectory = cliRequest.workingDirectory;
    boolean debug = cliRequest.debug;
    boolean quiet = cliRequest.quiet;
    boolean showErrors = cliRequest.showErrors;

    String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
    for (String deprecatedOption : deprecatedOptions) {
        if (commandLine.hasOption(deprecatedOption)) {
            cliRequest.stdout.println("[WARNING] Command line option -" + deprecatedOption
                    + " is deprecated and will be removed in future Maven versions.");
        }//from w w  w.java  2  s. co m
    }

    // ----------------------------------------------------------------------
    // Now that we have everything that we need we will fire up plexus and
    // bring the maven component to life for use.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.BATCH_MODE)) {
        request.setInteractiveMode(false);
    }

    boolean noSnapshotUpdates = false;
    if (commandLine.hasOption(CLIManager.SUPRESS_SNAPSHOT_UPDATES)) {
        noSnapshotUpdates = true;
    }

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    @SuppressWarnings("unchecked")
    List<String> goals = commandLine.getArgList();

    boolean recursive = true;

    // this is the default behavior.
    String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;

    if (commandLine.hasOption(CLIManager.NON_RECURSIVE)) {
        recursive = false;
    }

    if (commandLine.hasOption(CLIManager.FAIL_FAST)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST;
    } else if (commandLine.hasOption(CLIManager.FAIL_AT_END)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END;
    } else if (commandLine.hasOption(CLIManager.FAIL_NEVER)) {
        reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER;
    }

    if (commandLine.hasOption(CLIManager.OFFLINE)) {
        request.setOffline(true);
    }

    boolean updateSnapshots = false;

    if (commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS)) {
        updateSnapshots = true;
    }

    String globalChecksumPolicy = null;

    if (commandLine.hasOption(CLIManager.CHECKSUM_FAILURE_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL;
    } else if (commandLine.hasOption(CLIManager.CHECKSUM_WARNING_POLICY)) {
        globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN;
    }

    File baseDirectory = new File(workingDirectory, "").getAbsoluteFile();

    // ----------------------------------------------------------------------
    // Profile Activation
    // ----------------------------------------------------------------------

    List<String> activeProfiles = new ArrayList<String>();

    List<String> inactiveProfiles = new ArrayList<String>();

    if (commandLine.hasOption(CLIManager.ACTIVATE_PROFILES)) {
        String[] profileOptionValues = commandLine.getOptionValues(CLIManager.ACTIVATE_PROFILES);
        if (profileOptionValues != null) {
            for (int i = 0; i < profileOptionValues.length; ++i) {
                StringTokenizer profileTokens = new StringTokenizer(profileOptionValues[i], ",");

                while (profileTokens.hasMoreTokens()) {
                    String profileAction = profileTokens.nextToken().trim();

                    if (profileAction.startsWith("-") || profileAction.startsWith("!")) {
                        inactiveProfiles.add(profileAction.substring(1));
                    } else if (profileAction.startsWith("+")) {
                        activeProfiles.add(profileAction.substring(1));
                    } else {
                        activeProfiles.add(profileAction);
                    }
                }
            }
        }
    }

    TransferListener transferListener;

    if (quiet) {
        transferListener = new QuietMavenTransferListener();
    } else if (request.isInteractiveMode()) {
        transferListener = new ConsoleMavenTransferListener(cliRequest.stdout);
    } else {
        transferListener = new BatchModeMavenTransferListener(cliRequest.stdout);
    }

    String alternatePomFile = null;
    if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
        alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
    }

    int loggingLevel;

    if (debug) {
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
    } else if (quiet) {
        // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level.
        // Ideally, we could use Warn across the board
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_ERROR;
        // TODO:Additionally, we can't change the mojo level because the component key includes the version and
        // it isn't known ahead of time. This seems worth changing.
    } else {
        loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO;
    }

    File userToolchainsFile;
    if (commandLine.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) {
        userToolchainsFile = new File(commandLine.getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS));
        userToolchainsFile = resolveFile(userToolchainsFile, workingDirectory);
    } else {
        userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
    }

    request.setBaseDirectory(baseDirectory).setGoals(goals).setSystemProperties(cliRequest.systemProperties)
            .setUserProperties(cliRequest.userProperties).setReactorFailureBehavior(reactorFailureBehaviour) // default: fail fast
            .setRecursive(recursive) // default: true
            .setShowErrors(showErrors) // default: false
            .addActiveProfiles(activeProfiles) // optional
            .addInactiveProfiles(inactiveProfiles) // optional
            .setLoggingLevel(loggingLevel) // default: info
            .setTransferListener(transferListener) // default: batch mode which goes along with interactive
            .setUpdateSnapshots(updateSnapshots) // default: false
            .setNoSnapshotUpdates(noSnapshotUpdates) // default: false
            .setGlobalChecksumPolicy(globalChecksumPolicy) // default: warn
            .setUserToolchainsFile(userToolchainsFile);

    if (alternatePomFile != null) {
        File pom = resolveFile(new File(alternatePomFile), workingDirectory);

        request.setPom(pom);
    } else {
        File pom = modelProcessor.locatePom(baseDirectory);

        if (pom.isFile()) {
            request.setPom(pom);
        }
    }

    if ((request.getPom() != null) && (request.getPom().getParentFile() != null)) {
        request.setBaseDirectory(request.getPom().getParentFile());
    }

    if (commandLine.hasOption(CLIManager.RESUME_FROM)) {
        request.setResumeFrom(commandLine.getOptionValue(CLIManager.RESUME_FROM));
    }

    if (commandLine.hasOption(CLIManager.PROJECT_LIST)) {
        String projectList = commandLine.getOptionValue(CLIManager.PROJECT_LIST);
        String[] projects = StringUtils.split(projectList, ",");
        request.setSelectedProjects(Arrays.asList(projects));
    }

    if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && !commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);
    } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM);
    } else if (commandLine.hasOption(CLIManager.ALSO_MAKE)
            && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
        request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_BOTH);
    }

    String localRepoProperty = request.getUserProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);

    if (localRepoProperty == null) {
        localRepoProperty = request.getSystemProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);
    }

    if (localRepoProperty != null) {
        request.setLocalRepositoryPath(localRepoProperty);
    }

    final String threadConfiguration = commandLine.hasOption(CLIManager.THREADS)
            ? commandLine.getOptionValue(CLIManager.THREADS)
            : request.getSystemProperties().getProperty(MavenCli.THREADS_DEPRECATED); // TODO: Remove this setting. Note that the int-tests use it

    if (threadConfiguration != null) {
        request.setPerCoreThreadCount(threadConfiguration.contains("C"));
        if (threadConfiguration.contains("W")) {
            LifecycleWeaveBuilder.setWeaveMode(request.getUserProperties());
        }
        request.setThreadCount(threadConfiguration.replace("C", "").replace("W", "").replace("auto", ""));
    }

    request.setCacheNotFound(true);
    request.setCacheTransferError(false);

    return request;
}