use of org.sonatype.aether.repository.LocalMetadataResult in project sonatype-aether by sonatype.
the class TestLocalRepositoryManager method find.
public LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request) {
Metadata metadata = request.getMetadata();
LocalMetadataResult result = new LocalMetadataResult(request);
File file = new File(localRepository.getBasedir(), getPathForLocalMetadata(metadata));
result.setFile(file.isFile() ? file : null);
return result;
}
use of org.sonatype.aether.repository.LocalMetadataResult in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testFindLocalMetadata.
@Test
public void testFindLocalMetadata() throws Exception {
addMetadata(metadata, null);
LocalMetadataRequest request = new LocalMetadataRequest(metadata, null, testContext);
LocalMetadataResult result = manager.find(session, request);
assertNotNull(result.getFile());
}
use of org.sonatype.aether.repository.LocalMetadataResult in project sonatype-aether by sonatype.
the class DefaultMetadataResolver method getLocalFile.
private File getLocalFile(RepositorySystemSession session, Metadata metadata) {
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
LocalMetadataResult localResult = lrm.find(session, new LocalMetadataRequest(metadata, null, null));
File localFile = localResult.getFile();
return localFile;
}
use of org.sonatype.aether.repository.LocalMetadataResult in project sonatype-aether by sonatype.
the class DefaultArtifactResolverTest method testFindInLocalRepositoryWhenVersionRangeWasResolvedFromLocalRepository.
@Test
public void testFindInLocalRepositoryWhenVersionRangeWasResolvedFromLocalRepository() throws ArtifactResolutionException {
session.setLocalRepositoryManager(new LocalRepositoryManager() {
public LocalRepository getRepository() {
return null;
}
public String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context) {
return null;
}
public String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context) {
return null;
}
public String getPathForLocalMetadata(Metadata metadata) {
return null;
}
public String getPathForLocalArtifact(Artifact artifact) {
return null;
}
public LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request) {
LocalArtifactResult result = new LocalArtifactResult(request);
result.setAvailable(false);
try {
result.setFile(TestFileUtils.createTempFile(""));
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public void add(RepositorySystemSession session, LocalArtifactRegistration request) {
}
public LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request) {
LocalMetadataResult result = new LocalMetadataResult(request);
return result;
}
public void add(RepositorySystemSession session, LocalMetadataRegistration request) {
}
});
ArtifactRequest request = new ArtifactRequest(artifact, null, "");
resolver.setVersionResolver(new VersionResolver() {
public VersionResult resolveVersion(RepositorySystemSession session, VersionRequest request) throws VersionResolutionException {
return new VersionResult(request).setVersion(request.getArtifact().getVersion());
}
});
ArtifactResult result = resolver.resolveArtifact(session, request);
assertTrue(result.getExceptions().isEmpty());
Artifact resolved = result.getArtifact();
assertNotNull(resolved.getFile());
resolved = resolved.setFile(null);
assertEquals(artifact, resolved);
}
use of org.sonatype.aether.repository.LocalMetadataResult in project sonatype-aether by sonatype.
the class DefaultArtifactResolverTest method testFindInLocalRepositoryWhenVersionWasFoundInLocalRepository.
@Test
public void testFindInLocalRepositoryWhenVersionWasFoundInLocalRepository() throws ArtifactResolutionException {
session.setLocalRepositoryManager(new LocalRepositoryManager() {
public LocalRepository getRepository() {
return null;
}
public String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context) {
return null;
}
public String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context) {
return null;
}
public String getPathForLocalMetadata(Metadata metadata) {
return null;
}
public String getPathForLocalArtifact(Artifact artifact) {
return null;
}
public LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request) {
LocalArtifactResult result = new LocalArtifactResult(request);
result.setAvailable(false);
try {
result.setFile(TestFileUtils.createTempFile(""));
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public void add(RepositorySystemSession session, LocalArtifactRegistration request) {
}
public LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request) {
LocalMetadataResult result = new LocalMetadataResult(request);
return result;
}
public void add(RepositorySystemSession session, LocalMetadataRegistration request) {
}
});
ArtifactRequest request = new ArtifactRequest(artifact, null, "");
request.addRepository(new RemoteRepository("id", "default", "file:///"));
resolver.setVersionResolver(new VersionResolver() {
public VersionResult resolveVersion(RepositorySystemSession session, VersionRequest request) throws VersionResolutionException {
return new VersionResult(request).setRepository(new LocalRepository("id")).setVersion(request.getArtifact().getVersion());
}
});
ArtifactResult result = resolver.resolveArtifact(session, request);
assertTrue(result.getExceptions().isEmpty());
Artifact resolved = result.getArtifact();
assertNotNull(resolved.getFile());
resolved = resolved.setFile(null);
assertEquals(artifact, resolved);
}
Aggregations