0
# Repository Management
1
2
Repository and deployment configuration including repository policies, authentication, and distribution management. These classes handle Maven's artifact repository system for dependency resolution and deployment.
3
4
## Capabilities
5
6
### Repository
7
8
Represents a Maven repository for resolving dependencies and plugins.
9
10
```java { .api }
11
public class Repository extends RepositoryBase {
12
public RepositoryPolicy getReleases();
13
public void setReleases(RepositoryPolicy releases);
14
public RepositoryPolicy getSnapshots();
15
public void setSnapshots(RepositoryPolicy snapshots);
16
17
// Utility methods
18
public Repository clone();
19
public InputLocation getLocation(Object key);
20
public void setLocation(Object key, InputLocation location);
21
}
22
```
23
24
**Usage Example:**
25
26
```java
27
Repository repository = new Repository();
28
repository.setId("central");
29
repository.setName("Maven Central Repository");
30
repository.setUrl("https://repo1.maven.org/maven2");
31
32
// Configure release policy
33
RepositoryPolicy releasePolicy = new RepositoryPolicy();
34
releasePolicy.setEnabled("true");
35
releasePolicy.setUpdatePolicy("daily");
36
releasePolicy.setChecksumPolicy("warn");
37
repository.setReleases(releasePolicy);
38
39
model.addRepository(repository);
40
```
41
42
### RepositoryBase
43
44
Base class containing common repository properties.
45
46
```java { .api }
47
public class RepositoryBase {
48
public String getId();
49
public void setId(String id);
50
public String getName();
51
public void setName(String name);
52
public String getUrl();
53
public void setUrl(String url);
54
public String getLayout();
55
public void setLayout(String layout);
56
57
// Utility methods
58
public String toString();
59
public RepositoryBase clone();
60
public InputLocation getLocation(Object key);
61
public void setLocation(Object key, InputLocation location);
62
}
63
```
64
65
### DeploymentRepository
66
67
Extends Repository for deployment configuration with unique version handling.
68
69
```java { .api }
70
public class DeploymentRepository extends Repository {
71
public String getUniqueVersion();
72
public void setUniqueVersion(String uniqueVersion);
73
public boolean isUniqueVersion();
74
75
// Utility methods
76
public DeploymentRepository clone();
77
public InputLocation getLocation(Object key);
78
public void setLocation(Object key, InputLocation location);
79
}
80
```
81
82
### RepositoryPolicy
83
84
Defines policies for repository usage including update frequency and checksum validation.
85
86
```java { .api }
87
public class RepositoryPolicy {
88
public String getEnabled();
89
public void setEnabled(String enabled);
90
public boolean isEnabled();
91
public String getUpdatePolicy();
92
public void setUpdatePolicy(String updatePolicy);
93
public String getChecksumPolicy();
94
public void setChecksumPolicy(String checksumPolicy);
95
96
// Utility methods
97
public RepositoryPolicy clone();
98
public InputLocation getLocation(Object key);
99
public void setLocation(Object key, InputLocation location);
100
}
101
```
102
103
**Common Update Policies:**
104
- `always`: Check for updates on every build
105
- `daily` (default): Check for updates once per day
106
- `interval:X`: Check for updates every X minutes
107
- `never`: Never check for updates
108
109
**Common Checksum Policies:**
110
- `fail`: Fail the build if checksums don't match
111
- `warn` (default): Log a warning if checksums don't match
112
- `ignore`: Ignore checksum mismatches
113
114
### DistributionManagement
115
116
Configures where and how artifacts are deployed and where the project site is distributed.
117
118
```java { .api }
119
public class DistributionManagement {
120
public DeploymentRepository getRepository();
121
public void setRepository(DeploymentRepository repository);
122
public DeploymentRepository getSnapshotRepository();
123
public void setSnapshotRepository(DeploymentRepository snapshotRepository);
124
public Site getSite();
125
public void setSite(Site site);
126
public String getDownloadUrl();
127
public void setDownloadUrl(String downloadUrl);
128
public Relocation getRelocation();
129
public void setRelocation(Relocation relocation);
130
public String getStatus();
131
public void setStatus(String status);
132
133
// Utility methods
134
public DistributionManagement clone();
135
public InputLocation getLocation(Object key);
136
public void setLocation(Object key, InputLocation location);
137
}
138
```
139
140
**Usage Example:**
141
142
```java
143
DistributionManagement distMgmt = new DistributionManagement();
144
145
// Release repository
146
DeploymentRepository releaseRepo = new DeploymentRepository();
147
releaseRepo.setId("releases");
148
releaseRepo.setName("Release Repository");
149
releaseRepo.setUrl("https://nexus.example.com/repository/releases/");
150
distMgmt.setRepository(releaseRepo);
151
152
// Snapshot repository
153
DeploymentRepository snapshotRepo = new DeploymentRepository();
154
snapshotRepo.setId("snapshots");
155
snapshotRepo.setName("Snapshot Repository");
156
snapshotRepo.setUrl("https://nexus.example.com/repository/snapshots/");
157
distMgmt.setSnapshotRepository(snapshotRepo);
158
159
model.setDistributionManagement(distMgmt);
160
```
161
162
### Site
163
164
Defines where project documentation site should be deployed.
165
166
```java { .api }
167
public class Site {
168
public String getId();
169
public void setId(String id);
170
public String getName();
171
public void setName(String name);
172
public String getUrl();
173
public void setUrl(String url);
174
175
// Utility methods
176
public Site clone();
177
public InputLocation getLocation(Object key);
178
public void setLocation(Object key, InputLocation location);
179
}
180
```
181
182
### Relocation
183
184
Provides information about artifact relocation when groupId, artifactId, or version has changed.
185
186
```java { .api }
187
public class Relocation {
188
public String getGroupId();
189
public void setGroupId(String groupId);
190
public String getArtifactId();
191
public void setArtifactId(String artifactId);
192
public String getVersion();
193
public void setVersion(String version);
194
public String getMessage();
195
public void setMessage(String message);
196
197
// Utility methods
198
public Relocation clone();
199
public InputLocation getLocation(Object key);
200
public void setLocation(Object key, InputLocation location);
201
}
202
```