use of org.eclipse.aether.repository.LocalRepositoryManager in project spring-boot by spring-projects.
the class GrapeRootRepositorySystemSessionAutoConfiguration method configureLocalRepository.
private void configureLocalRepository(DefaultRepositorySystemSession session, RepositorySystem repositorySystem, String grapeRoot) {
File repositoryDir = new File(grapeRoot, "repository");
LocalRepository localRepository = new LocalRepository(repositoryDir);
LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
session.setLocalRepositoryManager(localRepositoryManager);
}
use of org.eclipse.aether.repository.LocalRepositoryManager in project intellij-community by JetBrains.
the class Maven3ServerEmbedderImpl method resolveDependencies.
/**
* copied from {@link DefaultProjectBuilder#resolveDependencies(MavenProject, org.sonatype.aether.RepositorySystemSession)}
*/
private DependencyResolutionResult resolveDependencies(MavenProject project, RepositorySystemSession session) {
DependencyResolutionResult resolutionResult;
try {
ProjectDependenciesResolver dependencyResolver = getComponent(ProjectDependenciesResolver.class);
DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest(project, session);
resolutionResult = dependencyResolver.resolve(resolution);
} catch (DependencyResolutionException e) {
resolutionResult = e.getResult();
}
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
if (resolutionResult.getDependencyGraph() != null) {
RepositoryUtils.toArtifacts(artifacts, resolutionResult.getDependencyGraph().getChildren(), Collections.singletonList(project.getArtifact().getId()), null);
// Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
for (Artifact artifact : artifacts) {
if (!artifact.isResolved()) {
String path = lrm.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
}
}
}
project.setResolvedArtifacts(artifacts);
project.setArtifacts(artifacts);
return resolutionResult;
}
use of org.eclipse.aether.repository.LocalRepositoryManager in project intellij-community by JetBrains.
the class CustomMaven3ArtifactResolver method resolveOld.
private void resolveOld(Artifact artifact, List<ArtifactRepository> remoteRepositories, RepositorySystemSession session) throws ArtifactResolutionException, ArtifactNotFoundException {
if (artifact == null) {
return;
}
if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
File systemFile = artifact.getFile();
if (systemFile == null) {
throw new ArtifactNotFoundException("System artifact: " + artifact + " has no file attached", artifact);
}
if (!systemFile.exists()) {
throw new ArtifactNotFoundException("System artifact: " + artifact + " not found in path: " + systemFile, artifact);
}
if (!systemFile.isFile()) {
throw new ArtifactNotFoundException("System artifact: " + artifact + " is not a file: " + systemFile, artifact);
}
artifact.setResolved(true);
return;
}
if (!artifact.isResolved()) {
ArtifactResult result;
try {
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(RepositoryUtils.toArtifact(artifact));
artifactRequest.setRepositories(RepositoryUtils.toRepos(remoteRepositories));
// 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(artifactRequest.getArtifact());
artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
result = repoSystem.resolveArtifact(session, artifactRequest);
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
if (e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException) {
throw new ArtifactNotFoundException(e.getMessage(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), e);
} else {
throw new ArtifactResolutionException(e.getMessage(), artifact, remoteRepositories, e);
}
}
artifact.selectVersion(result.getArtifact().getVersion());
artifact.setFile(result.getArtifact().getFile());
artifact.setResolved(true);
if (artifact.isSnapshot()) {
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(artifact.getVersion());
if (matcher.matches()) {
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp(matcher.group(2));
try {
snapshot.setBuildNumber(Integer.parseInt(matcher.group(3)));
artifact.addMetadata(new SnapshotArtifactRepositoryMetadata(artifact, snapshot));
} catch (NumberFormatException e) {
logger.warn("Invalid artifact version " + artifact.getVersion() + ": " + e.getMessage());
}
}
}
}
}
Aggregations