当前位置: 首页>>代码示例>>Java>>正文


Java Settings类代码示例

本文整理汇总了Java中org.apache.maven.settings.Settings的典型用法代码示例。如果您正苦于以下问题:Java Settings类的具体用法?Java Settings怎么用?Java Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Settings类属于org.apache.maven.settings包,在下文中一共展示了Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMirrorInfo

import org.apache.maven.settings.Settings; //导入依赖的package包/类
/**
 * if the repository has a mirror, then create a repositoryinfo object for it..
 */

private RepositoryInfo getMirrorInfo(RepositoryInfo info, MirrorSelector selector, Settings settings) {
    RemoteRepository original = new RemoteRepository.Builder(info.getId(), /* XXX do we even support any other layout?*/"default", info.getRepositoryUrl()).build();
    RemoteRepository mirror = selector.getMirror(original);
    if (mirror != null) {
        try {
            String name = mirror.getId();
            //#213078 need to lookup name for mirror
            for (Mirror m : settings.getMirrors()) {
                if (m.getId() != null && m.getId().equals(mirror.getId())) {
                    name = m.getName();
                    break;
                }
            }
            RepositoryInfo toret = new RepositoryInfo(mirror.getId(), name, null, mirror.getUrl());
            toret.setMirrorStrategy(RepositoryInfo.MirrorStrategy.NONE);
            return toret;
        } catch (URISyntaxException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:RepositoryPreferences.java

示例2: updateAppRuntime

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@Test
public void updateAppRuntime() throws Exception {
    final SiteInner siteInner = mock(SiteInner.class);
    doReturn("app,linux").when(siteInner).kind();
    final WithCredentials withCredentials = mock(WithCredentials.class);
    final Update update = mock(Update.class);
    doReturn(withCredentials).when(update).withPrivateRegistryImage(null, null);
    final WebApp app = mock(WebApp.class);
    doReturn(siteInner).when(app).inner();
    doReturn(update).when(app).update();

    final ContainerSetting containerSetting = new ContainerSetting();
    containerSetting.setServerId("serverId");
    doReturn(containerSetting).when(mojo).getContainerSettings();

    final Server server = mock(Server.class);
    final Settings settings = mock(Settings.class);
    doReturn(server).when(settings).getServer(anyString());
    doReturn(settings).when(mojo).getSettings();

    handler.updateAppRuntime(app);

    verify(update, times(1)).withPrivateRegistryImage(null, null);
    verify(server, times(1)).getUsername();
    verify(server, times(1)).getPassword();
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:27,代码来源:PrivateRegistryRuntimeHandlerImplTest.java

示例3: updateAppRuntime

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@Test
public void updateAppRuntime() throws Exception {
    final WebApp app = mock(WebApp.class);
    final SiteInner siteInner = mock(SiteInner.class);
    doReturn("app,linux").when(siteInner).kind();
    doReturn(siteInner).when(app).inner();
    final Update update = mock(Update.class);
    final WithCredentials withCredentials = mock(WithCredentials.class);
    doReturn(withCredentials).when(update).withPrivateDockerHubImage(null);
    doReturn(update).when(app).update();

    final ContainerSetting containerSetting = new ContainerSetting();
    containerSetting.setServerId("serverId");
    doReturn(containerSetting).when(mojo).getContainerSettings();

    final Server server = mock(Server.class);
    final Settings settings = mock(Settings.class);
    doReturn(server).when(settings).getServer(anyString());
    doReturn(settings).when(mojo).getSettings();

    handler.updateAppRuntime(app);

    verify(update, times(1)).withPrivateDockerHubImage(null);
    verify(server, times(1)).getUsername();
    verify(server, times(1)).getPassword();
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:27,代码来源:PrivateDockerHubRuntimeHandlerImplTest.java

示例4: getAuthObjFromServerId

import org.apache.maven.settings.Settings; //导入依赖的package包/类
/**
 * Get Authenticated object by referencing server definition in Maven settings.xml
 *
 * @param settings Settings object
 * @param serverId Server Id to search in settings.xml
 * @return Authenticated object if configurations are correct; otherwise return null.
 */
protected Authenticated getAuthObjFromServerId(final Settings settings, final String serverId) {
    if (StringUtils.isEmpty(serverId)) {
        getLog().debug(SERVER_ID_NOT_CONFIG);
        return null;
    }

    final Server server = Utils.getServer(settings, serverId);
    if (server == null) {
        getLog().error(SERVER_ID_NOT_FOUND + serverId);
        return null;
    }

    final ApplicationTokenCredentials credential = getAppTokenCredentialsFromServer(server);
    if (credential == null) {
        getLog().error(AZURE_AUTH_INVALID + serverId);
        return null;
    }

    final Authenticated auth = azureConfigure().authenticate(credential);
    if (auth != null) {
        getLog().info(AUTH_WITH_SERVER_ID + serverId);
    }
    return auth;
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:32,代码来源:AzureAuthHelper.java

示例5: doExecute

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
    final AddMojo mojo = getMojoFromPom();
    final Settings settings = new Settings();
    settings.setInteractiveMode(false);
    ReflectionUtils.setVariableValueInObject(mojo, "basedir", new File("target/test"));
    ReflectionUtils.setVariableValueInObject(mojo, "settings", settings);
    mojo.setFunctionTemplate("HttpTrigger");
    mojo.setFunctionName("New-Function");
    mojo.setFunctionPackageName("com.microsoft.azure");

    final File newFunctionFile = new File("target/test/src/main/java/com/microsoft/azure/New_Function.java");
    newFunctionFile.delete();

    mojo.doExecute();

    assertTrue(newFunctionFile.exists());
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:19,代码来源:AddMojoTest.java

示例6: loadMavenSettings

import org.apache.maven.settings.Settings; //导入依赖的package包/类
public static Settings loadMavenSettings()
    throws SettingsBuildingException {
  // http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
  SettingsBuildingRequest settingsBuildingRequest =
      new DefaultSettingsBuildingRequest();
  settingsBuildingRequest.setSystemProperties(System.getProperties());
  settingsBuildingRequest.setUserSettingsFile(new File(settingsXml));
  settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);

  SettingsBuildingResult settingsBuildingResult;
  DefaultSettingsBuilderFactory mvnSettingBuilderFactory =
      new DefaultSettingsBuilderFactory();
  DefaultSettingsBuilder settingsBuilder =
      mvnSettingBuilderFactory.newInstance();
  settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest);

  Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings();
  return effectiveSettings;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:20,代码来源:Utils.java

示例7: getSettings

import org.apache.maven.settings.Settings; //导入依赖的package包/类
private static final Settings getSettings() throws SettingsBuildingException {
  final SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance(); // this method should be static!
  assert settingsBuilder != null;
  final DefaultSettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest();
  settingsBuildingRequest.setSystemProperties(System.getProperties());
  // settingsBuildingRequest.setUserProperties(userProperties); // TODO: implement this
  settingsBuildingRequest.setGlobalSettingsFile(new File("/usr/local/maven/conf/settings.xml")); // TODO: do this for real
  settingsBuildingRequest.setUserSettingsFile(new File(new File(System.getProperty("user.home")), ".m2/settings.xml"));
  final SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest);
  assert settingsBuildingResult != null;
  final List<SettingsProblem> settingsBuildingProblems = settingsBuildingResult.getProblems();
  if (settingsBuildingProblems != null && !settingsBuildingProblems.isEmpty()) {
    throw new SettingsBuildingException(settingsBuildingProblems);
  }
  return settingsBuildingResult.getEffectiveSettings();
}
 
开发者ID:microbean,项目名称:microbean-helm-maven,代码行数:17,代码来源:TestMavenRepositoryChartResolver.java

示例8: setUp

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@Before
public void setUp() {
  logOutput = mock(LogOutput.class);
  runtimeInformation = mock(RuntimeInformation.class, Mockito.RETURNS_DEEP_STUBS);
  mavenSession = mock(MavenSession.class);
  rootProject = mock(MavenProject.class);
  mojoExecution = mock(MojoExecution.class);
  envProps = new Properties();

  Properties system = new Properties();
  system.put("system", "value");
  system.put("user", "value");
  Properties root = new Properties();
  root.put("root", "value");
  envProps.put("env", "value");

  when(mojoExecution.getVersion()).thenReturn("2.0");
  when(runtimeInformation.getMavenVersion()).thenReturn("1.0");
  when(mavenSession.getSystemProperties()).thenReturn(system);
  when(mavenSession.getUserProperties()).thenReturn(new Properties());
  when(mavenSession.getSettings()).thenReturn(new Settings());
  when(rootProject.getProperties()).thenReturn(root);
  when(mavenSession.getCurrentProject()).thenReturn(rootProject);
  propertyDecryptor = new PropertyDecryptor(mock(Log.class), mock(SecDispatcher.class));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:26,代码来源:ScannerFactoryTest.java

示例9: determineActiveProfiles

import org.apache.maven.settings.Settings; //导入依赖的package包/类
private List<Profile> determineActiveProfiles(Settings settings) {
	SpringBootCliModelProblemCollector problemCollector = new SpringBootCliModelProblemCollector();
	List<org.apache.maven.model.Profile> activeModelProfiles = createProfileSelector()
			.getActiveProfiles(createModelProfiles(settings.getProfiles()),
					new SpringBootCliProfileActivationContext(
							settings.getActiveProfiles()),
					problemCollector);
	if (!problemCollector.getProblems().isEmpty()) {
		throw new IllegalStateException(createFailureMessage(problemCollector));
	}
	List<Profile> activeProfiles = new ArrayList<Profile>();
	Map<String, Profile> profiles = settings.getProfilesAsMap();
	for (org.apache.maven.model.Profile modelProfile : activeModelProfiles) {
		activeProfiles.add(profiles.get(modelProfile.getId()));
	}
	return activeProfiles;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:MavenSettings.java

示例10: getAwsKeyPair

import org.apache.maven.settings.Settings; //导入依赖的package包/类
static AwsKeyPair getAwsKeyPair(String serverId, String awsAccessKey, String awsSecretAccessKey,
        Settings settings, SettingsDecrypter decrypter) throws MojoExecutionException {
    final AwsKeyPair keys;
    if (serverId != null) {
        Server server = settings.getServer(serverId);
        if (server == null) {
            throw new MojoExecutionException("serverId not found in settings: " + serverId);
        } else {
            SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
            SettingsDecryptionResult result = decrypter.decrypt(request);
            keys = new AwsKeyPair(result.getServer().getUsername(),
                    result.getServer().getPassword());
        }
    } else {
        keys = new AwsKeyPair(awsAccessKey, awsSecretAccessKey);
    }
    return keys;
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:19,代码来源:Util.java

示例11: loadSettings

import org.apache.maven.settings.Settings; //导入依赖的package包/类
private Settings loadSettings() {
	File settingsFile = new File(this.homeDir, ".m2/settings.xml");
	if (settingsFile.exists()) {
		log.info("Reading settings from: " + settingsFile);
	}
	else {
		log.info("No settings found at: " + settingsFile);
	}
	SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
	request.setUserSettingsFile(settingsFile);
	request.setSystemProperties(System.getProperties());
	try {
		return new DefaultSettingsBuilderFactory().newInstance().build(request)
				.getEffectiveSettings();
	}
	catch (SettingsBuildingException ex) {
		throw new IllegalStateException(
				"Failed to build settings from " + settingsFile, ex);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:21,代码来源:MavenSettingsReader.java

示例12: getPropertyValueInSettings

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@SuppressWarnings("unchecked") // because of Maven poor typing
public String getPropertyValueInSettings(String propertyName, Settings settings) {
	if (settings == null) {
		return null;
	}

	List<String> activeProfiles = settings.getActiveProfiles();

	for (Object _profileWithId : settings.getProfilesAsMap().entrySet()) {
		Entry<String, Profile> profileWithId = (Entry<String, Profile>) _profileWithId;
		if (activeProfiles.contains(profileWithId.getKey())) {
			Profile profile = profileWithId.getValue();

			String value = profile.getProperties().getProperty(propertyName);
			if (value != null) {
				return value;
			}
		}
	}

	return null;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:23,代码来源:AbstractBWMojo.java

示例13: propertyExistsInSettings

import org.apache.maven.settings.Settings; //导入依赖的package包/类
@SuppressWarnings("unchecked") // because of Maven poor typing
public boolean propertyExistsInSettings(String propertyName, Settings settings) {
	if (settings == null) {
		return false;
	}

	List<String> activeProfiles = getActiveProfiles(settings);

	for (Object _profileWithId : settings.getProfilesAsMap().entrySet()) {
		Entry<String, Profile> profileWithId = (Entry<String, Profile>) _profileWithId;
		if (activeProfiles.contains(profileWithId.getKey())) {
			Profile profile = profileWithId.getValue();

			boolean result = profile.getProperties().containsKey(propertyName);
			if (result) {
				return result;
			}
		}
	}

	return false;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:23,代码来源:AbstractBWMojo.java

示例14: test002DefaultUsernamePassword

import org.apache.maven.settings.Settings; //导入依赖的package包/类
public void test002DefaultUsernamePassword()
    throws MojoExecutionException
{

    Settings settings = new Settings();
    Server server = new Server();
    settings.addServer( server );

    mojo.setSettings( settings );

    // force a lookup of username
    mojo.setUsername( null );
    mojo.setPassword( null );

    mojo.execute();

    assertEquals( "", mojo.getUsername() );
    assertEquals( "", mojo.getPassword() );

}
 
开发者ID:mojohaus,项目名称:sql-maven-plugin,代码行数:21,代码来源:SqlExecMojoTest.java

示例15: test003UsernamePasswordLookup

import org.apache.maven.settings.Settings; //导入依赖的package包/类
public void test003UsernamePasswordLookup()
    throws MojoExecutionException
{

    Settings settings = new Settings();
    Server server = new Server();
    server.setId( "somekey" );
    server.setUsername( "username" );
    server.setPassword( "password" );
    settings.addServer( server );

    mojo.setSettings( settings );

    // force a lookup of username
    mojo.setSettingsKey( "somekey" );
    mojo.setUsername( null );
    mojo.setPassword( null );

    mojo.execute();

    assertEquals( "username", mojo.getUsername() );
    assertEquals( "password", mojo.getPassword() );

}
 
开发者ID:mojohaus,项目名称:sql-maven-plugin,代码行数:25,代码来源:SqlExecMojoTest.java


注:本文中的org.apache.maven.settings.Settings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。