Search in sources :

Example 1 with PlexusComponentConfigurator

use of org.jetbrains.maven.embedder.PlexusComponentConfigurator in project intellij-community by JetBrains.

the class Maven2ServerEmbedderImpl method create.

public static Maven2ServerEmbedderImpl create(MavenServerSettings facadeSettings) throws RemoteException {
    MavenEmbedderSettings settings = new MavenEmbedderSettings();
    List<String> commandLineOptions = new ArrayList<String>();
    String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
    if (mavenEmbedderCliOptions != null) {
        commandLineOptions.addAll(StringUtil.splitHonorQuotes(mavenEmbedderCliOptions, ' '));
    }
    settings.setConfigurator(new PlexusComponentConfigurator() {

        public void configureComponents(@NotNull PlexusContainer c) {
            setupContainer(c);
        }
    });
    Maven2ServerConsoleWrapper consoleWrapper = new Maven2ServerConsoleWrapper();
    consoleWrapper.setThreshold(facadeSettings.getLoggingLevel());
    settings.setLogger(consoleWrapper);
    settings.setRecursive(false);
    settings.setWorkOffline(facadeSettings.isOffline());
    settings.setUsePluginRegistry(false);
    settings.setMavenHome(facadeSettings.getMavenHome());
    settings.setUserSettingsFile(facadeSettings.getUserSettingsFile());
    settings.setGlobalSettingsFile(facadeSettings.getGlobalSettingsFile());
    settings.setLocalRepository(facadeSettings.getLocalRepository());
    if (commandLineOptions.contains("-U") || commandLineOptions.contains("--update-snapshots")) {
        settings.setSnapshotUpdatePolicy(MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE);
    } else {
        settings.setSnapshotUpdatePolicy(convertUpdatePolicy(facadeSettings.getSnapshotUpdatePolicy()));
    }
    settings.setPluginUpdatePolicy(convertUpdatePolicy(facadeSettings.getPluginUpdatePolicy()));
    settings.setProperties(MavenServerUtil.collectSystemProperties());
    return new Maven2ServerEmbedderImpl(MavenEmbedder.create(settings), consoleWrapper);
}
Also used : PlexusContainer(org.codehaus.plexus.PlexusContainer) PlexusComponentConfigurator(org.jetbrains.maven.embedder.PlexusComponentConfigurator) MavenEmbedderSettings(org.jetbrains.maven.embedder.MavenEmbedderSettings)

Aggregations

PlexusContainer (org.codehaus.plexus.PlexusContainer)1 MavenEmbedderSettings (org.jetbrains.maven.embedder.MavenEmbedderSettings)1 PlexusComponentConfigurator (org.jetbrains.maven.embedder.PlexusComponentConfigurator)1