1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.cloud.contract.maven.verifier.stubrunner;
18
19 import javax.inject.Inject;
20 import javax.inject.Named;
21 import javax.inject.Singleton;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.maven.project.MavenProject;
26 import org.eclipse.aether.RepositorySystem;
27 import org.eclipse.aether.RepositorySystemSession;
28 import shaded.org.apache.maven.settings.Settings;
29
30 import org.springframework.cloud.contract.stubrunner.AetherStubDownloader;
31 import org.springframework.cloud.contract.stubrunner.StubDownloader;
32 import org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder;
33 import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
34 import org.springframework.core.io.Resource;
35 import org.springframework.core.io.ResourceLoader;
36
37
38
39
40
41
42
43 @Named
44 @Singleton
45 public class AetherStubDownloaderFactory {
46
47 private static final Log log = LogFactory.getLog(AetherStubDownloaderFactory.class);
48
49 private final MavenProject project;
50
51 private final RepositorySystem repoSystem;
52
53 private final Settings settings;
54
55 @Inject
56 public AetherStubDownloaderFactory(RepositorySystem repoSystem, MavenProject project, Settings settings) {
57 this.repoSystem = repoSystem;
58 this.project = project;
59 this.settings = settings;
60 }
61
62 public StubDownloaderBuilder build(final RepositorySystemSession repoSession) {
63 return new StubDownloaderBuilder() {
64 @Override
65 public StubDownloader build(StubRunnerOptions stubRunnerOptions) {
66 log.info("Will download contracts using current build's Maven repository setup");
67 return new AetherStubDownloader(AetherStubDownloaderFactory.this.repoSystem,
68 AetherStubDownloaderFactory.this.project.getRemoteProjectRepositories(), repoSession,
69 AetherStubDownloaderFactory.this.settings);
70 }
71
72 @Override
73 public Resource resolve(String location, ResourceLoader resourceLoader) {
74 return null;
75 }
76 };
77 }
78
79 }