Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolver updates #1495

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public LocalRepository getLocalRepository() {
public Session withLocalRepository(@Nonnull LocalRepository localRepository) {
nonNull(localRepository, "localRepository");
if (session.getLocalRepository() != null
&& Objects.equals(session.getLocalRepository().getBasedir().toPath(), localRepository.getPath())) {
&& Objects.equals(session.getLocalRepository().getBasePath(), localRepository.getPath())) {
return this;
}
org.eclipse.aether.repository.LocalRepository repository = toRepository(localRepository);
Expand Down Expand Up @@ -293,13 +293,10 @@ public List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifac

@Override
public org.eclipse.aether.artifact.Artifact toArtifact(Artifact artifact) {
File file = getService(ArtifactManager.class)
.getPath(artifact)
.map(Path::toFile)
.orElse(null);
Path path = getService(ArtifactManager.class).getPath(artifact).orElse(null);
if (artifact instanceof DefaultArtifact) {
org.eclipse.aether.artifact.Artifact a = ((DefaultArtifact) artifact).getArtifact();
if (Objects.equals(file, a.getFile())) {
if (Objects.equals(path, a.getPath())) {
return a;
}
}
Expand All @@ -310,7 +307,7 @@ public org.eclipse.aether.artifact.Artifact toArtifact(Artifact artifact) {
artifact.getExtension(),
artifact.getVersion().toString(),
null,
file);
path);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public ArtifactResolverResult resolve(ArtifactResolverRequest request)
session.getRepositorySystem().resolveArtifacts(session.getSession(), requests);
for (ArtifactResult result : results) {
Artifact artifact = session.getArtifact(result.getArtifact());
Path path = result.getArtifact().getFile().toPath();
Path path = result.getArtifact().getPath();
artifactManager.setPath(artifact, path);
paths.put(artifact, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public String getType() {
@Nonnull
@Override
public Path getPath() {
return repository.getBasedir().toPath();
return repository.getBasePath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private org.eclipse.aether.repository.LocalRepositoryManager getManager(
InternalSession session, LocalRepository local) {
org.eclipse.aether.repository.LocalRepository repository = session.toRepository(local);
if ("enhanced".equals(repository.getContentType())) {
repository = new org.eclipse.aether.repository.LocalRepository(repository.getBasedir(), "");
repository = new org.eclipse.aether.repository.LocalRepository(repository.getBasePath(), "");
}
return session.getRepositorySystem().newLocalRepositoryManager(session.getSession(), repository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class DefaultRepositoryFactory implements RepositoryFactory {

@Override
public LocalRepository createLocal(Path path) {
return new DefaultLocalRepository(new org.eclipse.aether.repository.LocalRepository(path.toFile()));
return new DefaultLocalRepository(new org.eclipse.aether.repository.LocalRepository(path));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean get(URI relativeSource, Path target) {
throw new IllegalArgumentException("Supplied relative URI escapes baseUrl");
}
GetTask getTask = new GetTask(source);
getTask.setDataFile(target.toFile());
getTask.setDataPath(target);
try {
transporter.get(getTask);
return true;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void put(Path source, URI relativeTarget) {
}

PutTask putTask = new PutTask(target);
putTask.setDataFile(source.toFile());
putTask.setDataPath(source);
try {
transporter.put(putTask);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public Path getPath() {
return path;
}

@Deprecated
public void merge(File existing, File result) throws RepositoryException {
merge(existing != null ? existing.toPath() : null, result != null ? result.toPath() : null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
import org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector;
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;

Expand Down Expand Up @@ -98,7 +98,7 @@ protected DependencySelector getDependencySelector() {
protected DependencyGraphTransformer getDependencyGraphTransformer() {
return new ChainedDependencyGraphTransformer(
new ConflictResolver(
new NearestVersionSelector(), new ManagedScopeSelector(getScopeManager()),
new ConfigurableVersionSelector(), new ManagedScopeSelector(getScopeManager()),
new SimpleOptionalitySelector(), new ManagedScopeDeriver(getScopeManager())),
new ManagedDependencyContextRefiner(getScopeManager()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void installIntoProjectLocalRepository(Artifact artifact) {
LOGGER.info("Copying {} to project local repository", artifact);
Files.createDirectories(target.getParent());
Files.copy(
artifact.getFile().toPath(),
artifact.getPath(),
target,
StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.COPY_ATTRIBUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import javax.inject.Inject;
import javax.inject.Named;

import java.io.File;
import java.nio.file.Path;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -67,10 +66,7 @@ public Optional<Path> getPath(@Nonnull Artifact artifact) {
}
Path path = paths.get(id);
if (path == null && artifact instanceof DefaultArtifact) {
File file = ((DefaultArtifact) artifact).getArtifact().getFile();
if (file != null) {
path = file.toPath();
}
path = ((DefaultArtifact) artifact).getArtifact().getPath();
}
return Optional.ofNullable(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void get(
for (ArtifactDownload download : artifactDownloads) {
File remoteFile = new File(basedir, path(download.getArtifact()));
try {
Path dest = download.getFile().toPath();
Path dest = download.getPath();
Files.createDirectories(dest.getParent());
Files.copy(remoteFile.toPath(), dest);
} catch (IOException e) {
Expand All @@ -91,7 +91,7 @@ public void get(
for (final MetadataDownload download : metadataDownloads) {
File remoteFile = new File(basedir, path(download.getMetadata()));
try {
Path dest = download.getFile().toPath();
Path dest = download.getPath();
Files.createDirectories(dest.getParent());
Files.copy(remoteFile.toPath(), dest);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ private org.apache.maven.api.model.Model doReadFileModel(
}

if (modelSource instanceof FileModelSource) {
model = model.withPomFile(((FileModelSource) modelSource).getFile().toPath());
model = model.withPomFile(((FileModelSource) modelSource).getPath());
}

Model retModel = new Model(model);
Expand Down