Example usage for org.apache.maven.settings.building FileSettingsSource FileSettingsSource

List of usage examples for org.apache.maven.settings.building FileSettingsSource FileSettingsSource

Introduction

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

Prototype

public FileSettingsSource(File settingsFile) 

Source Link

Document

Creates a new settings source backed by the specified file.

Usage

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

License:Apache License

private static SettingsSource initUserSettingsSource() {
    String customSettings = System.getProperty(CUSTOM_SETTINGS_PROPERTY);
    if (customSettings != null) {
        File customSettingsFile = new File(customSettings);
        if (customSettingsFile.exists()) {
            return new FileSettingsSource(customSettingsFile);
        } else {/*from  w  ww.  ja v  a 2s . c  o m*/
            try {
                return new UrlSettingsSource(new URL(customSettings));
            } catch (MalformedURLException e) {
                // Ignore
            }
            log.warn("Cannot find custom maven settings: " + customSettings);
        }
    }

    String userHome = System.getProperty("user.home");
    if (userHome != null) {
        File userSettingsFile = new File(userHome + "/.m2/settings.xml");
        if (userSettingsFile.exists()) {
            return new FileSettingsSource(userSettingsFile);
        }
    } else {
        log.warn("User home is not set");
    }

    return null;
}