Example usage for org.apache.maven.settings.building SettingsProblem getMessage

List of usage examples for org.apache.maven.settings.building SettingsProblem getMessage

Introduction

In this page you can find the example usage for org.apache.maven.settings.building SettingsProblem getMessage.

Prototype

String getMessage();

Source Link

Document

Gets the message that describes this problem.

Usage

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

License:Apache License

protected void injectSettings(final EMBExecutionRequest request) throws EMBEmbeddingException {
    Settings settings = request.getSettings();
    SettingsBuildingResult settingsResult = null;
    if (settings == null) {
        final SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
        settingsRequest.setGlobalSettingsFile(request.getGlobalSettingsFile());
        settingsRequest.setUserSettingsFile(request.getUserSettingsFile());

        settingsRequest.setSystemProperties(request.getSystemProperties());
        settingsRequest.setUserProperties(request.getUserProperties());

        try {/*w w  w  .java2 s.c o m*/
            settingsResult = settingsBuilder.build(settingsRequest);
        } catch (final SettingsBuildingException e) {
            throw new EMBEmbeddingException(
                    "Failed to build settings; {0}\nGlobal settings: {1}\nUser settings: {2}", e,
                    e.getMessage(), request.getGlobalSettingsFile(), request.getUserSettingsFile());
        }

        settings = settingsResult.getEffectiveSettings();
    }

    try {
        executionRequestPopulator.populateFromSettings(request.asMavenExecutionRequest(), settings);
    } catch (final MavenExecutionRequestPopulationException e) {
        throw new EMBEmbeddingException("Failed to populate request from settings; {0}", e, e.getMessage());
    }

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

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

        logger.warn("");
    }
}

From source file:org.debian.dependency.sources.SCMSourceRetrieval.java

License:Apache License

@Override
public String retrieveSource(final Artifact artifact, final File directory, final MavenSession session)
        throws SourceRetrievalException {
    MavenProject project = findProjectRoot(constructProject(artifact, session));
    Scm scm = project.getScm();//w  w  w .ja v a  2 s . c  o  m
    if (scm == null) {
        return null;
    }

    SettingsDecryptionResult decryptionResult = settingsDecrypter
            .decrypt(new DefaultSettingsDecryptionRequest(session.getSettings()));
    for (SettingsProblem problem : decryptionResult.getProblems()) {
        getLogger().warn("Error decrypting settings (" + problem.getLocation() + ") : " + problem.getMessage(),
                problem.getException());
    }

    try {
        // first we check developer connection
        CheckOutScmResult checkoutResult = null;
        String connection = scm.getDeveloperConnection();
        try {
            checkoutResult = performCheckout(connection, determineVersion(scm), directory,
                    decryptionResult.getServers());
        } catch (ScmException e) {
            // we don't really care about the exception here because we will try the regular connection next
            getLogger().debug(
                    "Unable to checkout sources using developer connection, trying standard connection", e);
        }

        // now the regular connection if it wasn't successful
        if (checkoutResult == null || !checkoutResult.isSuccess()) {
            connection = scm.getConnection();
            checkoutResult = performCheckout(connection, determineVersion(scm), directory,
                    decryptionResult.getServers());
        }

        if (checkoutResult == null) {
            throw new SourceRetrievalException("No scm information available");
        } else if (!checkoutResult.isSuccess()) {
            getLogger().error("Provider Message:");
            getLogger().error(StringUtils.defaultString(checkoutResult.getProviderMessage()));
            getLogger().error("Commandline:");
            getLogger().error(StringUtils.defaultString(checkoutResult.getCommandOutput()));
            throw new SourceRetrievalException("Unable to checkout files: "
                    + StringUtils.defaultString(checkoutResult.getProviderMessage()));
        }
        return connection;
    } catch (ScmException e) {
        throw new SourceRetrievalException("Unable to checkout project", e);
    }
}

From source file:org.eclipse.ebr.maven.EclipseIpLogUtil.java

License:Open Source License

private Server getServer(final String serverId, final Settings settings,
        final SettingsDecrypter settingsDecrypter) {
    for (Server server : settings.getServers()) {
        if (StringUtils.equals(server.getId(), serverId)) {
            final SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
            final SettingsDecryptionResult result = settingsDecrypter.decrypt(request);
            server = result.getServer();

            // log any detected problems
            for (final SettingsProblem problem : result.getProblems()) {
                getLog().warn(problem.getMessage(), problem.getException());
            }/*from  w  w w .j  a v  a  2s . co m*/

            return server;
        }
    }

    return null;
}

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

License:Open Source License

public Server decryptPassword(Server server) throws CoreException {
    SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
    SettingsDecryptionResult result = lookup(SettingsDecrypter.class).decrypt(request);
    for (SettingsProblem problem : result.getProblems()) {
        log.warn(problem.getMessage(), problem.getException());
    }/*  ww w  . j a  v  a  2s . c o m*/
    return result.getServer();
}

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;/*w w w.ja  va2 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 v  a  2  s. c o  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("");
    }
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.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;/*from  w  w w .  j  ava  2 s .com*/

    if (commandLine.hasOption(CLIManager.ALTERNATE_USER_SETTINGS)) {
        String settingsFromCLi = commandLine.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS);
        logger.info("userSettings:" + settingsFromCLi);
        if (settingsFromCLi != null) {
            userSettingsFile = Paths.get(settingsFromCLi.trim());
            /*userSettingsFile = resolvePath(userSettingsFile,
                                   workingDirectory); why this override of the value ? */

            if (!Files.isRegularFile(userSettingsFile)) {
                throw new FileNotFoundException(
                        "The specified user settings file does not exist: " + userSettingsFile);
            }
        } else {
            userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
            logger.info("Using default userSettings:" + 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("");
    }
}

From source file:org.springframework.ide.vscode.commons.maven.MavenBridge.java

License:Open Source License

public Server decryptPassword(Server server) throws MavenException {
    SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
    SettingsDecryptionResult result = lookup(SettingsDecrypter.class).decrypt(request);
    for (SettingsProblem problem : result.getProblems()) {
        log.warn(problem.getMessage(), problem.getException());
    }/* ww w  .ja  v a 2 s .c  o  m*/
    return result.getServer();
}

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

License:Apache License

private void settings(CliRequest cliRequest) throws Exception {
    File userSettingsFile;//from   ww w .j a va2s  .  c  om

    if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_USER_SETTINGS)) {
        userSettingsFile = new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS));
        userSettingsFile = resolveFile(userSettingsFile, cliRequest.workingDirectory);

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

    logger.debug("Reading user settings from " + userSettingsFile);

    File globalSettingsFile;

    if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_SETTINGS)) {
        globalSettingsFile = new File(
                cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_SETTINGS));
        globalSettingsFile = resolveFile(globalSettingsFile, cliRequest.workingDirectory);

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

    logger.debug("Reading global settings from " + globalSettingsFile);

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

    SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
    settingsRequest.setGlobalSettingsFile(globalSettingsFile);
    settingsRequest.setUserSettingsFile(userSettingsFile);
    settingsRequest.setSystemProperties(cliRequest.systemProperties);
    settingsRequest.setUserProperties(cliRequest.userProperties);

    SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);

    executionRequestPopulator.populateFromSettings(cliRequest.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("");
    }
}

From source file:ph.samson.maven.cpages.DeployMojo.java

License:Apache License

private Server getServerSettings(String id) throws MojoExecutionException {
    SettingsDecryptionRequest sdr = new DefaultSettingsDecryptionRequest(settings.getServer(id));
    SettingsDecryptionResult decrypt = decrypter.decrypt(sdr);
    for (SettingsProblem problem : decrypt.getProblems()) {
        switch (problem.getSeverity()) {
        case WARNING:
            log.warn("{} ({})", problem.getMessage(), problem.getLocation());
            break;
        case ERROR:
            log.error("{} ({})", problem.getMessage(), problem.getLocation());
            break;
        case FATAL:
            log.error("{} ({})", problem.getMessage(), problem.getLocation());
            throw new MojoExecutionException(problem.getMessage());
        }//ww w .  j a v a  2  s  . co m
    }
    return decrypt.getServer();
}