本文整理汇总了Java中org.eclipse.aether.resolution.ArtifactDescriptorRequest类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactDescriptorRequest类的具体用法?Java ArtifactDescriptorRequest怎么用?Java ArtifactDescriptorRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactDescriptorRequest类属于org.eclipse.aether.resolution包,在下文中一共展示了ArtifactDescriptorRequest类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertDependencyUpdated
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private void assertDependencyUpdated(final Artifact artifact, final String targetProject,
final String expectedVersion, final String expectedBuildNumber) throws Exception {
final RepositorySystemSession session = newRepositorySystemSession();
final ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
final ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
Dependency targetDependency = null;
for (final Dependency dep : descriptorResult.getDependencies()) {
if (targetProject.equals(dep.getArtifact().getArtifactId())) {
targetDependency = dep;
break;
}
}
assertNotNull(format("No dependency found with artifact-id %s", targetProject), targetDependency);
assertEquals(format("%s%s", expectedVersion, expectedBuildNumber), targetDependency.getArtifact().getVersion());
}
示例2: resolveDependencies
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private Map<Artifact, Dependency> resolveDependencies(BomImport bom) throws Exception {
org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), "pom", bom.getVersion());
List<RemoteRepository> repositories = remoteRepositories;
if (bom.getRepository() != null) {
// Include the additional repository into the copy
repositories = new LinkedList<RemoteRepository>(repositories);
RemoteRepository repo = new RemoteRepository.Builder(bom.getArtifactId() + "-repository", "default", bom.getRepository()).build();
repositories.add(0, repo);
}
ArtifactRequest artifactRequest = new ArtifactRequest(artifact, repositories, null);
system.resolveArtifact(session, artifactRequest); // To get an error when the artifact does not exist
ArtifactDescriptorRequest req = new ArtifactDescriptorRequest(artifact, repositories, null);
ArtifactDescriptorResult res = system.readArtifactDescriptor(session, req);
Map<Artifact, Dependency> mavenDependencies = new LinkedHashMap<Artifact, Dependency>();
if (res.getManagedDependencies() != null) {
for (org.eclipse.aether.graph.Dependency dep : res.getManagedDependencies()) {
mavenDependencies.put(toMavenArtifact(dep), toMavenDependency(dep));
}
}
return mavenDependencies;
}
示例3: hasTransitiveSnapshots
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private boolean hasTransitiveSnapshots(Dependency dependency) throws MojoFailureException {
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(
new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()));
descriptorRequest.setRepositories(remoteRepos);
try {
ArtifactDescriptorResult result = repoSystem.readArtifactDescriptor(repoSession, descriptorRequest);
Optional<org.eclipse.aether.graph.Dependency> snapshotDependency = result.getDependencies().stream()
.filter(d -> d.getArtifact().isSnapshot())
.findFirst();
return snapshotDependency.isPresent();
} catch (ArtifactDescriptorException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
示例4: getDirectDependencies
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private ImmutableSet<ArtifactCoordinates> getDirectDependencies(Artifact artifact) throws RepositoryException {
ArtifactDescriptorRequest descriptorRequest =
new ArtifactDescriptorRequest(artifact, singletonList(mavenCentral), null);
return repositorySystem
.readArtifactDescriptor(repositorySystemSession, descriptorRequest)
.getDependencies().stream()
.filter(this::noTestDependency)
.map(Dependency::getArtifact)
.map(ArtifactCoordinates::from)
.collect(toImmutableSet());
}
示例5: getAllDependencies
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
public Set<Dependency> getAllDependencies(Artifact artifact) throws ArtifactDescriptorException {
ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(artifact, repositories, null);
ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);
Set<Dependency> dependencies = new HashSet<>(result.getManagedDependencies());
dependencies.addAll(result.getDependencies());
return dependencies;
}
示例6: getDependencies
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
public Collection<String> getDependencies(String moduleId, String version) throws ArtifactDescriptorException {
Artifact artifact = new DefaultArtifact(groupId, moduleId, "jar", version);
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
descriptorRequest.setRepositories(repos);
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
List<String> deps = Lists.newArrayList();
for (Dependency dep : descriptorResult.getDependencies()) {
deps.add(dep.getArtifact().getArtifactId());
}
return deps;
}
示例7: readArtifactDescriptor
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private ArtifactDescriptorResult readArtifactDescriptor(AddonId addonId) throws ArtifactDescriptorException
{
String coords = toMavenCoords(addonId);
RepositorySystem system = container.getRepositorySystem();
Settings settings = getSettings();
DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
request.setArtifact(new DefaultArtifact(coords));
request.setRepositories(repositories);
ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);
return result;
}
示例8: getDependenciesOf
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; //导入依赖的package包/类
private List<Dependency> getDependenciesOf(Artifact dep) throws ArtifactDescriptorException {
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(dep);
descriptorRequest.setRepositories(repos);
descriptorRequest.setRequestContext(JavaScopes.RUNTIME);
ArtifactDescriptorResult result = repoSys.readArtifactDescriptor(session, descriptorRequest);
return result.getDependencies();
}