Example usage for org.apache.maven.settings.building SettingsBuildingRequest setGlobalSettingsSource

List of usage examples for org.apache.maven.settings.building SettingsBuildingRequest setGlobalSettingsSource

Introduction

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

Prototype

SettingsBuildingRequest setGlobalSettingsSource(SettingsSource globalSettingsSource);

Source Link

Document

Sets the global settings source.

Usage

From source file:org.hudsonci.maven.eventspy_30.handler.SettingsBuildingRequestHandler.java

License:Open Source License

public void handle(final SettingsBuildingRequest event) throws Exception {
    log.debug("Settings request: {}", event);

    DocumentReference document;/*  w ww  .j  av a  2 s. c  o m*/

    // TODO: Support debug option to write document to disk

    document = getCallback().getSettingsDocument();
    log.debug("Settings document: {}", document);

    if (document != null) {
        if (event.getUserSettingsFile() != DEFAULT_USER_SETTINGS_FILE) {
            log.warn(
                    "Custom settings file configured via command-line as well as via document; document taking precedence");
        }

        log.info("Using settings document ID: {}", document.getId());
        log.trace("Content:\n{}", document.getContent()); // FIXME: May contain sensitive data

        event.setUserSettingsFile(null);
        event.setUserSettingsSource(new StringSettingsSource(document.getContent(), document.getLocation()));
    }

    document = getCallback().getGlobalSettingsDocument();
    log.debug("Global settings document: {}", document);

    if (document != null) {
        if (event.getGlobalSettingsFile() != DEFAULT_GLOBAL_SETTINGS_FILE) {
            log.warn(
                    "Custom global settings file configured via command-line as well as via document; document taking precedence");
        }

        log.info("Using global settings document ID: {}", document.getId());
        log.trace("Content:\n{}", document.getContent()); // FIXME: May contain sensitive data

        event.setGlobalSettingsFile(null);
        event.setGlobalSettingsSource(new StringSettingsSource(document.getContent(), document.getLocation()));
    }
}