|
|
37b8c33 |
--- src/main/java/io/tesla/aether/connector/AetherRepositoryConnector.java.orig 2014-05-01 02:41:07.000000000 +0100
|
|
|
37b8c33 |
+++ src/main/java/io/tesla/aether/connector/AetherRepositoryConnector.java 2014-05-24 16:17:15.050666912 +0100
|
|
|
37b8c33 |
@@ -57,6 +57,7 @@
|
|
|
37b8c33 |
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
|
|
37b8c33 |
import org.eclipse.aether.ConfigurationProperties;
|
|
|
37b8c33 |
import org.eclipse.aether.RepositorySystemSession;
|
|
|
37b8c33 |
+import org.eclipse.aether.impl.DefaultServiceLocator;
|
|
|
37b8c33 |
import org.eclipse.aether.repository.AuthenticationContext;
|
|
|
37b8c33 |
import org.eclipse.aether.repository.RemoteRepository;
|
|
|
37b8c33 |
import org.eclipse.aether.repository.RepositoryPolicy;
|
|
|
37b8c33 |
@@ -68,7 +69,10 @@
|
|
|
37b8c33 |
import org.eclipse.aether.spi.connector.MetadataUpload;
|
|
|
37b8c33 |
import org.eclipse.aether.spi.connector.RepositoryConnector;
|
|
|
37b8c33 |
import org.eclipse.aether.spi.connector.Transfer;
|
|
|
37b8c33 |
+import org.eclipse.aether.spi.connector.layout.RepositoryLayout;
|
|
|
37b8c33 |
+import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
|
|
|
37b8c33 |
import org.eclipse.aether.spi.io.FileProcessor;
|
|
|
37b8c33 |
+import org.eclipse.aether.spi.locator.ServiceLocator;
|
|
|
37b8c33 |
//import org.eclipse.aether.spi.log.Logger;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.ArtifactNotFoundException;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.ArtifactTransferException;
|
|
|
37b8c33 |
@@ -76,6 +80,7 @@
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.MetadataNotFoundException;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.MetadataTransferException;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.NoRepositoryConnectorException;
|
|
|
37b8c33 |
+import org.eclipse.aether.transfer.NoRepositoryLayoutException;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.TransferCancelledException;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.TransferEvent;
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.TransferEvent.EventType;
|
|
|
37b8c33 |
@@ -84,8 +89,6 @@
|
|
|
37b8c33 |
import org.eclipse.aether.transfer.TransferResource;
|
|
|
37b8c33 |
import org.eclipse.aether.util.ChecksumUtils;
|
|
|
37b8c33 |
import org.eclipse.aether.util.ConfigUtils;
|
|
|
37b8c33 |
-import org.eclipse.aether.util.repository.layout.MavenDefaultLayout;
|
|
|
37b8c33 |
-import org.eclipse.aether.util.repository.layout.RepositoryLayout;
|
|
|
37b8c33 |
import org.slf4j.Logger;
|
|
|
37b8c33 |
import org.slf4j.LoggerFactory;
|
|
|
37b8c33 |
|
|
|
37b8c33 |
@@ -95,8 +98,10 @@
|
|
|
37b8c33 |
class AetherRepositoryConnector implements RepositoryConnector {
|
|
|
37b8c33 |
|
|
|
37b8c33 |
private final Logger logger = LoggerFactory.getLogger(AetherRepositoryConnector.class);
|
|
|
37b8c33 |
+
|
|
|
37b8c33 |
+ private final ServiceLocator serviceLocator = new DefaultServiceLocator();
|
|
|
37b8c33 |
|
|
|
37b8c33 |
- private final RepositoryLayout layout = new MavenDefaultLayout();
|
|
|
37b8c33 |
+ private final RepositoryLayout layout;
|
|
|
37b8c33 |
private final TransferListener listener;
|
|
|
37b8c33 |
private final RepositorySystemSession session;
|
|
|
37b8c33 |
private final AuthenticationContext repoAuthenticationContext;
|
|
|
37b8c33 |
@@ -165,7 +170,7 @@
|
|
|
37b8c33 |
this(repository, session, fileProcessor, null);
|
|
|
37b8c33 |
}
|
|
|
37b8c33 |
|
|
|
37b8c33 |
- public AetherRepositoryConnector(RemoteRepository repository, RepositorySystemSession session, FileProcessor fileProcessor, SSLSocketFactory sslSocketFactory) throws NoRepositoryConnectorException {
|
|
|
37b8c33 |
+ public AetherRepositoryConnector(RemoteRepository repository, RepositorySystemSession session, FileProcessor fileProcessor, SSLSocketFactory sslSocketFactory) throws NoRepositoryConnectorException {
|
|
|
37b8c33 |
//
|
|
|
37b8c33 |
// Right now this only support a Maven layout which is what we mean by type
|
|
|
37b8c33 |
//
|
|
|
37b8c33 |
@@ -183,6 +188,13 @@
|
|
|
37b8c33 |
this.fileProcessor = fileProcessor;
|
|
|
37b8c33 |
this.session = session;
|
|
|
37b8c33 |
|
|
|
37b8c33 |
+ RepositoryLayoutProvider repositoryLayoutProvider = serviceLocator.getService(RepositoryLayoutProvider.class);
|
|
|
37b8c33 |
+ try {
|
|
|
37b8c33 |
+ this.layout = repositoryLayoutProvider.newRepositoryLayout(session, repository);
|
|
|
37b8c33 |
+ } catch (NoRepositoryLayoutException e) {
|
|
|
37b8c33 |
+ throw new RuntimeException(e);
|
|
|
37b8c33 |
+ }
|
|
|
37b8c33 |
+
|
|
|
37b8c33 |
AetherClientConfig config = new AetherClientConfig();
|
|
|
37b8c33 |
|
|
|
37b8c33 |
repoAuthenticationContext = AuthenticationContext.forRepository(session, repository);
|
|
|
37b8c33 |
@@ -284,14 +296,14 @@
|
|
|
37b8c33 |
Collection<GetTask<?>> tasks = new ArrayList<GetTask<?>>();
|
|
|
37b8c33 |
|
|
|
37b8c33 |
for (MetadataDownload download : metadataDownloads) {
|
|
|
37b8c33 |
- String resource = layout.getPath(download.getMetadata()).getPath();
|
|
|
37b8c33 |
+ String resource = layout.getLocation(download.getMetadata(), false).getPath();
|
|
|
37b8c33 |
GetTask task = new GetTask<MetadataTransfer>(resource, download.getFile(), download.getChecksumPolicy(), latch, download, METADATA);
|
|
|
37b8c33 |
tasks.add(task);
|
|
|
37b8c33 |
task.run();
|
|
|
37b8c33 |
}
|
|
|
37b8c33 |
|
|
|
37b8c33 |
for (ArtifactDownload download : artifactDownloads) {
|
|
|
37b8c33 |
- String resource = layout.getPath(download.getArtifact()).getPath();
|
|
|
37b8c33 |
+ String resource = layout.getLocation(download.getArtifact(), false).getPath();
|
|
|
37b8c33 |
GetTask task = new GetTask<ArtifactTransfer>(resource, download.isExistenceCheck() ? null : download.getFile(), download.getChecksumPolicy(), latch, download, ARTIFACT);
|
|
|
37b8c33 |
tasks.add(task);
|
|
|
37b8c33 |
task.run();
|
|
|
37b8c33 |
@@ -324,14 +336,14 @@
|
|
|
37b8c33 |
Collection<PutTask<?>> tasks = new ArrayList<PutTask<?>>();
|
|
|
37b8c33 |
|
|
|
37b8c33 |
for (ArtifactUpload upload : artifactUploads) {
|
|
|
37b8c33 |
- String path = layout.getPath(upload.getArtifact()).getPath();
|
|
|
37b8c33 |
+ String path = layout.getLocation(upload.getArtifact(), true).getPath();
|
|
|
37b8c33 |
PutTask task = new PutTask<ArtifactTransfer>(path, upload.getFile(), latch, upload, ARTIFACT);
|
|
|
37b8c33 |
tasks.add(task);
|
|
|
37b8c33 |
task.run();
|
|
|
37b8c33 |
}
|
|
|
37b8c33 |
|
|
|
37b8c33 |
for (MetadataUpload upload : metadataUploads) {
|
|
|
37b8c33 |
- String path = layout.getPath(upload.getMetadata()).getPath();
|
|
|
37b8c33 |
+ String path = layout.getLocation(upload.getMetadata(), true).getPath();
|
|
|
37b8c33 |
PutTask task = new PutTask<MetadataTransfer>(path, upload.getFile(), latch, upload, METADATA);
|
|
|
37b8c33 |
tasks.add(task);
|
|
|
37b8c33 |
task.run();
|
|
|
37b8c33 |
@@ -413,7 +425,6 @@
|
|
|
37b8c33 |
|
|
|
37b8c33 |
public void run() {
|
|
|
37b8c33 |
|
|
|
37b8c33 |
- download.setState(Transfer.State.ACTIVE);
|
|
|
37b8c33 |
String uri = buildUrl(path);
|
|
|
37b8c33 |
TransferResource transferResource = new TransferResource(repository.getUrl(), path, fileInLocalRepository, download.getTrace());
|
|
|
37b8c33 |
|
|
|
37b8c33 |
@@ -682,7 +693,6 @@
|
|
|
37b8c33 |
|
|
|
37b8c33 |
public void flush() {
|
|
|
37b8c33 |
wrapper.wrap(download, exception, repository);
|
|
|
37b8c33 |
- download.setState(Transfer.State.DONE);
|
|
|
37b8c33 |
}
|
|
|
37b8c33 |
|
|
|
37b8c33 |
private void rename(File from, File to) throws IOException {
|
|
|
37b8c33 |
@@ -713,7 +723,6 @@
|
|
|
37b8c33 |
|
|
|
37b8c33 |
public void run() {
|
|
|
37b8c33 |
|
|
|
37b8c33 |
- upload.setState(Transfer.State.ACTIVE);
|
|
|
37b8c33 |
final TransferResource transferResource = new TransferResource(repository.getUrl(), path, file, upload.getTrace());
|
|
|
37b8c33 |
|
|
|
37b8c33 |
try {
|
|
|
37b8c33 |
@@ -762,7 +771,6 @@
|
|
|
37b8c33 |
|
|
|
37b8c33 |
public void flush() {
|
|
|
37b8c33 |
wrapper.wrap(upload, exception, repository);
|
|
|
37b8c33 |
- upload.setState(Transfer.State.DONE);
|
|
|
37b8c33 |
}
|
|
|
37b8c33 |
|
|
|
37b8c33 |
private void uploadChecksums(File file, String uri) {
|