use of org.sonatype.aether.installation.InstallationException in project sonatype-aether by sonatype.
the class DefaultInstaller method install.
private void install(RepositorySystemSession session, RequestTrace trace, Artifact artifact) throws InstallationException {
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
File srcFile = artifact.getFile();
File dstFile = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact(artifact));
artifactInstalling(session, trace, artifact, dstFile);
Exception exception = null;
try {
boolean copy = "pom".equals(artifact.getExtension()) || srcFile.lastModified() != dstFile.lastModified() || srcFile.length() != dstFile.length();
if (copy) {
fileProcessor.copy(srcFile, dstFile, null);
dstFile.setLastModified(srcFile.lastModified());
} else {
logger.debug("Skipped re-installing " + srcFile + " to " + dstFile + ", seems unchanged");
}
lrm.add(session, new LocalArtifactRegistration(artifact));
} catch (Exception e) {
exception = e;
throw new InstallationException("Failed to install artifact " + artifact + ": " + e.getMessage(), e);
} finally {
artifactInstalled(session, trace, artifact, dstFile, exception);
}
}
use of org.sonatype.aether.installation.InstallationException in project sonatype-aether by sonatype.
the class DefaultInstaller method install.
private void install(RepositorySystemSession session, RequestTrace trace, Metadata metadata) throws InstallationException {
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
File dstFile = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalMetadata(metadata));
metadataInstalling(session, trace, metadata, dstFile);
Exception exception = null;
try {
if (metadata instanceof MergeableMetadata) {
((MergeableMetadata) metadata).merge(dstFile, dstFile);
} else {
fileProcessor.copy(metadata.getFile(), dstFile, null);
}
lrm.add(session, new LocalMetadataRegistration(metadata));
} catch (Exception e) {
exception = e;
throw new InstallationException("Failed to install metadata " + metadata + ": " + e.getMessage(), e);
} finally {
metadataInstalled(session, trace, metadata, dstFile, exception);
}
}
use of org.sonatype.aether.installation.InstallationException in project sonatype-aether by sonatype.
the class DefaultInstallerTest method checkFailedEvents.
private void checkFailedEvents(String msg, Artifact artifact) {
InstallRequest request = new InstallRequest().addArtifact(artifact);
msg = "Repository events problem (case: " + msg + ")";
try {
installer.install(session, request);
fail("expected exception");
} catch (InstallationException e) {
checkEvents(msg, artifact, true);
}
}
use of org.sonatype.aether.installation.InstallationException in project sonatype-aether by sonatype.
the class DefaultInstallerTest method checkFailedEvents.
private void checkFailedEvents(String msg, Metadata metadata) {
InstallRequest request = new InstallRequest().addMetadata(metadata);
msg = "Repository events problem (case: " + msg + ")";
try {
installer.install(session, request);
fail("expected exception");
} catch (InstallationException e) {
checkEvents(msg, metadata, true);
}
}
Aggregations