diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java index 4ae1b71f67..b09f5a991d 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java @@ -43,6 +43,7 @@ import org.eclipse.equinox.internal.provisional.p2.repository.IStateful; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; @Component(role = org.eclipse.equinox.internal.p2.repository.Transport.class, hint = "tycho") public class TychoRepositoryTransport extends org.eclipse.equinox.internal.p2.repository.Transport @@ -85,46 +86,32 @@ public TychoRepositoryTransport() { } @Override - public IStatus download(URI toDownload, OutputStream target, long startPos, IProgressMonitor monitor) { - if (startPos > 0) { - return Status.error("range downloads are not implemented"); - } - return download(toDownload, target, monitor); - } - - @Override - public IStatus download(URI toDownload, OutputStream target, IProgressMonitor monitor) { + public IStatus downloadArtifact(URI source, OutputStream target, IArtifactDescriptor descriptor, + IProgressMonitor monitor) { String id = "p2"; // TODO we might compute the id from the IRepositoryIdManager based on the URI? if (cacheConfig.isInteractive()) { - logger.info("Downloading from " + id + ": " + toDownload); + logger.info("Downloading from " + id + ": " + source); } try { DownloadStatusOutputStream statusOutputStream = new DownloadStatusOutputStream(target, - "Download of " + toDownload); - stream(toDownload, monitor).transferTo(statusOutputStream); + "Download of " + source); + stream(source, monitor).transferTo(statusOutputStream); DownloadStatus downloadStatus = statusOutputStream.getStatus(); if (cacheConfig.isInteractive()) { - logger.info("Downloaded from " + id + ": " + toDownload + " (" + logger.info("Downloaded from " + id + ": " + source + " (" + FileUtils.byteCountToDisplaySize(downloadStatus.getFileSize()) + " at " + FileUtils.byteCountToDisplaySize(downloadStatus.getTransferRate()) + "/s)"); } return reportStatus(downloadStatus, target); } catch (AuthenticationFailedException e) { - return Status.error("authentication failed for " + toDownload, e); + return Status.error("authentication failed for " + source, e); } catch (IOException e) { - return reportStatus(Status.error("download from " + toDownload + " failed", e), target); + return reportStatus(Status.error("download from " + source + " failed", e), target); } catch (CoreException e) { return reportStatus(e.getStatus(), target); } } - private IStatus reportStatus(IStatus status, OutputStream target) { - if (target instanceof IStateful stateful) { - stateful.setStatus(status); - } - return status; - } - @Override public InputStream stream(URI toDownload, IProgressMonitor monitor) throws FileNotFoundException, CoreException, AuthenticationFailedException { @@ -168,6 +155,19 @@ public InputStream stream(URI toDownload, IProgressMonitor monitor) } } + @Override + public IStatus download(URI toDownload, OutputStream target, IProgressMonitor monitor) { + return downloadArtifact(toDownload, target, null, monitor); + } + + @Override + public IStatus download(URI toDownload, OutputStream target, long startPos, IProgressMonitor monitor) { + if (startPos > 0) { + return Status.error("range downloads are not implemented"); + } + return downloadArtifact(toDownload, target, null, monitor); + } + TransportProtocolHandler getHandler(URI uri) { String scheme = uri.getScheme(); if (scheme != null) { @@ -230,4 +230,11 @@ TransportCacheConfig getCacheConfig() { return cacheConfig; } + private static IStatus reportStatus(IStatus status, OutputStream target) { + if (target instanceof IStateful stateful) { + stateful.setStatus(status); + } + return status; + } + }