org.apache.maven.settings.Settings类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(14.1k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中org.apache.maven.settings.Settings类的一些代码示例,展示了Settings类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings类的具体详情如下:
包路径:org.apache.maven.settings.Settings
类名称:Settings

Settings介绍

[英]Root element of the user configuration file.
[中]用户配置文件的根元素。

代码示例

代码示例来源:origin: apache/maven

  1. recessive.setSourceLevel( recessiveSourceLevel );
  2. List<String> dominantActiveProfiles = dominant.getActiveProfiles();
  3. List<String> recessiveActiveProfiles = recessive.getActiveProfiles();
  4. dominant.setActiveProfiles( dominantActiveProfiles );
  5. List<String> dominantPluginGroupIds = dominant.getPluginGroups();
  6. List<String> recessivePluginGroupIds = recessive.getPluginGroups();
  7. dominant.setPluginGroups( dominantPluginGroupIds );
  8. if ( StringUtils.isEmpty( dominant.getLocalRepository() ) )
  9. dominant.setLocalRepository( recessive.getLocalRepository() );
  10. shallowMergeById( dominant.getMirrors(), recessive.getMirrors(), recessiveSourceLevel );
  11. shallowMergeById( dominant.getServers(), recessive.getServers(), recessiveSourceLevel );
  12. shallowMergeById( dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel );
  13. shallowMergeById( dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel );

代码示例来源:origin: eirslett/frontend-maven-plugin

  1. static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) {
  2. if (StringUtils.isEmpty(serverId)) {
  3. return null;
  4. }
  5. Server server = mavenSession.getSettings().getServer(serverId);
  6. if (server != null) {
  7. final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
  8. SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest);
  9. return decryptedResult.getServer();
  10. } else {
  11. LOGGER.warn("Could not find server '" + serverId + "' in settings.xml");
  12. return null;
  13. }
  14. }

代码示例来源:origin: apache/maven

  1. /**
  2. * @param settings could be null
  3. * @return a new instance of settings or null if settings was null.
  4. */
  5. public static Settings copySettings( Settings settings )
  6. {
  7. if ( settings == null )
  8. {
  9. return null;
  10. }
  11. Settings clone = new Settings();
  12. clone.setActiveProfiles( settings.getActiveProfiles() );
  13. clone.setInteractiveMode( settings.isInteractiveMode() );
  14. clone.setLocalRepository( settings.getLocalRepository() );
  15. clone.setMirrors( settings.getMirrors() );
  16. clone.setModelEncoding( settings.getModelEncoding() );
  17. clone.setOffline( settings.isOffline() );
  18. clone.setPluginGroups( settings.getPluginGroups() );
  19. clone.setProfiles( settings.getProfiles() );
  20. clone.setProxies( settings.getProxies() );
  21. clone.setServers( settings.getServers() );
  22. clone.setSourceLevel( settings.getSourceLevel() );
  23. clone.setUsePluginRegistry( settings.isUsePluginRegistry() );
  24. return clone;
  25. }
  26. }

代码示例来源:origin: apache/maven

  1. /**
  2. * Creates a new request to decrypt the specified settings.
  3. *
  4. * @param settings The settings to decrypt, must not be {@code null}.
  5. */
  6. public DefaultSettingsDecryptionRequest( Settings settings )
  7. {
  8. setServers( settings.getServers() );
  9. setProxies( settings.getProxies() );
  10. }

代码示例来源:origin: jeremylong/DependencyCheck

  1. settings.setString(Settings.KEYS.PROXY_SERVER, proxy.getHost());
  2. settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(proxy.getPort()));
  3. final String userName = proxy.getUsername();
  4. settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl);
  5. if (nexusServerId != null) {
  6. final Server server = settingsXml.getServer(nexusServerId);
  7. if (server != null) {
  8. final String nexusUser = server.getUsername();
  9. String nexusPassword = null;
  10. try {
  11. || (ex.getCause() != null && ex.getCause().getCause() instanceof FileNotFoundException)) {
  12. final String tmp = server.getPassword();
  13. if (Boolean.TRUE.equals(artifactoryAnalyzerEnabled)) {
  14. if (artifactoryAnalyzerServerId != null) {
  15. final Server server = settingsXml.getServer(artifactoryAnalyzerServerId);
  16. if (server != null) {
  17. settings.setStringIfNotNull(Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME, server.getUsername());
  18. settings.setStringIfNotEmpty(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
  19. if (databaseUser == null && databasePassword == null && serverId != null) {
  20. final Server server = settingsXml.getServer(serverId);

代码示例来源:origin: jmeter-maven-plugin/jmeter-maven-plugin

  1. /**
  2. * Try to load the active maven proxy.
  3. */
  4. protected void loadMavenProxy() {
  5. if (settings == null)
  6. return;
  7. try {
  8. Proxy mvnProxy = settings.getActiveProxy();
  9. if (mvnProxy != null) {
  10. ProxyConfiguration newProxyConf = new ProxyConfiguration();
  11. newProxyConf.setHost(mvnProxy.getHost());
  12. newProxyConf.setPort(mvnProxy.getPort());
  13. newProxyConf.setUsername(mvnProxy.getUsername());
  14. newProxyConf.setPassword(mvnProxy.getPassword());
  15. newProxyConf.setHostExclusions(mvnProxy.getNonProxyHosts());
  16. proxyConfig = newProxyConf;
  17. getLog().info("Maven proxy loaded successfully");
  18. } else {
  19. getLog().warn("No maven proxy found, but useMavenProxy set to true.");
  20. }
  21. } catch (Exception e) {
  22. getLog().error("Error while loading maven proxy", e);
  23. }
  24. }

代码示例来源:origin: apache/cxf

  1. protected void configureProxyServerSettings() throws MojoExecutionException {
  2. Proxy proxy = mavenSession.getSettings().getActiveProxy();
  3. if (proxy != null) {
  4. getLog().info("Using proxy server configured in maven.");
  5. if (proxy.getHost() == null) {
  6. throw new MojoExecutionException("Proxy in settings.xml has no host");
  7. }
  8. if (proxy.getHost() != null) {
  9. System.setProperty(HTTP_PROXY_HOST, proxy.getHost());
  10. }
  11. if (String.valueOf(proxy.getPort()) != null) {
  12. System.setProperty(HTTP_PROXY_PORT, String.valueOf(proxy.getPort()));
  13. }
  14. if (proxy.getNonProxyHosts() != null) {
  15. System.setProperty(HTTP_NON_PROXY_HOSTS, proxy.getNonProxyHosts());
  16. }
  17. if (!StringUtils.isEmpty(proxy.getUsername())
  18. && !StringUtils.isEmpty(proxy.getPassword())) {
  19. final String authUser = proxy.getUsername();
  20. final String authPassword = proxy.getPassword();
  21. Authenticator.setDefault(new Authenticator() {
  22. public PasswordAuthentication getPasswordAuthentication() {
  23. return new PasswordAuthentication(authUser, authPassword.toCharArray());
  24. }
  25. });
  26. System.setProperty(HTTP_PROXY_USER, authUser);
  27. System.setProperty(HTTP_PROXY_PORT, authPassword);
  28. }
  29. }
  30. }

代码示例来源:origin: highsource/maven-jaxb2-plugin

  1. protected String getActiveProxyAsHttpproxy() {
  2. if (getSettings() == null) {
  3. return null;
  4. }
  5. final Settings settings = getSettings();
  6. final Proxy activeProxy = settings.getActiveProxy();
  7. if (activeProxy == null || activeProxy.getHost() == null) {
  8. return null;
  9. }
  10. return createXJCProxyArgument(activeProxy.getHost(), activeProxy.getPort(), activeProxy.getUsername(),
  11. activeProxy.getPassword());
  12. }

代码示例来源:origin: SonarSource/sonar-scanner-maven

  1. public void setProxySystemProperties() {
  2. Proxy activeProxy = session.getSettings().getActiveProxy();
  3. if (activeProxy != null && activeProxy.getProtocol() != null && activeProxy.getProtocol().contains("http")) {
  4. log.debug("Setting proxy properties");
  5. System.setProperty("http.proxyHost", activeProxy.getHost());
  6. System.setProperty("http.proxyPort", String.valueOf(activeProxy.getPort()));
  7. System.setProperty("http.proxyUser", StringUtils.defaultString(activeProxy.getUsername(), ""));
  8. System.setProperty("http.proxyPassword", StringUtils.defaultString(activeProxy.getPassword(), ""));
  9. System.setProperty("http.nonProxyHosts", StringUtils.defaultString(activeProxy.getNonProxyHosts(), ""));
  10. }
  11. }
  12. }

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

  1. protected CredentialsProvider getCredentialsProvider(final Log log) throws ValidationException {
  2. if (serverId != null) {
  3. Server server = settings.getServer(serverId);
  4. if (server == null) {
  5. log.warn(format("No server configuration in Maven settings found with id %s", serverId));
  6. }
  7. if (server.getUsername() != null && server.getPassword() != null) {
  8. return new UsernamePasswordCredentialsProvider(server.getUsername(), server.getPassword());
  9. }
  10. }
  11. return null;
  12. }

代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin

  1. public void executeTask() throws MojoExecutionException, MojoFailureException {
  2. initSdkStatsFile();
  3. String localRepository = mavenSession.getSettings().getLocalRepository();
  4. File mavenHome = new File(localRepository).getParentFile();
  5. mavenHome.mkdirs();
  6. File mavenSettings = new File(mavenHome, SDKConstants.MAVEN_SETTINGS);
  7. try {
  8. SettingsManager settings = new SettingsManager(mavenSession);
  9. InputStream settingsStream = getClass().getClassLoader().getResourceAsStream(SDKConstants.MAVEN_SETTINGS);
  10. SettingsManager defaultSettings = new SettingsManager(settingsStream);
  11. settings.updateSettings(defaultSettings.getSettings());
  12. OutputStream out = new FileOutputStream(mavenSettings);
  13. settings.apply(out);
  14. getLog().info(String.format(SUCCESS_TEMPLATE, mavenSettings.getPath()));
  15. getLog().info(SDK_INFO);
  16. } catch (IOException e) {
  17. throw new MojoExecutionException(e.getMessage());
  18. }
  19. }

代码示例来源:origin: wouterd/docker-maven-plugin

  1. private Optional<Credentials> getCredentialsFromSettings() {
  2. if(settings == null) {
  3. getLog().debug("No settings.xml");
  4. return empty();
  5. }
  6. Server server = settings.getServer(serverId);
  7. if(server == null) {
  8. getLog().debug("Cannot find server " + serverId + " in Maven settings");
  9. return empty();
  10. }
  11. getLog().debug("Using credentials from Maven settings: " + server.getUsername());
  12. return of(new Credentials(server.getUsername(), server.getPassword(), getEmail(server), null));
  13. }

代码示例来源:origin: org.apache.maven.continuum/continuum-core

  1. private ArtifactRepository getRepository( Settings settings )
  2. {
  3. // ----------------------------------------------------------------------
  4. // Set our configured location as the default but try to use the defaults
  5. // as returned by the MavenSettings component.
  6. // ----------------------------------------------------------------------
  7. String localRepo = localRepository;
  8. if ( !( StringUtils.isEmpty( settings.getLocalRepository() ) ) )
  9. {
  10. localRepo = settings.getLocalRepository();
  11. }
  12. return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + localRepo, repositoryLayout,
  13. null, null );
  14. }

代码示例来源:origin: maven-gae-plugin/maven-gae-plugin

  1. /**
  2. * Passes command to the Google App Engine AppCfg runner.
  3. *
  4. * @param command command to run through AppCfg
  5. * @param commandArguments arguments to the AppCfg command.
  6. * @throws MojoExecutionException If {@link #ensureSystemProperties()} fails
  7. */
  8. protected final void runAppCfg(final String command, final String... commandArguments) throws MojoExecutionException {
  9. final List<String> args = new ArrayList<String>();
  10. args.addAll(getAppCfgArgs());
  11. args.add(command);
  12. args.addAll(Arrays.asList(commandArguments));
  13. if (goalArguments != null) {
  14. args.addAll(goalArguments);
  15. }
  16. ensureSystemProperties();
  17. getLog().debug("execute AppCfg " + args.toString());
  18. if (hasServerSettings()) {
  19. forkPasswordExpectThread(args.toArray(ARG_TYPE), decryptPassword(settings.getServer(serverId).getPassword()));
  20. return;
  21. }
  22. AppCfg.main(args.toArray(ARG_TYPE));
  23. }

代码示例来源:origin: jbossas/jboss-as-maven-plugin

  1. private void getCredentialsFromSettings() {
  2. if (settings != null) {
  3. Server server = settings.getServer(id);
  4. if (server != null) {
  5. getLog().debug(DEBUG_MESSAGE_SETTINGS_HAS_ID);
  6. password = decrypt(server);
  7. username = server.getUsername();
  8. if (username != null && password != null) {
  9. getLog().debug(DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
  10. } else {
  11. getLog().debug(DEBUG_MESSAGE_NO_CREDS);
  12. }
  13. } else {
  14. getLog().debug(DEBUG_MESSAGE_NO_SERVER_SECTION);
  15. }
  16. } else {
  17. getLog().debug(DEBUG_MESSAGE_NO_SETTINGS_FILE);
  18. }
  19. }

代码示例来源:origin: eirslett/frontend-maven-plugin

  1. static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) {
  2. if (mavenSession == null ||
  3. mavenSession.getSettings() == null ||
  4. mavenSession.getSettings().getProxies() == null ||
  5. mavenSession.getSettings().getProxies().isEmpty()) {
  6. return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList());
  7. } else {
  8. final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies();
  9. final List<ProxyConfig.Proxy> proxies = new ArrayList<ProxyConfig.Proxy>(mavenProxies.size());
  10. for (Proxy mavenProxy : mavenProxies) {
  11. if (mavenProxy.isActive()) {
  12. mavenProxy = decryptProxy(mavenProxy, decrypter);
  13. proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(),
  14. mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts()));
  15. }
  16. }
  17. LOGGER.info("Found proxies: {}", proxies);
  18. return new ProxyConfig(proxies);
  19. }
  20. }

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

  1. protected final void configureJsch(final Log log) {
  2. if (!disableSshAgent) {
  3. if (serverId != null) {
  4. final Server server = settings.getServer(serverId);
  5. if (server != null) {
  6. privateKey = privateKey == null ? server.getPrivateKey() : privateKey;
  7. passphrase = passphrase == null ? server.getPassphrase() : passphrase;
  8. } else {
  9. log.warn(format("No server configuration in Maven settings found with id %s", serverId));
  10. }
  11. }
  12. JschConfigSessionFactory.setInstance(new SshAgentSessionFactory(log, knownHosts, privateKey, passphrase));
  13. }
  14. }

代码示例来源:origin: apache/maven

  1. if ( settings.isUsePluginRegistry() )
  2. List<String> pluginGroups = settings.getPluginGroups();
  3. if ( StringUtils.isBlank( pluginGroup ) )
  4. List<Server> servers = settings.getServers();
  5. validateStringNotEmpty( problems, "servers.server[" + i + "].id", server.getId(), null );
  6. if ( !serverIds.add( server.getId() ) )
  7. "must be unique but found duplicate server with id " + server.getId() );
  8. List<Mirror> mirrors = settings.getMirrors();
  9. validateStringNotEmpty( problems, "mirrors.mirror.id", mirror.getId(), mirror.getUrl() );
  10. List<Profile> profiles = settings.getProfiles();
  11. List<Proxy> proxies = settings.getProxies();
  12. if ( !proxyIds.add( proxy.getId() ) )
  13. "must be unique but found duplicate proxy with id " + proxy.getId() );
  14. validateStringNotEmpty( problems, "proxies.proxy.host", proxy.getHost(), proxy.getId() );

代码示例来源:origin: raydac/mvn-golang

  1. @Nullable
  2. private ProxySettings extractProxySettings() {
  3. final ProxySettings result;
  4. if (this.isUseMavenProxy()) {
  5. final Proxy activeMavenProxy = this.settings == null ? null : this.settings.getActiveProxy();
  6. result = activeMavenProxy == null ? null : new ProxySettings(activeMavenProxy);
  7. getLog().debug("Detected maven proxy : " + result);
  8. } else {
  9. result = this.proxy;
  10. if (result != null) {
  11. getLog().debug("Defined proxy : " + result);
  12. }
  13. }
  14. return result;
  15. }

代码示例来源:origin: apache/maven

  1. request.setOffline( settings.isOffline() );
  2. request.setInteractiveMode( settings.isInteractiveMode() );
  3. request.setPluginGroups( settings.getPluginGroups() );
  4. request.setLocalRepositoryPath( settings.getLocalRepository() );
  5. for ( Server server : settings.getServers() )
  6. server = server.clone();
  7. for ( Proxy proxy : settings.getProxies() )
  8. if ( !proxy.isActive() )
  9. proxy = proxy.clone();
  10. for ( Mirror mirror : settings.getMirrors() )
  11. mirror = mirror.clone();
  12. request.setActiveProfiles( settings.getActiveProfiles() );
  13. for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
  14. if ( settings.getActiveProfiles().contains( rawProfile.getId() ) )

相关文章