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