本文整理汇总了Java中org.eclipse.aether.resolution.DependencyResolutionException类的典型用法代码示例。如果您正苦于以下问题:Java DependencyResolutionException类的具体用法?Java DependencyResolutionException怎么用?Java DependencyResolutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DependencyResolutionException类属于org.eclipse.aether.resolution包,在下文中一共展示了DependencyResolutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCasesWithDependencies
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<PinpointPluginTestInstance> createCasesWithDependencies(PinpointPluginTestContext context) throws ArtifactResolutionException, DependencyResolutionException {
List<PinpointPluginTestInstance> cases = new ArrayList<PinpointPluginTestInstance>();
DependencyResolver resolver = DependencyResolver.get(repositories);
Map<String, List<Artifact>> dependencyCases = resolver.resolveDependencySets(dependencies);
for (Map.Entry<String, List<Artifact>> dependencyCase : dependencyCases.entrySet()) {
List<String> libs = new ArrayList<String>();
for (File lib : resolver.resolveArtifactsAndDependencies(dependencyCase.getValue())) {
libs.add(lib.getAbsolutePath());
}
if (testOnSystemClassLoader) {
cases.add(new NormalPluginTestCase(context, dependencyCase.getKey(), libs, true));
}
if (testOnChildClassLoader) {
cases.add(new NormalPluginTestCase(context, dependencyCase.getKey(), libs, false));
}
}
return cases;
}
示例2: resolveArtifacts
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
* Given a set of coordinates, resolves the transitive dependencies, and then returns the root
* node to the resolved dependency graph. The root node is a sentinel node with direct edges
* on the artifacts users declared explicit on.
*/
public DependencyNode resolveArtifacts(List<String> artifactCoords) {
List<Dependency> directDependencies = createDirectDependencyList(artifactCoords);
CollectRequest collectRequest =
aether.createCollectRequest(directDependencies, managedDependencies);
DependencyRequest dependencyRequest = aether.createDependencyRequest(collectRequest);
DependencyResult dependencyResult;
try {
dependencyResult = aether.requestDependencyResolution(dependencyRequest);
} catch (DependencyResolutionException e) {
//FIXME(petros): This is very fragile. If one artifact doesn't resolve, no artifacts resolve.
logger.warning("Unable to resolve transitive dependencies: " + e.getMessage());
return null;
}
// root is a sentinel node whose direct children are the requested artifacts.
return dependencyResult.getRoot();
}
示例3: resolveArtifacts
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private Stream<? extends Artifact> resolveArtifacts(String coordinator) {
log.debug("resolving {}", coordinator);
try {
// build resolve filters
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(new DefaultArtifact(coordinator), JavaScopes.COMPILE));
DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest,
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME)
);
// resolve
final List<Artifact> artifacts = teslaAether.resolveArtifacts(dependencyRequest);
if (CollectionUtils.isEmpty(artifacts)) {
throw new DependencyResolveException(String.format("cannot resolve %s", coordinator));
}
return artifacts.stream();
} catch (DependencyResolutionException e) {
final String message = String.format("cannot resolve %s : %s", coordinator, e.getLocalizedMessage());
throw new DependencyResolveException(message, e);
}
}
示例4: getAllDependencies
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private ImmutableSet<ArtifactCoordinates> getAllDependencies(Artifact artifact, String scope)
throws DependencyCollectionException, DependencyResolutionException {
Dependency artifactAsDependency = new Dependency(artifact, scope);
CollectRequest collectRequest = new CollectRequest(artifactAsDependency, singletonList(mavenCentral));
DependencyNode dependencyRoot =
repositorySystem.collectDependencies(repositorySystemSession, collectRequest).getRoot();
DependencyRequest dependencyRequest = new DependencyRequest(dependencyRoot, null);
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
PreorderNodeListGenerator dependencies = new PreorderNodeListGenerator();
dependencyRoot.getChildren().forEach(node -> node.accept(dependencies));
ImmutableSet.Builder<ArtifactCoordinates> dependencyCoordinates = ImmutableSet.builder();
dependencies.getArtifacts(true).stream().map(ArtifactCoordinates::from).forEach(dependencyCoordinates::add);
return dependencyCoordinates.build();
}
示例5: resolveDependencies
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<Artifact> resolveDependencies(final Artifact artifact) throws DependencyResolutionException {
List<Artifact> result = new ArrayList<Artifact>();
RepositorySystem system = newRepositorySystem();
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.eclipse.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
List<ArtifactResult> dependenciesTree = system.resolveDependencies(
session,
new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE))
).getArtifactResults();
for (final ArtifactResult res : dependenciesTree) {
result.add(res.getArtifact());
}
return result;
}
示例6: resolve
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
* Resolves all dependencies for the external metrics
*/
public void resolve(){
RepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository("/tmp/luzzu/local-repo");
((DefaultRepositorySystemSession) session).setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
try {
List<POMDependency> dep = getPOMDependencies(pomFileName);
for(POMDependency d : dep) installDependency(d.groupId, d.artifactId, d.version, session);
} catch (ParserConfigurationException | SAXException | IOException | DependencyResolutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: AbstractPinpointPluginTestSuite
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
public AbstractPinpointPluginTestSuite(Class<?> testClass) throws InitializationError, ArtifactResolutionException, DependencyResolutionException {
super(testClass, Collections.<Runner> emptyList());
PinpointAgent agent = testClass.getAnnotation(PinpointAgent.class);
this.agentJar = resolveAgentPath(agent);
PinpointConfig config = testClass.getAnnotation(PinpointConfig.class);
this.configFile = config == null ? null : resolveConfigFileLocation(config.value());
JvmArgument jvmArgument = testClass.getAnnotation(JvmArgument.class);
this.jvmArguments = jvmArgument == null ? new String[0] : jvmArgument.value();
JvmVersion jvmVersion = testClass.getAnnotation(JvmVersion.class);
this.jvmVersions = jvmVersion == null ? new int[] { NO_JVM_VERSION } : jvmVersion.value();
this.requiredLibraries = resolveRequiredLibraries();
this.testClassLocation = resolveTestClassLocation(testClass);
this.debug = isDebugMode();
}
示例8: resolveArtifactsAndDependencies
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
public List<File> resolveArtifactsAndDependencies(List<Artifact> artifacts) throws ArtifactResolutionException, DependencyResolutionException {
List<Dependency> dependencies = new ArrayList<Dependency>();
for (Artifact artifact : artifacts) {
dependencies.add(new Dependency(artifact, JavaScopes.RUNTIME));
}
CollectRequest collectRequest = new CollectRequest((Dependency)null, dependencies, repositories);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
DependencyResult result = system.resolveDependencies(session, dependencyRequest);
List<File> files = new ArrayList<File>();
for (ArtifactResult artifactResult : result.getArtifactResults()) {
files.add(artifactResult.getArtifact().getFile());
}
return files;
}
示例9: copyDependencies
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private Set<String> copyDependencies(File destination) throws DependencyResolutionException, IOException {
Set<String> artifactNames = new HashSet<String>();
for (Dependency dependency : project.getDependencies()) {
if (!excludedScopes().contains(dependency.getScope())) {
String depString = dependency.getGroupId() + ":" + dependency.getArtifactId()
+ ":" + dependency.getVersion();
CollectRequest request = new CollectRequest(
new org.eclipse.aether.graph.Dependency(
new DefaultArtifact(depString), dependency.getScope()), projectRepos);
DependencyResult result = repoSystem.resolveDependencies(
repoSession,
new DependencyRequest(request, new ScopeDependencyFilter(null, excludedScopes())));
for (ArtifactResult artifactResult : result.getArtifactResults()) {
File artifactFile = artifactResult.getArtifact().getFile();
File codeFile = new File(destination, artifactFile.getName());
FileUtils.copyFile(artifactFile, codeFile);
artifactNames.add(artifactFile.getName());
}
}
}
return artifactNames;
}
示例10: getArtifacts
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
public List<Artifact> getArtifacts(DependencyFilter transitiveFilter)
throws DependencyCollectionException, DependencyResolutionException {
CollectRequest request = new CollectRequest(dependency, remoteRepos);
DependencyRequest dependencyRequest = new DependencyRequest(request,
transitiveFilter);
DependencyResult dependencyResult = repoSystem.resolveDependencies(
repoSession, dependencyRequest);
List<ArtifactResult> artifactResults = dependencyResult
.getArtifactResults();
List<Artifact> artifacts = new ArrayList<Artifact>();
for (ArtifactResult artifactResult : artifactResults) {
Artifact artifact = artifactResult.getArtifact();
artifacts.add(artifact);
}
return artifacts;
}
示例11: getClasspath
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
public String getClasspath(DependencyFilter transitiveFilter)
throws DependencyCollectionException, DependencyResolutionException {
List<Artifact> artifacts = getArtifacts(transitiveFilter);
Iterator<Artifact> artifactIterator = artifacts.iterator();
StringBuilder classpathBuilder = new StringBuilder();
while (artifactIterator.hasNext()) {
Artifact artifact = artifactIterator.next();
File file = artifact.getFile();
classpathBuilder.append(file.toString());
if (artifactIterator.hasNext()) {
classpathBuilder.append(File.pathSeparatorChar);
}
}
return classpathBuilder.toString();
}
示例12: downloadDependencyTree
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
* Resolves and downloads an artifact with its dependencies.
*
* @param artifact
* artifact to resolve
* @param javadoc
* <code>true</code> if javadoc attachment should be retrieved too
* @param sources
* <code>true</code> if sources attachment should be retrieved too
* @throws DependencyCollectionException
* if the dependency graph could not be properly assembled
* @throws DependencyResolutionException
* if a dependency is not resolvable
*/
public void downloadDependencyTree(DefaultArtifact artifact, boolean javadoc, boolean sources)
throws DependencyCollectionException, DependencyResolutionException {
log.info("Resolving: {} with these dependencies ...", artifact.toString());
Dependency dependency = new Dependency(artifact, JavaScopes.COMPILE);
DependencyNode jarNode = repoSystemHelper.collectDependencies(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.TEST);
jarNode.accept(new TreeDependencyVisitor(new FilteringDependencyVisitor(new DependencyGraphPrinter(), classpathFilter)));
DependencyRequest dependencyRequest = new DependencyRequest(jarNode, classpathFilter);
DependencyResult dependencyResult = repoSystemHelper.resolveDependencies(dependencyRequest);
if (javadoc) {
downloadAttachments(dependencyResult, "javadoc");
}
if (sources) {
downloadAttachments(dependencyResult, "sources");
}
}
示例13: downloadAttachments
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
/**
* Downloads additional artifacts like javadoc or sources.
*
* @param depResult
* a set of resolved dependencies
* @param attachment
* type of attachment. Either "javadoc" or "sources"
* @throws DependencyCollectionException
*/
private void downloadAttachments(DependencyResult depResult, final String attachment) throws DependencyCollectionException {
for (ArtifactResult artifactResult : depResult.getArtifactResults()) {
final Artifact artifact = artifactResult.getArtifact();
final String artifactId = artifact.getArtifactId();
final String groupId = artifact.getGroupId();
final String extension = artifact.getExtension();
final String version = artifact.getVersion();
log.info("Resolving {} for {}", attachment, artifact);
try {
DefaultArtifact extraArtifact = new DefaultArtifact(groupId, artifactId, attachment, extension, version);
Dependency attachedDependency = new Dependency(extraArtifact, JavaScopes.COMPILE);
DependencyNode attachmentNode = repoSystemHelper.collectDependencies(attachedDependency);
DependencyRequest javadocDependencyRequest = new DependencyRequest(attachmentNode, null);
repoSystemHelper.resolveDependencies(javadocDependencyRequest);
} catch (DependencyResolutionException de) {
log.warn("No {} found for {}", attachment, artifact);
}
}
}
示例14: validateBomDependency
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private void validateBomDependency(ValidatorContext ctx, Model bom, Dependency bomDependency, Dependency dependency) {
CollectRequest collectRequest = new CollectRequest(
bomDependency,
Collections.singletonList(dependency),
ctx.getRemoteRepositories());
DependencyRequest dependencyRequest = new DependencyRequest(
collectRequest,
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
try {
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
} catch (DependencyResolutionException e) {
ArtifactResolutionException are = findCause(e, ArtifactResolutionException.class);
if( are == null ) {
ctx.addError(this, bom.getPomFile(), e);
} else {
DependencyNode dependencyNode = e.getResult().getRoot();
Artifact validatedArtifact = new DefaultArtifact(bom.getGroupId(), bom.getArtifactId(), bom.getPackaging(), bom.getVersion());
for (Artifact missingArtifact : Utils.collectMissingArtifacts(are)) {
ctx.addError(this, bom.getPomFile(), new BomDependencyNotFoundException(e, missingArtifact, validatedArtifact, dependencyNode));
}
}
}
}
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:26,代码来源:BomDependencyNotFoundValidator.java
示例15: resolveAsDependencyNode
import org.eclipse.aether.resolution.DependencyResolutionException; //导入依赖的package包/类
private List<DependencyNode> resolveAsDependencyNode(final Artifact artifact) throws DependencyCollectionException, DependencyResolutionException {
final CollectResult collect_result = collectDependencies(artifact, repositories);
final DependencyNode root_dependency = collect_result.getRoot();
final DependencyRequest dep_request = new DependencyRequest();
final DependencyNodeCollector node_collector = new DependencyNodeCollector();
dep_request.setRoot(root_dependency);
REPOSITORY_SYSTEM.resolveDependencies(session, dep_request);
root_dependency.accept(node_collector);
return node_collector.nodes;
}