本文整理汇总了Java中org.apache.maven.settings.Settings.getServer方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.getServer方法的具体用法?Java Settings.getServer怎么用?Java Settings.getServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Settings
的用法示例。
在下文中一共展示了Settings.getServer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: getRemoteRepoFromDeployment
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository repo,
final MavenEmbedder embedder) {
RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(repo.getId(),
repo.getLayout(),
repo
.getUrl())
.setSnapshotPolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_DAILY,
RepositoryPolicy.CHECKSUM_POLICY_WARN))
.setReleasePolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_ALWAYS,
RepositoryPolicy.CHECKSUM_POLICY_WARN));
Settings settings = MavenSettings.getSettings();
Server server = settings.getServer(repo.getId());
if (server != null) {
Authentication authentication = embedder.getMavenSession().getRepositorySession()
.getAuthenticationSelector()
.getAuthentication(remoteRepoBuilder.build());
remoteRepoBuilder.setAuthentication(authentication);
}
return remoteRepoBuilder.build();
}
示例3: convertToArtifactRepository
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private RemoteRepository convertToArtifactRepository(final org.apache.maven.artifact.repository.ArtifactRepository artifactRepository) {
final MavenEmbedder mavenEmbedder = MavenProjectLoader.newMavenEmbedder(MavenSettings.getSettings().isOffline());
final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(artifactRepository.getId(),
artifactRepository.getLayout().getId(),
artifactRepository.getUrl())
.setSnapshotPolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_DAILY,
RepositoryPolicy.CHECKSUM_POLICY_WARN))
.setReleasePolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_ALWAYS,
RepositoryPolicy.CHECKSUM_POLICY_WARN));
final Settings settings = MavenSettings.getSettings();
final Server server = settings.getServer(artifactRepository.getId());
if (server != null) {
final Authentication authentication = mavenEmbedder
.getMavenSession()
.getRepositorySession()
.getAuthenticationSelector()
.getAuthentication(remoteRepoBuilder.build());
remoteRepoBuilder.setAuthentication(authentication);
}
return remoteRepoBuilder.build();
}
示例4: getRemoteRepoFromDeployment
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private static RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository deploymentRepository,
final RepositorySystemSession mavenSession) {
final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(deploymentRepository.getId(),
deploymentRepository.getLayout(),
deploymentRepository.getUrl())
.setSnapshotPolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_DAILY,
RepositoryPolicy.CHECKSUM_POLICY_WARN))
.setReleasePolicy(new RepositoryPolicy(true,
RepositoryPolicy.UPDATE_POLICY_DAILY,
RepositoryPolicy.CHECKSUM_POLICY_WARN));
final Settings settings = MavenSettings.getSettings();
final Server server = settings.getServer(deploymentRepository.getId());
if (server != null) {
final Authentication authentication = mavenSession
.getAuthenticationSelector()
.getAuthentication(remoteRepoBuilder.build());
remoteRepoBuilder.setAuthentication(authentication);
}
return remoteRepoBuilder.build();
}
示例5: ServerCredentials
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
* Public ctor.
* @param settings Maven settings
* @param name Name of server ID
* @throws MojoFailureException If some error
*/
protected ServerCredentials(@NotNull final Settings settings,
@NotNull final String name)
throws MojoFailureException {
final Server server = settings.getServer(name);
if (server == null) {
throw new MojoFailureException(
String.format("Server '%s' is absent in settings.xml", name)
);
}
this.key = server.getUsername().trim();
if (!this.key.matches("[A-Z0-9]{20}")) {
throw new MojoFailureException(
String.format(
"Key '%s' for server '%s' is not a valid AWS key",
this.key, name
)
);
}
this.secret = server.getPassword().trim();
if (!this.secret.matches("[a-zA-Z0-9\\+/]{40}")) {
throw new MojoFailureException(
String.format(
"Secret '%s' for server '%s' is not a valid AWS secret",
this.secret, name
)
);
}
Logger.info(
ServerCredentials.class,
"Using server '%s' with AWS key '%s'",
name, this.key
);
}
示例6: getServerSettings
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
public Server getServerSettings(String serverId) {
MavenSession mavenSession = getMavenSession();
Settings settings = mavenSession.getSettings();
Server server = settings.getServer(serverId);
return server;
}
示例7: getServer
import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
* Get server credential from Maven settings by server Id.
*
* @param settings Maven settings object.
* @param serverId Server Id.
* @return Server object if it exists in settings. Otherwise return null.
*/
public static Server getServer(final Settings settings, final String serverId) {
if (settings == null || StringUtils.isEmpty(serverId)) {
return null;
}
return settings.getServer(serverId);
}