use of org.eclipse.aether.repository.LocalRepositoryManager in project sts4 by spring-projects.
the class MavenCore method resolveDependencies.
/**
* Calculates dependency graph for a Maven project provided the scope.
*
* @param project Maven Project descriptor
* @param scope Dependency scope
* @return Set of all dependencies including transient ones
* @throws MavenException
*/
public Set<Artifact> resolveDependencies(MavenProject project, String scope) throws MavenException {
MavenExecutionRequest request = maven.createExecutionRequest();
DefaultRepositorySystemSession session = maven.createRepositorySession(request);
DependencyNode graph = readDependencyTree(maven.lookupComponent(org.eclipse.aether.RepositorySystem.class), session, project, scope);
if (graph != null) {
ArrayList<DependencyNode> dependencyNodes = new ArrayList<>();
graph.accept(new DependencyVisitor() {
public boolean visitEnter(DependencyNode node) {
if (node.getDependency() != null) {
dependencyNodes.add(node);
}
return true;
}
public boolean visitLeave(DependencyNode dependencynode) {
return true;
}
});
LinkedHashSet<Artifact> artifacts = new LinkedHashSet<>();
RepositoryUtils.toArtifacts(artifacts, dependencyNodes, Collections.singletonList(project.getArtifact().getId()), null);
return artifacts.parallelStream().map(artifact -> {
if (!artifact.isResolved()) {
try {
artifact = maven.resolve(artifact, project.getRemoteArtifactRepositories(), request);
} catch (MavenException e) {
Log.log(e);
// Maven 2.x quirk: an artifact always points at the local repo,
// regardless whether resolved or not
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
String path = lrm.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
}
}
return artifact;
}).collect(Collectors.toSet());
}
return Collections.emptySet();
}
use of org.eclipse.aether.repository.LocalRepositoryManager in project sts4 by spring-projects.
the class MavenCore method localRepositoryFolder.
public File localRepositoryFolder() throws MavenException {
MavenExecutionRequest request = maven.createExecutionRequest();
DefaultRepositorySystemSession session = maven.createRepositorySession(request);
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
return lrm.getRepository().getBasedir();
}
use of org.eclipse.aether.repository.LocalRepositoryManager in project frontend-maven-plugin by eirslett.
the class RepositoryCacheResolver method resolve.
@Override
public File resolve(CacheDescriptor cacheDescriptor) {
LocalRepositoryManager manager = repositorySystemSession.getLocalRepositoryManager();
File localArtifact = new File(manager.getRepository().getBasedir(), manager.getPathForLocalArtifact(createArtifact(cacheDescriptor)));
return localArtifact;
}
Aggregations