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

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

Introduction

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

Prototype

MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);

Source Link

Usage

From source file:hudson.maven.MavenEmbedder.java

License:Apache License

protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest)
        throws MavenEmbedderException, ComponentLookupException {
    MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();

    if (mavenRequest.getGlobalSettingsFile() != null) {
        mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile()));
    }//from w w  w  .  j  a  v a 2  s. c  o m

    if (mavenExecutionRequest.getUserSettingsFile() != null) {
        mavenExecutionRequest.setUserSettingsFile(new File(mavenRequest.getUserSettingsFile()));
    }

    try {
        lookup(MavenExecutionRequestPopulator.class).populateFromSettings(mavenExecutionRequest, getSettings());

        lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest);
    } catch (MavenExecutionRequestPopulationException e) {
        throw new MavenEmbedderException(e.getMessage(), e);
    }

    ArtifactRepository localRepository = getLocalRepository();
    mavenExecutionRequest.setLocalRepository(localRepository);
    mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir());
    mavenExecutionRequest.setOffline(mavenRequest.isOffline());

    mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots());

    // TODO check null and create a console one ?
    mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener());

    mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound());
    mavenExecutionRequest.setCacheTransferError(true);

    mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties());
    mavenExecutionRequest.getSystemProperties().putAll(System.getProperties());
    if (mavenRequest.getSystemProperties() != null) {
        mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties());
    }
    mavenExecutionRequest.getSystemProperties().putAll(getEnvVars());

    if (this.mavenHome != null) {
        mavenExecutionRequest.getSystemProperties().put("maven.home", this.mavenHome.getAbsolutePath());
    }

    if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) {
        for (String id : mavenRequest.getProfiles()) {
            Profile p = new Profile();
            p.setId(id);
            p.setSource("cli");
            mavenExecutionRequest.addProfile(p);
            mavenExecutionRequest.addActiveProfile(id);
        }
    }

    mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel());

    lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel());

    mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener())
            .setInteractiveMode(mavenRequest.isInteractive())
            .setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals());

    if (mavenRequest.getPom() != null) {
        mavenExecutionRequest.setPom(new File(mavenRequest.getPom()));
    }

    if (mavenRequest.getWorkspaceReader() != null) {
        mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader());
    }

    // FIXME inactive profiles 

    //this.mavenExecutionRequest.set

    return mavenExecutionRequest;

}

From source file:io.takari.maven.testing.Maven30xRuntime.java

License:Open Source License

@SuppressWarnings("deprecation")
protected MavenExecutionRequest newExecutionRequest() throws Exception {

    // system properties
    Properties buildProperties = getMavenBuildProperties();
    String mavenVersion = buildProperties.getProperty("version");
    Properties systemProperties = new Properties();
    systemProperties.putAll(System.getProperties()); // TODO not thread safe
    systemProperties.setProperty("maven.version", mavenVersion);
    systemProperties.setProperty("maven.build.version", mavenVersion);

    // request with initial configuration
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();
    request.setLocalRepositoryPath(properties.getLocalRepository());
    request.setUserSettingsFile(properties.getUserSettings());
    request.setGlobalSettingsFile(properties.getGlobalSettings());
    request.setOffline(properties.getOffline());
    request.setUpdateSnapshots(properties.getUpdateSnapshots());
    request.setSystemProperties(systemProperties);

    // read settings
    SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
    settingsRequest.setGlobalSettingsFile(request.getGlobalSettingsFile());
    settingsRequest.setUserSettingsFile(request.getUserSettingsFile());
    settingsRequest.setSystemProperties(request.getSystemProperties());
    settingsRequest.setUserProperties(request.getUserProperties());
    Settings settings = lookup(SettingsBuilder.class).build(settingsRequest).getEffectiveSettings();

    MavenExecutionRequestPopulator populator = container.lookup(MavenExecutionRequestPopulator.class);
    request = populator.populateFromSettings(request, settings);
    return populator.populateDefaults(request);
}

From source file:net.oneandone.maven.embedded.Maven.java

License:Apache License

/**
 * @param globalSettings null to use default
 * @param userSettings null to use default
 *//*from   w w  w. j  a  va  2  s. c om*/
public static Settings loadSettings(World world, FileNode globalSettings, FileNode userSettings,
        DefaultPlexusContainer container) throws IOException, XmlPullParserException, ComponentLookupException {
    DefaultMavenSettingsBuilder builder;
    MavenExecutionRequest request;

    builder = (DefaultMavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE);
    request = new DefaultMavenExecutionRequest();
    if (globalSettings == null) {
        globalSettings = locateMaven(world).join("conf/settings.xml");
    }
    if (userSettings == null) {
        userSettings = (FileNode) world.getHome().join(".m2/settings.xml");
    }
    request.setGlobalSettingsFile(globalSettings.toPath().toFile());
    request.setUserSettingsFile(userSettings.toPath().toFile());
    return builder.buildSettings(request);
}

From source file:org.appformer.maven.integration.embedder.MavenEmbedder.java

License:Apache License

protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest)
        throws MavenEmbedderException, ComponentLookupException {
    MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();

    if (mavenRequest.getGlobalSettingsFile() != null) {
        mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile()));
    }//from ww  w  .j  a v  a  2  s.c om

    SettingsSource userSettings = mavenRequest.getUserSettingsSource();
    if (userSettings != null) {
        if (userSettings instanceof FileSettingsSource) {
            mavenExecutionRequest.setUserSettingsFile(((FileSettingsSource) userSettings).getSettingsFile());
        } else {
            try {
                mavenExecutionRequest.setUserSettingsFile(copyInTempFile(userSettings.getInputStream(), "xml"));
            } catch (IOException ioe) {
                log.warn("Unable to use maven settings defined in " + userSettings, ioe);
            }
        }
    }

    try {
        componentProvider.lookup(MavenExecutionRequestPopulator.class)
                .populateFromSettings(mavenExecutionRequest, getSettings());
        componentProvider.lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest);
    } catch (MavenExecutionRequestPopulationException e) {
        throw new MavenEmbedderException(e.getMessage(), e);
    }

    ArtifactRepository localRepository = getLocalRepository();
    mavenExecutionRequest.setLocalRepository(localRepository);
    mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir());
    mavenExecutionRequest.setOffline(mavenRequest.isOffline());

    mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots());

    // TODO check null and create a console one ?
    mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener());

    mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound());
    mavenExecutionRequest.setCacheTransferError(true);

    mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties());
    mavenExecutionRequest.getSystemProperties().putAll(System.getProperties());
    if (mavenRequest.getSystemProperties() != null) {
        mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties());
    }
    mavenExecutionRequest.getSystemProperties().putAll(getEnvVars());

    if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) {
        for (String id : mavenRequest.getProfiles()) {
            Profile p = new Profile();
            p.setId(id);
            p.setSource("cli");
            mavenExecutionRequest.addProfile(p);
            mavenExecutionRequest.addActiveProfile(id);
        }
    }

    MavenRepositoryConfiguration mavenRepoConf = getMavenRepositoryConfiguration();

    //DROOLS-899: Copy repositories defined in settings to execution request
    for (ArtifactRepository artifactRepository : mavenRepoConf.getArtifactRepositoriesForRequest()) {
        mavenExecutionRequest.addRemoteRepository(artifactRepository);
    }

    mavenExecutionRequest.setProxies(mavenRepoConf.getProxies());

    mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel());

    componentProvider.lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel());

    mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener())
            .setInteractiveMode(mavenRequest.isInteractive())
            .setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals());

    if (mavenRequest.getPom() != null) {
        mavenExecutionRequest.setPom(new File(mavenRequest.getPom()));
    }

    if (mavenRequest.getWorkspaceReader() != null) {
        mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader());
    }

    return mavenExecutionRequest;
}

From source file:org.commonjava.maven.ext.cli.Cli.java

License:Apache License

private void createSession(File target, File settings) {
    try {//ww w.  j a v  a 2  s  . c om
        final DefaultContainerConfiguration config = new DefaultContainerConfiguration();
        config.setClassPathScanning(PlexusConstants.SCANNING_ON);
        config.setComponentVisibility(PlexusConstants.GLOBAL_VISIBILITY);
        config.setName("PME-CLI");
        PlexusContainer container = new DefaultPlexusContainer(config);

        pomIO = container.lookup(PomIO.class);
        session = container.lookup(ManipulationSession.class);
        manipulationManager = container.lookup(ManipulationManager.class);

        final MavenExecutionRequest req = new DefaultMavenExecutionRequest()
                .setUserProperties(System.getProperties()).setUserProperties(userProps)
                .setRemoteRepositories(Collections.<ArtifactRepository>emptyList());

        ArtifactRepository ar = null;
        if (settings == null) {
            // No, this is not a typo. If current default is null, supply new local and global.
            // This function passes in settings to make it easier to test.
            this.settings = settings = new File(System.getProperty("user.home"), ".m2/settings.xml");

            ar = new MavenArtifactRepository();
            ar.setUrl("file://" + System.getProperty("user.home") + "/.m2/repository");
            req.setLocalRepository(ar);
        }

        req.setUserSettingsFile(settings);
        req.setGlobalSettingsFile(settings);

        MavenExecutionRequestPopulator executionRequestPopulator = container
                .lookup(MavenExecutionRequestPopulator.class);

        executionRequestPopulator.populateFromSettings(req, parseSettings(settings));
        executionRequestPopulator.populateDefaults(req);

        if (ar != null) {
            ar.setUrl("file://" + req.getLocalRepositoryPath());
        }

        if (userProps != null && userProps.containsKey("maven.repo.local")) {
            if (ar == null) {
                ar = new MavenArtifactRepository();
            }
            ar.setUrl("file://" + userProps.getProperty("maven.repo.local"));
            req.setLocalRepository(ar);
        }

        final MavenSession mavenSession = new MavenSession(container, null, req,
                new DefaultMavenExecutionResult());

        mavenSession.getRequest().setPom(target);

        session.setMavenSession(mavenSession);
    } catch (ComponentLookupException e) {
        logger.debug("Caught problem instantiating ", e);
        System.err.println("Unable to start Cli subsystem");
        System.exit(100);
    } catch (PlexusContainerException e) {
        logger.debug("Caught problem instantiating ", e);
        System.err.println("Unable to start Cli subsystem");
        System.exit(100);
    } catch (SettingsBuildingException e) {
        logger.debug("Caught problem parsing settings file ", e);
        System.err.println("Unable to parse settings.xml file");
        System.exit(100);
    } catch (MavenExecutionRequestPopulationException e) {
        logger.debug("Caught problem populating maven request from settings file ", e);
        System.err.println("Unable to create maven execution request from settings.xml file");
        System.exit(100);
    }
}

From source file:org.commonjava.maven.ext.manip.Cli.java

License:Apache License

private void createSession(File target, File settings) {
    try {//from w  w w  .  j ava  2s.  co  m
        PlexusContainer container = new DefaultPlexusContainer();

        final MavenExecutionRequest req = new DefaultMavenExecutionRequest()
                .setUserProperties(System.getProperties()).setUserProperties(userProps)
                .setRemoteRepositories(Collections.<ArtifactRepository>emptyList());

        if (userProps != null && userProps.containsKey("maven.repo.local")) {
            ArtifactRepository ar = new MavenArtifactRepository();
            ar.setUrl("file://" + userProps.getProperty("maven.repo.local"));
            req.setLocalRepository(ar);
        }

        if (settings != null) {
            req.setUserSettingsFile(settings);
            req.setGlobalSettingsFile(settings);

            MavenExecutionRequestPopulator executionRequestPopulator = container
                    .lookup(MavenExecutionRequestPopulator.class);

            executionRequestPopulator.populateFromSettings(req, parseSettings(settings));
            executionRequestPopulator.populateDefaults(req);
        }

        final MavenSession mavenSession = new MavenSession(container, null, req,
                new DefaultMavenExecutionResult());

        mavenSession.getRequest().setPom(target);

        pomIO = container.lookup(PomIO.class);
        session = container.lookup(ManipulationSession.class);
        manipulationManager = container.lookup(ManipulationManager.class);

        session.setMavenSession(mavenSession);
    } catch (ComponentLookupException e) {
        logger.debug("Caught problem instantiating ", e);
        System.err.println("Unable to start Cli subsystem");
        System.exit(100);
        e.printStackTrace();
    } catch (PlexusContainerException e) {
        logger.debug("Caught problem instantiating ", e);
        System.err.println("Unable to start Cli subsystem");
        System.exit(100);
    } catch (SettingsBuildingException e) {
        logger.debug("Caught problem parsing settings file ", e);
        System.err.println("Unable to parse settings.xml file");
        System.exit(100);
    } catch (MavenExecutionRequestPopulationException e) {
        logger.debug("Caught problem populating maven request from settings file ", e);
        System.err.println("Unable to create maven execution request from settings.xml file");
        System.exit(100);
    }
}

From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java

License:Open Source License

MavenExecutionRequest createExecutionRequest() throws CoreException {
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();

    // this causes problems with unexpected "stale project configuration" error markers
    // need to think how to manage ${maven.build.timestamp} properly inside workspace
    //request.setStartTime( new Date() );

    if (mavenConfiguration.getGlobalSettingsFile() != null) {
        request.setGlobalSettingsFile(new File(mavenConfiguration.getGlobalSettingsFile()));
    }//from   ww  w . ja va  2 s . c o  m
    if (mavenConfiguration.getUserSettingsFile() != null) {
        request.setUserSettingsFile(new File(mavenConfiguration.getUserSettingsFile()));
    }

    try {
        lookup(MavenExecutionRequestPopulator.class).populateFromSettings(request, getSettings());
    } catch (MavenExecutionRequestPopulationException ex) {
        throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1,
                Messages.MavenImpl_error_no_exec_req, ex));
    }

    ArtifactRepository localRepository = getLocalRepository();
    request.setLocalRepository(localRepository);
    request.setLocalRepositoryPath(localRepository.getBasedir());
    request.setOffline(mavenConfiguration.isOffline());

    request.getUserProperties().put("m2e.version", MavenPluginActivator.getVersion()); //$NON-NLS-1$
    request.getUserProperties().put(ConfigurationProperties.USER_AGENT, MavenPluginActivator.getUserAgent());

    EnvironmentUtils.addEnvVars(request.getSystemProperties());
    request.getSystemProperties().putAll(System.getProperties());

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

    // the right way to disable snapshot update
    // request.setUpdateSnapshots(false);
    return request;
}

From source file:org.kie.scanner.embedder.MavenEmbedder.java

License:Apache License

protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest)
        throws MavenEmbedderException, ComponentLookupException {
    MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();

    if (mavenRequest.getGlobalSettingsFile() != null) {
        mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile()));
    }//from   www  .j  a  v  a  2s .co m

    if (mavenExecutionRequest.getUserSettingsFile() != null) {
        mavenExecutionRequest.setUserSettingsFile(new File(mavenRequest.getUserSettingsFile()));
    }

    try {
        lookup(MavenExecutionRequestPopulator.class).populateFromSettings(mavenExecutionRequest, getSettings());

        lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest);
    } catch (MavenExecutionRequestPopulationException e) {
        throw new MavenEmbedderException(e.getMessage(), e);
    }

    ArtifactRepository localRepository = getLocalRepository();
    mavenExecutionRequest.setLocalRepository(localRepository);
    mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir());
    mavenExecutionRequest.setOffline(mavenRequest.isOffline());

    mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots());

    // TODO check null and create a console one ?
    mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener());

    mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound());
    mavenExecutionRequest.setCacheTransferError(true);

    mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties());
    mavenExecutionRequest.getSystemProperties().putAll(System.getProperties());
    if (mavenRequest.getSystemProperties() != null) {
        mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties());
    }
    mavenExecutionRequest.getSystemProperties().putAll(getEnvVars());

    if (this.mavenHome != null) {
        mavenExecutionRequest.getSystemProperties().put("maven.home", this.mavenHome.getAbsolutePath());
    }

    if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) {
        for (String id : mavenRequest.getProfiles()) {
            Profile p = new Profile();
            p.setId(id);
            p.setSource("cli");
            mavenExecutionRequest.addProfile(p);
            mavenExecutionRequest.addActiveProfile(id);
        }
    }

    mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel());

    lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel());

    mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener())
            .setInteractiveMode(mavenRequest.isInteractive())
            .setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals());

    if (mavenRequest.getPom() != null) {
        mavenExecutionRequest.setPom(new File(mavenRequest.getPom()));
    }

    if (mavenRequest.getWorkspaceReader() != null) {
        mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader());
    }

    return mavenExecutionRequest;
}

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

License:Apache License

public void process(AFCliRequest cliRequest) throws Exception {
    CommandLine commandLine = cliRequest.getCommandLine();
    String workingDirectory = cliRequest.getWorkingDirectory();
    MavenExecutionRequest request = cliRequest.getRequest();
    Path userSettingsFile;/*from w ww.  j  a v a  2  s .c o  m*/
    if (commandLine.hasOption('s')) {
        userSettingsFile = Paths.get(commandLine.getOptionValue('s'));
        userSettingsFile = resolvePath(userSettingsFile, workingDirectory);
        if (!Files.isRegularFile(userSettingsFile)) {
            throw new FileNotFoundException(
                    "The specified user settings file does not exist: " + userSettingsFile);
        }
    } else {
        userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
    }

    Path globalSettingsFile;
    if (commandLine.hasOption("gs")) {
        globalSettingsFile = Paths.get(commandLine.getOptionValue("gs"));
        globalSettingsFile = resolvePath(globalSettingsFile, workingDirectory);
        if (!Files.isRegularFile(globalSettingsFile)) {
            throw new FileNotFoundException(
                    "The specified global settings file does not exist: " + globalSettingsFile);
        }
    } else {
        globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
    }

    request.setGlobalSettingsFile(globalSettingsFile.toFile());
    request.setUserSettingsFile(userSettingsFile.toFile());
    SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
    settingsRequest.setGlobalSettingsFile(globalSettingsFile.toFile());
    settingsRequest.setUserSettingsFile(userSettingsFile.toFile());
    settingsRequest.setSystemProperties(cliRequest.getSystemProperties());
    settingsRequest.setUserProperties(cliRequest.getUserProperties());
    if (request.getEventSpyDispatcher() != null) {
        request.getEventSpyDispatcher().onEvent(settingsRequest);
    }

    this.logger.debug("Reading global settings from " + this
            .getLocation(settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile()));
    this.logger.debug("Reading user settings from "
            + this.getLocation(settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile()));
    SettingsBuildingResult settingsResult = this.settingsBuilder.build(settingsRequest);
    if (request.getEventSpyDispatcher() != null) {
        request.getEventSpyDispatcher().onEvent(settingsResult);
    }

    this.populateFromSettings(request, settingsResult.getEffectiveSettings());
    if (!settingsResult.getProblems().isEmpty() && this.logger.isWarnEnabled()) {
        this.logger.warn("");
        this.logger.warn("Some problems were encountered while building the effective settings");
        Iterator i$ = settingsResult.getProblems().iterator();

        while (i$.hasNext()) {
            SettingsProblem problem = (SettingsProblem) i$.next();
            this.logger.warn(problem.getMessage() + " @ " + problem.getLocation());
        }

        this.logger.warn("");
    }
}

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

License:Apache License

@Override
public void process(AFCliRequest cliRequest) throws Exception {
    CommandLine commandLine = cliRequest.getCommandLine();
    String workingDirectory = cliRequest.getWorkingDirectory();
    MavenExecutionRequest request = cliRequest.getRequest();

    Path userSettingsFile;/* w  w w.  j a  va  2s. co m*/

    if (commandLine.hasOption(CLIManager.ALTERNATE_USER_SETTINGS)) {
        userSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS));
        userSettingsFile = resolvePath(userSettingsFile, workingDirectory);

        if (!Files.isRegularFile(userSettingsFile)) {
            throw new FileNotFoundException(
                    "The specified user settings file does not exist: " + userSettingsFile);
        }
    } else {
        userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
    }

    Path globalSettingsFile;

    if (commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_SETTINGS)) {
        globalSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_SETTINGS));
        globalSettingsFile = resolvePath(globalSettingsFile, workingDirectory);

        if (!Files.isRegularFile(globalSettingsFile)) {
            throw new FileNotFoundException(
                    "The specified global settings file does not exist: " + globalSettingsFile);
        }
    } else {
        globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
    }

    request.setGlobalSettingsFile(globalSettingsFile.toFile());
    request.setUserSettingsFile(userSettingsFile.toFile());

    AFSettingsBuildingRequest settingsRequest = new AFSettingsBuildingRequest();
    settingsRequest.setGlobalSettingsFile(globalSettingsFile.toFile());
    settingsRequest.setUserSettingsFile(userSettingsFile.toFile());
    settingsRequest.setSystemProperties(cliRequest.getSystemProperties());
    settingsRequest.setUserProperties(cliRequest.getUserProperties());

    if (request.getEventSpyDispatcher() != null) {
        request.getEventSpyDispatcher().onEvent(settingsRequest);
    }

    logger.debug("Reading global settings from "
            + getLocation(settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsPath()));
    logger.debug("Reading user settings from "
            + getLocation(settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsPath()));

    SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);

    if (request.getEventSpyDispatcher() != null) {
        request.getEventSpyDispatcher().onEvent(settingsResult);
    }

    populateFromSettings(request, settingsResult.getEffectiveSettings());

    if (!settingsResult.getProblems().isEmpty() && logger.isWarnEnabled()) {
        logger.warn("");
        logger.warn("Some problems were encountered while building the effective settings");

        for (SettingsProblem problem : settingsResult.getProblems()) {
            logger.warn(problem.getMessage() + " @ " + problem.getLocation());
        }
        logger.warn("");
    }
}