List of usage examples for org.apache.maven.cli CLIManager ALTERNATE_USER_TOOLCHAINS
char ALTERNATE_USER_TOOLCHAINS
To view the source code for org.apache.maven.cli CLIManager ALTERNATE_USER_TOOLCHAINS.
Click Source Link
From source file:org.commonjava.emb.boot.main.EMBCLIManager.java
License:Apache License
@SuppressWarnings("static-access") private void populateNativeMavenOptions(final Options options) { options.addOption(OptionBuilder.withLongOpt("file").hasArg() .withDescription("Force the use of an alternate POM file.").create(CLIManager.ALTERNATE_POM_FILE)); options.addOption(OptionBuilder.withLongOpt("define").hasArg().withDescription("Define a system property") .create(CLIManager.SET_SYSTEM_PROPERTY)); options.addOption(/* w w w . j a v a2s . co m*/ OptionBuilder.withLongOpt("offline").withDescription("Work offline").create(CLIManager.OFFLINE)); options.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help information") .create(CLIManager.HELP)); options.addOption(OptionBuilder.withLongOpt("version").withDescription("Display version information") .create(CLIManager.VERSION)); options.addOption(OptionBuilder.withLongOpt("quiet").withDescription("Quiet output - only show errors") .create(CLIManager.QUIET)); options.addOption(OptionBuilder.withLongOpt("debug").withDescription("Produce execution debug output") .create(CLIManager.DEBUG)); options.addOption(OptionBuilder.withLongOpt("errors").withDescription("Produce execution error messages") .create(CLIManager.ERRORS)); options.addOption(OptionBuilder.withLongOpt("non-recursive") .withDescription("Do not recurse into sub-projects").create(CLIManager.NON_RECURSIVE)); options.addOption(OptionBuilder.withLongOpt("update-snapshots") .withDescription("Forces a check for updated releases and snapshots on remote repositories") .create(CLIManager.UPDATE_SNAPSHOTS)); options.addOption(OptionBuilder.withLongOpt("activate-profiles") .withDescription("Comma-delimited list of profiles to activate").hasArg() .create(CLIManager.ACTIVATE_PROFILES)); options.addOption(OptionBuilder.withLongOpt("batch-mode") .withDescription("Run in non-interactive (batch) mode").create(CLIManager.BATCH_MODE)); options.addOption(OptionBuilder.withLongOpt("no-snapshot-updates") .withDescription("Supress SNAPSHOT updates").create(CLIManager.SUPRESS_SNAPSHOT_UPDATES)); options.addOption(OptionBuilder.withLongOpt("strict-checksums") .withDescription("Fail the build if checksums don't match") .create(CLIManager.CHECKSUM_FAILURE_POLICY)); options.addOption(OptionBuilder.withLongOpt("lax-checksums") .withDescription("Warn if checksums don't match").create(CLIManager.CHECKSUM_WARNING_POLICY)); options.addOption( OptionBuilder.withLongOpt("settings").withDescription("Alternate path for the user settings file") .hasArg().create(CLIManager.ALTERNATE_USER_SETTINGS)); options.addOption(OptionBuilder.withLongOpt("global-settings") .withDescription("Alternate path for the global settings file").hasArg() .create(CLIManager.ALTERNATE_GLOBAL_SETTINGS)); options.addOption(OptionBuilder.withLongOpt("toolchains") .withDescription("Alternate path for the user toolchains file").hasArg() .create(CLIManager.ALTERNATE_USER_TOOLCHAINS)); options.addOption(OptionBuilder.withLongOpt("fail-fast") .withDescription("Stop at first failure in reactorized builds").create(CLIManager.FAIL_FAST)); options.addOption(OptionBuilder.withLongOpt("fail-at-end") .withDescription("Only fail the build afterwards; allow all non-impacted builds to continue") .create(CLIManager.FAIL_AT_END)); options.addOption(OptionBuilder.withLongOpt("fail-never") .withDescription("NEVER fail the build, regardless of project result") .create(CLIManager.FAIL_NEVER)); options.addOption(OptionBuilder.withLongOpt("resume-from").hasArg() .withDescription("Resume reactor from specified project").create(CLIManager.RESUME_FROM)); options.addOption(OptionBuilder.withLongOpt("projects").withDescription( "Build specified reactor projects instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.") .hasArg().create(CLIManager.PROJECT_LIST)); options.addOption(OptionBuilder.withLongOpt("also-make") .withDescription("If project list is specified, also build projects required by the list") .create(CLIManager.ALSO_MAKE)); options.addOption(OptionBuilder.withLongOpt("also-make-dependents") .withDescription( "If project list is specified, also build projects that depend on projects on the list") .create(CLIManager.ALSO_MAKE_DEPENDENTS)); options.addOption(OptionBuilder.withLongOpt("log-file").hasArg() .withDescription("Log file to where all build output will go.").create(CLIManager.LOG_FILE)); options.addOption(OptionBuilder.withLongOpt("show-version") .withDescription("Display version information WITHOUT stopping build") .create(CLIManager.SHOW_VERSION)); options.addOption(OptionBuilder.withLongOpt("encrypt-master-password").hasArg() .withDescription("Encrypt master security password").create(CLIManager.ENCRYPT_MASTER_PASSWORD)); options.addOption(OptionBuilder.withLongOpt("encrypt-password").hasArg() .withDescription("Encrypt server password").create(CLIManager.ENCRYPT_PASSWORD)); options.addOption(OptionBuilder.withLongOpt("threads").hasArg() .withDescription("Thread count, for instance 2.0C where C is core multiplied") .create(CLIManager.THREADS)); // Adding this back in for compatibility with the verifier that hard codes this option. options.addOption(OptionBuilder.withLongOpt("no-plugin-registry") .withDescription("Ineffective, only kept for backward compatibility").create("npr")); }
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 w w w. j a v a 2s.com*/ 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
@SuppressWarnings("checkstyle:methodlength") protected void toolchains(AFCliRequest cliRequest) throws Exception { Path userToolchainsFile;/*from ww w. ja v a2 s . co m*/ if (cliRequest.getCommandLine().hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) { userToolchainsFile = Paths .get(cliRequest.getCommandLine().getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS)); userToolchainsFile = resolvePath(userToolchainsFile, cliRequest.getWorkingDirectory()); if (!java.nio.file.Files.isRegularFile(userToolchainsFile)) { throw new FileNotFoundException( "The specified user toolchains file does not exist: " + userToolchainsFile); } } else { userToolchainsFile = Paths.get(userMavenConfigurationHome.toString(), "toolchains.xml"); } Path globalToolchainsFile; if (cliRequest.getCommandLine().hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) { globalToolchainsFile = Paths .get(cliRequest.getCommandLine().getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)); globalToolchainsFile = resolvePath(globalToolchainsFile, cliRequest.getWorkingDirectory()); if (!java.nio.file.Files.isRegularFile(globalToolchainsFile)) { throw new FileNotFoundException( "The specified global toolchains file does not exist: " + globalToolchainsFile); } } else { globalToolchainsFile = Paths.get(userMavenConfigurationHome.toString(), "toolchains.xml"); } cliRequest.getRequest().setGlobalToolchainsFile(globalToolchainsFile.toFile()); cliRequest.getRequest().setUserToolchainsFile(userToolchainsFile.toFile()); DefaultToolchainsBuildingRequest toolchainsRequest = new DefaultToolchainsBuildingRequest(); if (java.nio.file.Files.isRegularFile(globalToolchainsFile)) { toolchainsRequest.setGlobalToolchainsSource(new FileSource(globalToolchainsFile.toFile())); } if (java.nio.file.Files.isRegularFile(userToolchainsFile)) { toolchainsRequest.setUserToolchainsSource(new FileSource(userToolchainsFile.toFile())); } eventSpyDispatcher.onEvent(toolchainsRequest); slf4jLogger.debug("Reading global toolchains from " + getLocation(toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile)); slf4jLogger.debug("Reading user toolchains from " + getLocation(toolchainsRequest.getUserToolchainsSource(), userToolchainsFile)); ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build(toolchainsRequest); eventSpyDispatcher.onEvent(toolchainsRequest); executionRequestPopulator.populateFromToolchains(cliRequest.getRequest(), toolchainsResult.getEffectiveToolchains()); if (!toolchainsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled()) { slf4jLogger.warn(""); slf4jLogger.warn("Some problems were encountered while building the effective toolchains"); for (Problem problem : toolchainsResult.getProblems()) { slf4jLogger.warn(problem.getMessage() + " @ " + problem.getLocation()); } slf4jLogger.warn(""); } }
From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java
License:Apache License
@SuppressWarnings("checkstyle:methodlength") protected void toolchains(AFCliRequest cliRequest) throws Exception { Path userToolchainsFile;/*from w w w. j a va 2 s . c o m*/ if (cliRequest.getCommandLine().hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) { userToolchainsFile = Paths .get(cliRequest.getCommandLine().getOptionValue(CLIManager.ALTERNATE_USER_TOOLCHAINS)); userToolchainsFile = resolvePath(userToolchainsFile, cliRequest.getWorkingDirectory()); if (!java.nio.file.Files.isRegularFile(userToolchainsFile)) { throw new FileNotFoundException( "The specified user toolchains file does not exist: " + userToolchainsFile); } } else { userToolchainsFile = Paths.get(userMavenConfigurationHome.toString(), "toolchains.xml"); } Path globalToolchainsFile; if (cliRequest.getCommandLine().hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) { globalToolchainsFile = Paths .get(cliRequest.getCommandLine().getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)); globalToolchainsFile = resolvePath(globalToolchainsFile, cliRequest.getWorkingDirectory()); if (!java.nio.file.Files.isRegularFile(globalToolchainsFile)) { throw new FileNotFoundException( "The specified global toolchains file does not exist: " + globalToolchainsFile); } } else { globalToolchainsFile = Paths.get(userMavenConfigurationHome.toString(), "toolchains.xml"); } cliRequest.getRequest().setGlobalToolchainsFile(globalToolchainsFile.toFile()); cliRequest.getRequest().setUserToolchainsFile(userToolchainsFile.toFile()); DefaultToolchainsBuildingRequest toolchainsRequest = new DefaultToolchainsBuildingRequest(); if (java.nio.file.Files.isRegularFile(globalToolchainsFile)) { toolchainsRequest.setGlobalToolchainsSource(new FileSource(globalToolchainsFile.toFile())); } if (java.nio.file.Files.isRegularFile(userToolchainsFile)) { toolchainsRequest.setUserToolchainsSource(new FileSource(userToolchainsFile.toFile())); } reusableEventSpyDispatcher.onEvent(toolchainsRequest); reusableSlf4jLogger.debug("Reading global toolchains from " + getLocation(toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile)); reusableSlf4jLogger.debug("Reading user toolchains from " + getLocation(toolchainsRequest.getUserToolchainsSource(), userToolchainsFile)); ToolchainsBuildingResult toolchainsResult = reusableToolchainsBuilder.build(toolchainsRequest); reusableEventSpyDispatcher.onEvent(toolchainsRequest); reusableExecutionRequestPopulator.populateFromToolchains(cliRequest.getRequest(), toolchainsResult.getEffectiveToolchains()); if (!toolchainsResult.getProblems().isEmpty() && reusableSlf4jLogger.isWarnEnabled()) { reusableSlf4jLogger.warn(""); reusableSlf4jLogger.warn("Some problems were encountered while building the effective toolchains"); for (Problem problem : toolchainsResult.getProblems()) { reusableSlf4jLogger.warn(problem.getMessage() + " @ " + problem.getLocation()); } reusableSlf4jLogger.warn(""); } }
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 ww w . j a va2s . 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 (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; }