List of usage examples for org.apache.maven.settings MavenSettingsBuilder ROLE
String ROLE
To view the source code for org.apache.maven.settings MavenSettingsBuilder ROLE.
Click Source Link
From source file:com.googlecode.jndiresources.maven.MavenEmbedder.java
License:Apache License
/** * Create the Settings that will be used with the embedder. If we are * aligning with the user installation then we lookup the standard settings * builder and use that to create our settings. Otherwise we constructs a * settings object and populate the information ourselves. * /*from w w w .j a v a 2s . c o m*/ * @throws XmlPullParserException If error. * @throws IOException If error. * @throws ComponentLookupException If error. */ private void createMavenSettings() throws ComponentLookupException, IOException, XmlPullParserException { if (alignWithUserInstallation_) { // ---------------------------------------------------------------------- // We will use the standard method for creating the settings. This // method reproduces the method of building the settings from the // CLI // mode of operation. // ---------------------------------------------------------------------- settingsBuilder_ = (MavenSettingsBuilder) embedder_.lookup(MavenSettingsBuilder.ROLE); settings_ = settingsBuilder_.buildSettings(); } else { if (localRepository_ == null) { throw new IllegalArgumentException("When not aligning with a user install you must specify " + "a local repository location using the " + "setLocalRepositoryDirectory( File ) method."); } settings_ = new Settings(); settings_.setLocalRepository(localRepositoryDirectory_.getAbsolutePath()); settings_.setOffline(offline_); settings_.setInteractiveMode(interactiveMode_); } }
From source file:net.oneandone.maven.embedded.Maven.java
License:Apache License
/** * @param globalSettings null to use default * @param userSettings null to use default *//*from w w w . j av a 2 s .co m*/ public static Settings loadSettings(World world, FileNode globalSettings, FileNode userSettings, DefaultPlexusContainer container) throws IOException, XmlPullParserException, ComponentLookupException { DefaultMavenSettingsBuilder builder; MavenExecutionRequest request; builder = (DefaultMavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE); request = new DefaultMavenExecutionRequest(); if (globalSettings == null) { globalSettings = locateMaven(world).join("conf/settings.xml"); } if (userSettings == null) { userSettings = (FileNode) world.getHome().join(".m2/settings.xml"); } request.setGlobalSettingsFile(globalSettings.toPath().toFile()); request.setUserSettingsFile(userSettings.toPath().toFile()); return builder.buildSettings(request); }
From source file:net.sourceforge.vulcan.maven.integration.MavenIntegration.java
License:Open Source License
public MavenIntegration() throws PlexusContainerException, ComponentLookupException, IOException, XmlPullParserException { embedder = new Embedder(); final ClassLoader prev = Thread.currentThread().getContextClassLoader(); try {//from w w w . j a v a 2s . co m Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); embedder.start(); } finally { Thread.currentThread().setContextClassLoader(prev); } final MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) embedder .lookup(MavenSettingsBuilder.ROLE); final Settings settings = settingsBuilder.buildSettings(); settings.setOffline(true); settings.setInteractiveMode(false); artifactRepository = createLocalRepository(embedder, settings); }
From source file:org.efaps.maven_java5.EfapsAnnotationDescriptorExtractor.java
License:Open Source License
/** * Initialize the container from the context. * *//*from w ww. j a v a2s . co m*/ public void contextualize(final Context _context) throws ContextException { final PlexusContainer container = (PlexusContainer) _context.get(PlexusConstants.PLEXUS_KEY); try { this.artifactRepositoryLayout = (ArtifactRepositoryLayout) container .lookup(ArtifactRepositoryLayout.ROLE); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactRepositoryLayout from PlexusContainer", e); } try { this.artifactRepositoryFactory = (ArtifactRepositoryFactory) container .lookup(ArtifactRepositoryFactory.ROLE); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactResolver from PlexusContainer", e); } try { this.settingsBuilder = (MavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactResolver from PlexusContainer", e); } try { this.artifactResolver = (ArtifactResolver) container.lookup(ArtifactResolver.ROLE); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactResolver from PlexusContainer", e); } try { this.artifactFactory = (ArtifactFactory) container.lookup(ArtifactFactory.ROLE); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactFactory from PlexusContainer", e); } try { this.artifactMetadataSource = (ArtifactMetadataSource) container.lookup(ArtifactMetadataSource.ROLE, "maven"); } catch (final ComponentLookupException e) { throw new ContextException("Could not get ArtifactMetadataSource from PlexusContainer", e); } }
From source file:org.jetbrains.maven.embedder.MavenEmbedder.java
License:Apache License
public static Settings buildSettings(PlexusContainer container, MavenEmbedderSettings embedderSettings) { File file = embedderSettings.getGlobalSettingsFile(); if (file != null) { System.setProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION, file.getPath()); }/*from w w w. j ava2s .c o m*/ Settings settings = null; try { MavenSettingsBuilder builder = (MavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE); File userSettingsFile = embedderSettings.getUserSettingsFile(); if (userSettingsFile != null && userSettingsFile.exists() && !userSettingsFile.isDirectory()) { settings = builder.buildSettings(userSettingsFile, false); } if (settings == null) { settings = builder.buildSettings(); } } catch (ComponentLookupException e) { MavenEmbedderLog.LOG.error(e); } catch (IOException e) { MavenEmbedderLog.LOG.warn(e); } catch (XmlPullParserException e) { MavenEmbedderLog.LOG.warn(e); } if (settings == null) { settings = new Settings(); } if (embedderSettings.getLocalRepository() != null) { settings.setLocalRepository(embedderSettings.getLocalRepository().getPath()); } if (settings.getLocalRepository() == null) { settings.setLocalRepository(System.getProperty("user.home") + "/.m2/repository"); } settings.setOffline(embedderSettings.isWorkOffline()); settings.setInteractiveMode(false); settings.setUsePluginRegistry(embedderSettings.isUsePluginRegistry()); RuntimeInfo runtimeInfo = new RuntimeInfo(settings); runtimeInfo.setPluginUpdateOverride( embedderSettings.getPluginUpdatePolicy() == MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE); settings.setRuntimeInfo(runtimeInfo); return settings; }
From source file:org.nuxeo.build.maven.EmbeddedMavenClient.java
License:Open Source License
/** * Default implementation is not flexible enough *///from w w w.j ava2 s.co m @Override protected void createMavenSettings() throws MavenEmbedderException, ComponentLookupException { if (settingsFile != null) { settingsBuilder = (MavenSettingsBuilder) embedder.lookup(MavenSettingsBuilder.ROLE); try { settings = settingsBuilder.buildSettings(settingsFile); } catch (IOException e) { throw new MavenEmbedderException("Error creating settings.", e); } catch (XmlPullParserException e) { throw new MavenEmbedderException("Error creating settings.", e); } } else { super.createMavenSettings(); } settings.setOffline(offline); }
From source file:org.nuxeo.build.maven.MavenEmbedder.java
License:Open Source License
/** * Create the Settings that will be used with the embedder. If we are * aligning with the user installation then we lookup the standard settings * builder and use that to create our settings. Otherwise we constructs a * settings object and populate the information ourselves. * * @throws MavenEmbedderException//from ww w . ja v a2s . c om * @throws ComponentLookupException */ protected void createMavenSettings() throws MavenEmbedderException, ComponentLookupException { if (alignWithUserInstallation) { // ---------------------------------------------------------------------- // We will use the standard method for creating the settings. This // method reproduces the method of building the settings from the // CLI // mode of operation. // ---------------------------------------------------------------------- settingsBuilder = (MavenSettingsBuilder) embedder.lookup(MavenSettingsBuilder.ROLE); try { settings = settingsBuilder.buildSettings(); } catch (IOException e) { throw new MavenEmbedderException("Error creating settings.", e); } catch (XmlPullParserException e) { throw new MavenEmbedderException("Error creating settings.", e); } } else { if (localRepository == null) { localRepository = createLocalRepository(localRepositoryDirectory); // throw new IllegalArgumentException( // "When not aligning with a user install you must specify a local repository location using the setLocalRepositoryDirectory( File ) method."); } settings = new Settings(); settings.setLocalRepository(localRepositoryDirectory.getAbsolutePath()); settings.setRuntimeInfo(createRuntimeInfo()); settings.setOffline(offline); settings.setInteractiveMode(interactiveMode); } // bs: correctly init wagon initWagonFromSettings(); // end bs }