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
32 public class DefaultRepositoryRequest implements RepositoryRequest {
33
34 private boolean offline;
35
36 private boolean forceUpdate;
37
38 private ArtifactRepository localRepository;
39
40 private List<ArtifactRepository> remoteRepositories;
41
42
43
44
45 public DefaultRepositoryRequest() {
46
47 }
48
49
50
51
52
53
54 public DefaultRepositoryRequest(RepositoryRequest repositoryRequest) {
55 setLocalRepository(repositoryRequest.getLocalRepository());
56 setRemoteRepositories(repositoryRequest.getRemoteRepositories());
57 setOffline(repositoryRequest.isOffline());
58 setForceUpdate(repositoryRequest.isForceUpdate());
59 }
60
61 public static RepositoryRequest getRepositoryRequest(MavenSession session, MavenProject project) {
62 RepositoryRequest request = new DefaultRepositoryRequest();
63
64 request.setLocalRepository(session.getLocalRepository());
65 if (project != null) {
66 request.setRemoteRepositories(project.getPluginArtifactRepositories());
67 }
68 request.setOffline(session.isOffline());
69 request.setForceUpdate(session.getRequest().isUpdateSnapshots());
70
71 return request;
72 }
73
74 public boolean isOffline() {
75 return offline;
76 }
77
78 public DefaultRepositoryRequest setOffline(boolean offline) {
79 this.offline = offline;
80
81 return this;
82 }
83
84 public boolean isForceUpdate() {
85 return forceUpdate;
86 }
87
88 public DefaultRepositoryRequest setForceUpdate(boolean forceUpdate) {
89 this.forceUpdate = forceUpdate;
90
91 return this;
92 }
93
94 public ArtifactRepository getLocalRepository() {
95 return localRepository;
96 }
97
98 public DefaultRepositoryRequest setLocalRepository(ArtifactRepository localRepository) {
99 this.localRepository = localRepository;
100
101 return this;
102 }
103
104 public List<ArtifactRepository> getRemoteRepositories() {
105 if (remoteRepositories == null) {
106 remoteRepositories = new ArrayList<>();
107 }
108
109 return remoteRepositories;
110 }
111
112 public DefaultRepositoryRequest setRemoteRepositories(List<ArtifactRepository> remoteRepositories) {
113 this.remoteRepositories = remoteRepositories;
114
115 return this;
116 }
117 }