當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。