use of org.sonatype.aether.installation.InstallResult in project sonatype-aether by sonatype.
the class DefaultInstallerTest method testSuccessfulInstall.
@Test
public void testSuccessfulInstall() throws InstallationException, UnsupportedEncodingException, IOException {
File artifactFile = new File(session.getLocalRepositoryManager().getRepository().getBasedir(), localArtifactPath);
File metadataFile = new File(session.getLocalRepositoryManager().getRepository().getBasedir(), localMetadataPath);
artifactFile.delete();
metadataFile.delete();
request.addArtifact(artifact);
request.addMetadata(metadata);
InstallResult result = installer.install(session, request);
assertTrue(artifactFile.exists());
TestFileUtils.assertContent("artifact".getBytes("UTF-8"), artifactFile);
assertTrue(metadataFile.exists());
TestFileUtils.assertContent("metadata".getBytes("UTF-8"), metadataFile);
assertEquals(result.getRequest(), request);
assertEquals(result.getArtifacts().size(), 1);
assertTrue(result.getArtifacts().contains(artifact));
assertEquals(result.getMetadata().size(), 1);
assertTrue(result.getMetadata().contains(metadata));
assertEquals(1, lrm.getMetadataRegistration().size());
assertTrue(lrm.getMetadataRegistration().contains(metadata));
assertEquals(1, lrm.getArtifactRegistration().size());
assertTrue(lrm.getArtifactRegistration().contains(artifact));
}
use of org.sonatype.aether.installation.InstallResult in project sonatype-aether by sonatype.
the class DefaultInstaller method install.
private InstallResult install(SyncContext syncContext, RepositorySystemSession session, InstallRequest request) throws InstallationException {
InstallResult result = new InstallResult(request);
RequestTrace trace = DefaultRequestTrace.newChild(request.getTrace(), request);
List<MetadataGenerator> generators = getMetadataGenerators(session, request);
List<Artifact> artifacts = new ArrayList<Artifact>(request.getArtifacts());
IdentityHashMap<Metadata, Object> processedMetadata = new IdentityHashMap<Metadata, Object>();
List<Metadata> metadatas = Utils.prepareMetadata(generators, artifacts);
syncContext.acquire(artifacts, Utils.combine(request.getMetadata(), metadatas));
for (Metadata metadata : metadatas) {
install(session, trace, metadata);
processedMetadata.put(metadata, null);
result.addMetadata(metadata);
}
for (int i = 0; i < artifacts.size(); i++) {
Artifact artifact = artifacts.get(i);
for (MetadataGenerator generator : generators) {
artifact = generator.transformArtifact(artifact);
}
artifacts.set(i, artifact);
install(session, trace, artifact);
result.addArtifact(artifact);
}
metadatas = Utils.finishMetadata(generators, artifacts);
syncContext.acquire(null, metadatas);
for (Metadata metadata : metadatas) {
install(session, trace, metadata);
processedMetadata.put(metadata, null);
result.addMetadata(metadata);
}
for (Metadata metadata : request.getMetadata()) {
if (!processedMetadata.containsKey(metadata)) {
install(session, trace, metadata);
result.addMetadata(metadata);
}
}
return result;
}
Aggregations