Search in sources :

Example 6 with SettingsBuildingRequest

use of org.apache.maven.settings.building.SettingsBuildingRequest in project sts4 by spring-projects.

the class MavenBridge method buildSettings.

public Settings buildSettings(String globalSettings, String userSettings) throws MavenException {
    SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
    request.setGlobalSettingsFile(globalSettings != null ? new File(globalSettings) : null);
    request.setUserSettingsFile(userSettings != null ? new File(userSettings) : SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE);
    try {
        return lookup(SettingsBuilder.class).build(request).getEffectiveSettings();
    } catch (SettingsBuildingException ex) {
        throw new MavenException(ex);
    }
}
Also used : SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) File(java.io.File) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingRequest(org.apache.maven.settings.building.SettingsBuildingRequest)

Example 7 with SettingsBuildingRequest

use of org.apache.maven.settings.building.SettingsBuildingRequest in project drools by kiegroup.

the class MavenEmbedder method getSettings.

public Settings getSettings() throws MavenEmbedderException, ComponentLookupException {
    SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest();
    if (this.mavenRequest.getGlobalSettingsFile() != null) {
        settingsBuildingRequest.setGlobalSettingsFile(new File(this.mavenRequest.getGlobalSettingsFile()));
    } else {
        settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
    }
    if (this.mavenRequest.getUserSettingsSource() != null) {
        settingsBuildingRequest.setUserSettingsSource(this.mavenRequest.getUserSettingsSource());
    } else {
        SettingsSource userSettingsSource = MavenSettings.getUserSettingsSource();
        if (userSettingsSource != null) {
            settingsBuildingRequest.setUserSettingsSource(userSettingsSource);
        }
    }
    settingsBuildingRequest.setUserProperties(this.mavenRequest.getUserProperties());
    settingsBuildingRequest.getSystemProperties().putAll(System.getProperties());
    settingsBuildingRequest.getSystemProperties().putAll(this.mavenRequest.getSystemProperties());
    settingsBuildingRequest.getSystemProperties().putAll(getEnvVars());
    try {
        return componentProvider.lookup(SettingsBuilder.class).build(settingsBuildingRequest).getEffectiveSettings();
    } catch (SettingsBuildingException e) {
        throw new MavenEmbedderException(e.getMessage(), e);
    }
}
Also used : SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) FileSettingsSource(org.apache.maven.settings.building.FileSettingsSource) SettingsSource(org.apache.maven.settings.building.SettingsSource) File(java.io.File) IoUtils.copyInTempFile(org.kie.maven.integration.IoUtils.copyInTempFile) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingRequest(org.apache.maven.settings.building.SettingsBuildingRequest)

Example 8 with SettingsBuildingRequest

use of org.apache.maven.settings.building.SettingsBuildingRequest in project karaf by apache.

the class MavenConfigurationSupport method readSettings.

/**
 * Reads on demand <code>settings.xml</code> file - without password decryption. Also
 * collects declared servers by ID.
 * @param settingsFile
 */
protected synchronized Settings readSettings(File settingsFile) throws SettingsBuildingException {
    if (!settingsFile.isFile() || !settingsFile.canRead()) {
        return null;
    }
    try {
        DefaultSettingsBuilderFactory factory = new DefaultSettingsBuilderFactory();
        DefaultSettingsBuilder builder = factory.newInstance();
        SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
        request.setUserSettingsFile(settingsFile);
        SettingsBuildingResult result = builder.build(request);
        if (result.getProblems().size() > 0) {
            for (SettingsProblem problem : result.getProblems()) {
                System.err.println(problem);
            }
            return null;
        } else {
            Settings settings = result.getEffectiveSettings();
            if (settings.getServers() != null) {
                for (Server server : settings.getServers()) {
                    servers.put(server.getId(), server);
                }
            }
            return settings;
        }
    } catch (Throwable e) {
        System.err.println(e.getMessage());
        LOG.error(e.getMessage(), e);
        throw e;
    }
}
Also used : Server(org.apache.maven.settings.Server) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingResult(org.apache.maven.settings.building.SettingsBuildingResult) DefaultSettingsBuilder(org.apache.maven.settings.building.DefaultSettingsBuilder) DefaultSettingsBuilderFactory(org.apache.maven.settings.building.DefaultSettingsBuilderFactory) SettingsProblem(org.apache.maven.settings.building.SettingsProblem) Settings(org.apache.maven.settings.Settings) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingRequest(org.apache.maven.settings.building.SettingsBuildingRequest)

Example 9 with SettingsBuildingRequest

use of org.apache.maven.settings.building.SettingsBuildingRequest in project intellij-plugins by JetBrains.

the class GeneratorServer method createSettings.

private Settings createSettings(MavenExecutionRequest mavenExecutionRequest) throws ComponentLookupException, SettingsBuildingException {
    SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
    request.setSystemProperties(request.getSystemProperties());
    request.setGlobalSettingsFile(mavenExecutionRequest.getGlobalSettingsFile());
    request.setUserSettingsFile(mavenExecutionRequest.getUserSettingsFile());
    // IDEA-87004, getEffectiveSettings contains local repo as null, but our mavenExecutionRequest already has not-null local repo
    Settings settings = plexusContainer.lookup(SettingsBuilder.class).build(request).getEffectiveSettings();
    settings.setLocalRepository(mavenExecutionRequest.getLocalRepositoryPath().getPath());
    return settings;
}
Also used : DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) Settings(org.apache.maven.settings.Settings) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingRequest(org.apache.maven.settings.building.SettingsBuildingRequest)

Example 10 with SettingsBuildingRequest

use of org.apache.maven.settings.building.SettingsBuildingRequest in project fabric8 by jboss-fuse.

the class MavenConfigurationImpl method buildSettings.

private Settings buildSettings(String localRepoPath, String settingsPath, boolean useFallbackRepositories) {
    Settings settings;
    if (settingsPath == null) {
        settings = new Settings();
    } else {
        DefaultSettingsBuilderFactory factory = new DefaultSettingsBuilderFactory();
        DefaultSettingsBuilder builder = factory.newInstance();
        SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
        request.setUserSettingsFile(new File(settingsPath));
        try {
            SettingsBuildingResult result = builder.build(request);
            settings = result.getEffectiveSettings();
        } catch (SettingsBuildingException exc) {
            throw new AssertionError("cannot build settings", exc);
        }
    }
    if (useFallbackRepositories) {
        Profile fallbackProfile = new Profile();
        Repository central = new Repository();
        central.setId("central");
        central.setUrl("http://repo1.maven.org/maven2");
        fallbackProfile.setId("fallback");
        fallbackProfile.setRepositories(Arrays.asList(central));
        settings.addProfile(fallbackProfile);
        settings.addActiveProfile("fallback");
    }
    if (localRepoPath != null) {
        settings.setLocalRepository(localRepoPath);
    }
    return settings;
}
Also used : SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) Repository(org.apache.maven.settings.Repository) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingResult(org.apache.maven.settings.building.SettingsBuildingResult) DefaultSettingsBuilder(org.apache.maven.settings.building.DefaultSettingsBuilder) DefaultSettingsBuilderFactory(org.apache.maven.settings.building.DefaultSettingsBuilderFactory) File(java.io.File) Settings(org.apache.maven.settings.Settings) Profile(org.apache.maven.settings.Profile) DefaultSettingsBuildingRequest(org.apache.maven.settings.building.DefaultSettingsBuildingRequest) SettingsBuildingRequest(org.apache.maven.settings.building.SettingsBuildingRequest)

Aggregations

DefaultSettingsBuildingRequest (org.apache.maven.settings.building.DefaultSettingsBuildingRequest)13 SettingsBuildingRequest (org.apache.maven.settings.building.SettingsBuildingRequest)13 File (java.io.File)11 SettingsBuildingException (org.apache.maven.settings.building.SettingsBuildingException)10 Settings (org.apache.maven.settings.Settings)9 DefaultSettingsBuilderFactory (org.apache.maven.settings.building.DefaultSettingsBuilderFactory)6 DefaultSettingsBuilder (org.apache.maven.settings.building.DefaultSettingsBuilder)4 SettingsBuildingResult (org.apache.maven.settings.building.SettingsBuildingResult)4 IOException (java.io.IOException)1 Properties (java.util.Properties)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Profile (org.apache.maven.settings.Profile)1 Repository (org.apache.maven.settings.Repository)1 Server (org.apache.maven.settings.Server)1 FileSettingsSource (org.apache.maven.settings.building.FileSettingsSource)1 SettingsBuilder (org.apache.maven.settings.building.SettingsBuilder)1 SettingsProblem (org.apache.maven.settings.building.SettingsProblem)1 SettingsSource (org.apache.maven.settings.building.SettingsSource)1 IoUtils.copyInTempFile (org.kie.maven.integration.IoUtils.copyInTempFile)1