1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.repository;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.apache.maven.execution.MavenSession;
25 import org.apache.maven.project.MavenProject;
26
27
28
29
30
31 public class DefaultRepositoryRequest implements RepositoryRequest {
32
33 private boolean offline;
34
35 private boolean forceUpdate;
36
37 private ArtifactRepository localRepository;
38
39 private List<ArtifactRepository> remoteRepositories;
40
41
42
43
44 public DefaultRepositoryRequest() {
45
46 }
47
48
49
50
51
52
53 public DefaultRepositoryRequest(RepositoryRequest repositoryRequest) {
54 setLocalRepository(repositoryRequest.getLocalRepository());
55 setRemoteRepositories(repositoryRequest.getRemoteRepositories());
56 setOffline(repositoryRequest.isOffline());
57 setForceUpdate(repositoryRequest.isForceUpdate());
58 }
59
60 public static RepositoryRequest getRepositoryRequest(MavenSession session, MavenProject project) {
61 RepositoryRequest request = new DefaultRepositoryRequest();
62
63 request.setLocalRepository(session.getLocalRepository());
64 if (project != null) {
65 request.setRemoteRepositories(project.getPluginArtifactRepositories());
66 }
67 request.setOffline(session.isOffline());
68 request.setForceUpdate(session.getRequest().isUpdateSnapshots());
69
70 return request;
71 }
72
73 public boolean isOffline() {
74 return offline;
75 }
76
77 public DefaultRepositoryRequest setOffline(boolean offline) {
78 this.offline = offline;
79
80 return this;
81 }
82
83 public boolean isForceUpdate() {
84 return forceUpdate;
85 }
86
87 public DefaultRepositoryRequest setForceUpdate(boolean forceUpdate) {
88 this.forceUpdate = forceUpdate;
89
90 return this;
91 }
92
93 public ArtifactRepository getLocalRepository() {
94 return localRepository;
95 }
96
97 public DefaultRepositoryRequest setLocalRepository(ArtifactRepository localRepository) {
98 this.localRepository = localRepository;
99
100 return this;
101 }
102
103 public List<ArtifactRepository> getRemoteRepositories() {
104 if (remoteRepositories == null) {
105 remoteRepositories = new ArrayList<>();
106 }
107
108 return remoteRepositories;
109 }
110
111 public DefaultRepositoryRequest setRemoteRepositories(List<ArtifactRepository> remoteRepositories) {
112 this.remoteRepositories = remoteRepositories;
113
114 return this;
115 }
116 }