0
# Repository System
1
2
Maven Core repository system provides comprehensive APIs for artifact resolution, transfer operations, repository management, and dependency handling. This system enables Maven to locate, download, and manage artifacts from local and remote repositories.
3
4
## Core Repository Interface
5
6
### RepositorySystem Interface
7
8
Primary interface for repository operations including artifact resolution and publishing.
9
10
```java { .api }
11
public interface RepositorySystem {
12
// Standard Repository Constants
13
static final String DEFAULT_LOCAL_REPO_ID = "local";
14
static final String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2";
15
16
/**
17
* Resolve a single artifact.
18
*
19
* @param session repository system session
20
* @param request artifact resolution request
21
* @return artifact resolution result
22
* @throws ArtifactResolutionException if resolution fails
23
*/
24
ArtifactResult resolve(RepositorySystemSession session, ArtifactRequest request)
25
throws ArtifactResolutionException;
26
27
/**
28
* Resolve multiple artifacts.
29
*
30
* @param session repository system session
31
* @param requests collection of artifact resolution requests
32
* @return list of artifact resolution results
33
* @throws ArtifactResolutionException if any resolution fails
34
*/
35
List<ArtifactResult> resolveArtifacts(RepositorySystemSession session,
36
Collection<? extends ArtifactRequest> requests) throws ArtifactResolutionException;
37
38
/**
39
* Read artifact descriptor (POM information).
40
*
41
* @param session repository system session
42
* @param request artifact descriptor request
43
* @return artifact descriptor result with dependencies and metadata
44
* @throws ArtifactDescriptorException if descriptor reading fails
45
*/
46
ArtifactDescriptorResult readArtifactDescriptor(RepositorySystemSession session,
47
ArtifactDescriptorRequest request) throws ArtifactDescriptorException;
48
49
/**
50
* Collect dependency information.
51
*
52
* @param session repository system session
53
* @param request dependency collection request
54
* @return dependency collection result with dependency tree
55
* @throws DependencyCollectionException if collection fails
56
*/
57
CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request)
58
throws DependencyCollectionException;
59
60
/**
61
* Resolve dependency tree.
62
*
63
* @param session repository system session
64
* @param request dependency resolution request
65
* @return dependency resolution result with resolved artifacts
66
* @throws DependencyResolutionException if resolution fails
67
*/
68
DependencyResult resolveDependencies(RepositorySystemSession session, DependencyRequest request)
69
throws DependencyResolutionException;
70
71
/**
72
* Install artifacts to local repository.
73
*
74
* @param session repository system session
75
* @param request installation request
76
* @return installation result
77
* @throws InstallationException if installation fails
78
*/
79
InstallResult install(RepositorySystemSession session, InstallRequest request)
80
throws InstallationException;
81
82
/**
83
* Deploy artifacts to remote repository.
84
*
85
* @param session repository system session
86
* @param request deployment request
87
* @return deployment result
88
* @throws DeploymentException if deployment fails
89
*/
90
DeployResult deploy(RepositorySystemSession session, DeployRequest request)
91
throws DeploymentException;
92
93
/**
94
* Create local repository manager.
95
*
96
* @param session repository system session
97
* @param localRepository local repository configuration
98
* @return local repository manager instance
99
*/
100
LocalRepositoryManager newLocalRepositoryManager(RepositorySystemSession session,
101
LocalRepository localRepository);
102
103
/**
104
* Create synchronization context for thread-safe operations.
105
*
106
* @param session repository system session
107
* @param shared whether context is shared across threads
108
* @return synchronization context
109
*/
110
SyncContext newSyncContext(RepositorySystemSession session, boolean shared);
111
}
112
```
113
114
**Basic Repository Operations Example:**
115
```java
116
import org.apache.maven.repository.RepositorySystem;
117
import org.eclipse.aether.artifact.DefaultArtifact;
118
import org.eclipse.aether.resolution.ArtifactRequest;
119
import org.eclipse.aether.resolution.ArtifactResult;
120
121
@Component
122
private RepositorySystem repositorySystem;
123
124
public void resolveArtifacts(RepositorySystemSession session, List<RemoteRepository> repositories) throws Exception {
125
// Create artifact to resolve
126
Artifact artifact = new DefaultArtifact("org.apache.commons", "commons-lang3", "jar", "3.12.0");
127
128
// Create resolution request
129
ArtifactRequest request = new ArtifactRequest();
130
request.setArtifact(artifact);
131
request.setRepositories(repositories);
132
133
// Resolve artifact
134
ArtifactResult result = repositorySystem.resolve(session, request);
135
136
if (result.isResolved()) {
137
File artifactFile = result.getArtifact().getFile();
138
System.out.println("Resolved artifact: " + artifactFile.getAbsolutePath());
139
} else {
140
System.err.println("Failed to resolve artifact: " + artifact);
141
for (Exception exception : result.getExceptions()) {
142
exception.printStackTrace();
143
}
144
}
145
}
146
147
// Batch artifact resolution
148
public Map<Artifact, File> resolveMultipleArtifacts(RepositorySystemSession session,
149
List<RemoteRepository> repositories,
150
List<Artifact> artifacts) throws Exception {
151
// Create requests for all artifacts
152
List<ArtifactRequest> requests = new ArrayList<>();
153
for (Artifact artifact : artifacts) {
154
ArtifactRequest request = new ArtifactRequest();
155
request.setArtifact(artifact);
156
request.setRepositories(repositories);
157
requests.add(request);
158
}
159
160
// Resolve all artifacts
161
List<ArtifactResult> results = repositorySystem.resolveArtifacts(session, requests);
162
163
// Build result map
164
Map<Artifact, File> resolvedArtifacts = new HashMap<>();
165
for (ArtifactResult result : results) {
166
if (result.isResolved()) {
167
resolvedArtifacts.put(result.getRequest().getArtifact(), result.getArtifact().getFile());
168
} else {
169
System.err.println("Failed to resolve: " + result.getRequest().getArtifact());
170
}
171
}
172
173
return resolvedArtifacts;
174
}
175
```
176
177
## Dependency Resolution
178
179
### Dependency Collection and Resolution
180
181
```java { .api }
182
public interface RepositorySystem {
183
/**
184
* Collect dependencies for an artifact or project.
185
*
186
* @param session repository system session
187
* @param request dependency collection request
188
* @return collection result with dependency tree
189
* @throws DependencyCollectionException if collection fails
190
*/
191
CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request)
192
throws DependencyCollectionException;
193
194
/**
195
* Resolve collected dependencies to files.
196
*
197
* @param session repository system session
198
* @param request dependency resolution request
199
* @return resolution result with artifact files
200
* @throws DependencyResolutionException if resolution fails
201
*/
202
DependencyResult resolveDependencies(RepositorySystemSession session, DependencyRequest request)
203
throws DependencyResolutionException;
204
}
205
```
206
207
**Dependency Resolution Example:**
208
```java
209
import org.eclipse.aether.collection.CollectRequest;
210
import org.eclipse.aether.collection.CollectResult;
211
import org.eclipse.aether.resolution.DependencyRequest;
212
import org.eclipse.aether.resolution.DependencyResult;
213
import org.eclipse.aether.graph.DependencyNode;
214
215
public void resolveDependencyTree(RepositorySystemSession session, List<RemoteRepository> repositories) throws Exception {
216
// Create root dependency
217
Dependency rootDependency = new Dependency(
218
new DefaultArtifact("org.springframework", "spring-core", "jar", "5.3.21"), "compile");
219
220
// Create collection request
221
CollectRequest collectRequest = new CollectRequest();
222
collectRequest.setRoot(rootDependency);
223
collectRequest.setRepositories(repositories);
224
225
// Collect dependency tree
226
CollectResult collectResult = repositorySystem.collectDependencies(session, collectRequest);
227
DependencyNode rootNode = collectResult.getRoot();
228
229
System.out.println("Dependency tree for " + rootNode.getArtifact() + ":");
230
printDependencyTree(rootNode, "");
231
232
// Resolve dependencies to files
233
DependencyRequest dependencyRequest = new DependencyRequest(rootNode, null);
234
DependencyResult dependencyResult = repositorySystem.resolveDependencies(session, dependencyRequest);
235
236
System.out.println("\nResolved dependencies:");
237
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
238
if (artifactResult.isResolved()) {
239
Artifact artifact = artifactResult.getArtifact();
240
System.out.println(" " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
241
":" + artifact.getVersion() + " -> " + artifact.getFile());
242
}
243
}
244
}
245
246
private void printDependencyTree(DependencyNode node, String indent) {
247
Artifact artifact = node.getArtifact();
248
if (artifact != null) {
249
System.out.println(indent + artifact.getGroupId() + ":" + artifact.getArtifactId() +
250
":" + artifact.getVersion() + " (" + node.getDependency().getScope() + ")");
251
}
252
253
for (DependencyNode child : node.getChildren()) {
254
printDependencyTree(child, indent + " ");
255
}
256
}
257
258
// Resolve with filters
259
public void resolveDependenciesWithFilters(RepositorySystemSession session,
260
List<RemoteRepository> repositories) throws Exception {
261
// Create collection request
262
CollectRequest collectRequest = new CollectRequest();
263
collectRequest.setRoot(new Dependency(
264
new DefaultArtifact("org.apache.maven", "maven-core", "jar", "3.9.11"), "compile"));
265
collectRequest.setRepositories(repositories);
266
267
// Collect dependencies
268
CollectResult collectResult = repositorySystem.collectDependencies(session, collectRequest);
269
270
// Create dependency filter (exclude test scope)
271
DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.TEST);
272
273
// Resolve with filter
274
DependencyRequest dependencyRequest = new DependencyRequest(collectResult.getRoot(), filter);
275
DependencyResult result = repositorySystem.resolveDependencies(session, dependencyRequest);
276
277
System.out.println("Resolved " + result.getArtifactResults().size() +
278
" dependencies (excluding test scope)");
279
}
280
```
281
282
## Artifact Transfer Events
283
284
### ArtifactTransferListener Interface
285
286
Interface for monitoring artifact transfer operations.
287
288
```java { .api }
289
public interface ArtifactTransferListener {
290
/**
291
* Called when transfer is initiated.
292
*
293
* @param event transfer event information
294
*/
295
void transferInitiated(ArtifactTransferEvent event);
296
297
/**
298
* Called when transfer starts.
299
*
300
* @param event transfer event information
301
*/
302
void transferStarted(ArtifactTransferEvent event);
303
304
/**
305
* Called during transfer progress.
306
*
307
* @param event transfer event information with progress data
308
*/
309
void transferProgress(ArtifactTransferEvent event);
310
311
/**
312
* Called when transfer completes successfully.
313
*
314
* @param event transfer event information
315
*/
316
void transferCompleted(ArtifactTransferEvent event);
317
318
/**
319
* Called when transfer encounters an error.
320
*
321
* @param event transfer event information with error details
322
*/
323
void transferError(ArtifactTransferEvent event);
324
}
325
```
326
327
### ArtifactTransferEvent Class
328
329
Event data for artifact transfer operations.
330
331
```java { .api }
332
public class ArtifactTransferEvent {
333
// Event Type Constants
334
public static final int TRANSFER_INITIATED = 1;
335
public static final int TRANSFER_STARTED = 2;
336
public static final int TRANSFER_COMPLETED = 3;
337
public static final int TRANSFER_ERROR = 4;
338
339
// Request Type Constants
340
public static final int REQUEST_GET = 1;
341
public static final int REQUEST_PUT = 2;
342
343
/**
344
* Get event type.
345
*
346
* @return event type constant
347
*/
348
public int getEventType();
349
350
/**
351
* Get request type (GET or PUT).
352
*
353
* @return request type constant
354
*/
355
public int getRequestType();
356
357
/**
358
* Get artifact being transferred.
359
*
360
* @return artifact instance
361
*/
362
public Artifact getArtifact();
363
364
/**
365
* Get local file for the artifact.
366
*
367
* @return local file path
368
*/
369
public File getLocalFile();
370
371
/**
372
* Get repository involved in transfer.
373
*
374
* @return artifact repository
375
*/
376
public ArtifactRepository getRepository();
377
378
/**
379
* Get transfer exception (for error events).
380
*
381
* @return exception or null if no error
382
*/
383
public Exception getException();
384
385
/**
386
* Get total length of transfer.
387
*
388
* @return total bytes to transfer
389
*/
390
public long getDataLength();
391
392
/**
393
* Get bytes transferred so far.
394
*
395
* @return bytes transferred
396
*/
397
public long getTransferredBytes();
398
399
/**
400
* Get data buffer for progress events.
401
*
402
* @return byte buffer with current data chunk
403
*/
404
public byte[] getDataBuffer();
405
406
/**
407
* Get offset in data buffer.
408
*
409
* @return buffer offset
410
*/
411
public int getDataOffset();
412
413
/**
414
* Get length of data in buffer.
415
*
416
* @return buffer data length
417
*/
418
public int getDataLength();
419
}
420
```
421
422
**Transfer Listener Example:**
423
```java
424
import org.apache.maven.repository.ArtifactTransferListener;
425
import org.apache.maven.repository.ArtifactTransferEvent;
426
427
public class ProgressTrackingTransferListener implements ArtifactTransferListener {
428
private final Map<Artifact, TransferProgress> progressMap = new ConcurrentHashMap<>();
429
430
@Override
431
public void transferInitiated(ArtifactTransferEvent event) {
432
Artifact artifact = event.getArtifact();
433
System.out.println("Transfer initiated: " + artifact.getGroupId() + ":" +
434
artifact.getArtifactId() + ":" + artifact.getVersion());
435
}
436
437
@Override
438
public void transferStarted(ArtifactTransferEvent event) {
439
Artifact artifact = event.getArtifact();
440
long totalBytes = event.getDataLength();
441
442
TransferProgress progress = new TransferProgress(totalBytes, System.currentTimeMillis());
443
progressMap.put(artifact, progress);
444
445
String direction = (event.getRequestType() == ArtifactTransferEvent.REQUEST_GET) ? "Downloading" : "Uploading";
446
System.out.println(direction + " " + artifact.getArtifactId() +
447
" (" + formatBytes(totalBytes) + ")");
448
}
449
450
@Override
451
public void transferProgress(ArtifactTransferEvent event) {
452
Artifact artifact = event.getArtifact();
453
TransferProgress progress = progressMap.get(artifact);
454
455
if (progress != null) {
456
progress.addBytes(event.getDataLength());
457
458
long elapsed = System.currentTimeMillis() - progress.getStartTime();
459
if (elapsed > 1000) { // Update every second
460
double percentage = (progress.getTransferredBytes() * 100.0) / progress.getTotalBytes();
461
double speed = progress.getTransferredBytes() / (elapsed / 1000.0); // bytes per second
462
463
System.out.printf("\r%s: %.1f%% (%s at %s/s)",
464
artifact.getArtifactId(),
465
percentage,
466
formatBytes(progress.getTransferredBytes()),
467
formatBytes((long) speed));
468
}
469
}
470
}
471
472
@Override
473
public void transferCompleted(ArtifactTransferEvent event) {
474
Artifact artifact = event.getArtifact();
475
TransferProgress progress = progressMap.remove(artifact);
476
477
if (progress != null) {
478
long elapsed = System.currentTimeMillis() - progress.getStartTime();
479
double speed = progress.getTotalBytes() / (elapsed / 1000.0);
480
481
System.out.println("\nCompleted " + artifact.getArtifactId() +
482
" (" + formatBytes(progress.getTotalBytes()) +
483
" in " + (elapsed / 1000.0) + "s at " + formatBytes((long) speed) + "/s)");
484
}
485
}
486
487
@Override
488
public void transferError(ArtifactTransferEvent event) {
489
Artifact artifact = event.getArtifact();
490
Exception exception = event.getException();
491
492
progressMap.remove(artifact);
493
494
System.err.println("\nTransfer failed for " + artifact.getArtifactId() +
495
": " + exception.getMessage());
496
}
497
498
private String formatBytes(long bytes) {
499
if (bytes < 1024) return bytes + " B";
500
if (bytes < 1024 * 1024) return String.format("%.1f KB", bytes / 1024.0);
501
return String.format("%.1f MB", bytes / (1024.0 * 1024.0));
502
}
503
504
private static class TransferProgress {
505
private final long totalBytes;
506
private final long startTime;
507
private long transferredBytes;
508
509
public TransferProgress(long totalBytes, long startTime) {
510
this.totalBytes = totalBytes;
511
this.startTime = startTime;
512
}
513
514
public void addBytes(long bytes) {
515
this.transferredBytes += bytes;
516
}
517
518
public long getTotalBytes() { return totalBytes; }
519
public long getStartTime() { return startTime; }
520
public long getTransferredBytes() { return transferredBytes; }
521
}
522
}
523
```
524
525
## Repository Configuration
526
527
### ArtifactRepository Interface
528
529
Represents a Maven artifact repository (local or remote).
530
531
```java { .api }
532
public interface ArtifactRepository {
533
/**
534
* Get repository identifier.
535
*
536
* @return repository ID
537
*/
538
String getId();
539
540
/**
541
* Set repository identifier.
542
*
543
* @param id repository ID
544
*/
545
void setId(String id);
546
547
/**
548
* Get repository URL.
549
*
550
* @return repository URL
551
*/
552
String getUrl();
553
554
/**
555
* Set repository URL.
556
*
557
* @param url repository URL
558
*/
559
void setUrl(String url);
560
561
/**
562
* Get repository layout.
563
*
564
* @return repository layout strategy
565
*/
566
ArtifactRepositoryLayout getLayout();
567
568
/**
569
* Set repository layout.
570
*
571
* @param layout repository layout strategy
572
*/
573
void setLayout(ArtifactRepositoryLayout layout);
574
575
/**
576
* Get snapshot policy.
577
*
578
* @return snapshot artifact policy
579
*/
580
ArtifactRepositoryPolicy getSnapshots();
581
582
/**
583
* Set snapshot policy.
584
*
585
* @param policy snapshot artifact policy
586
*/
587
void setSnapshots(ArtifactRepositoryPolicy policy);
588
589
/**
590
* Get releases policy.
591
*
592
* @return release artifact policy
593
*/
594
ArtifactRepositoryPolicy getReleases();
595
596
/**
597
* Set releases policy.
598
*
599
* @param policy release artifact policy
600
*/
601
void setReleases(ArtifactRepositoryPolicy policy);
602
603
/**
604
* Check if repository uses unique versions for snapshots.
605
*
606
* @return true if unique versions are used
607
*/
608
boolean isUniqueVersion();
609
610
/**
611
* Check if repository is blacklisted.
612
*
613
* @return true if blacklisted
614
*/
615
boolean isBlacklisted();
616
617
/**
618
* Set repository blacklist status.
619
*
620
* @param blacklisted true to blacklist repository
621
*/
622
void setBlacklisted(boolean blacklisted);
623
}
624
```
625
626
**Repository Configuration Example:**
627
```java
628
import org.apache.maven.artifact.repository.ArtifactRepository;
629
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
630
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
631
632
public List<ArtifactRepository> createRepositoryList() {
633
List<ArtifactRepository> repositories = new ArrayList<>();
634
635
// Central repository
636
ArtifactRepository central = new DefaultArtifactRepository(
637
"central",
638
"https://repo.maven.apache.org/maven2",
639
new DefaultArtifactRepositoryLayout());
640
641
// Enable releases, disable snapshots
642
central.setReleases(new ArtifactRepositoryPolicy(true, "daily", "warn"));
643
central.setSnapshots(new ArtifactRepositoryPolicy(false, "never", "ignore"));
644
645
repositories.add(central);
646
647
// Snapshot repository
648
ArtifactRepository snapshots = new DefaultArtifactRepository(
649
"snapshots",
650
"https://oss.sonatype.org/content/repositories/snapshots",
651
new DefaultArtifactRepositoryLayout());
652
653
// Enable snapshots with frequent updates
654
snapshots.setReleases(new ArtifactRepositoryPolicy(false, "never", "ignore"));
655
snapshots.setSnapshots(new ArtifactRepositoryPolicy(true, "always", "warn"));
656
657
repositories.add(snapshots);
658
659
return repositories;
660
}
661
662
// Create local repository
663
public ArtifactRepository createLocalRepository(String path) {
664
ArtifactRepository localRepo = new DefaultArtifactRepository(
665
RepositorySystem.DEFAULT_LOCAL_REPO_ID,
666
"file://" + path,
667
new DefaultArtifactRepositoryLayout());
668
669
// Local repository accepts both releases and snapshots
670
localRepo.setReleases(new ArtifactRepositoryPolicy(true, "never", "ignore"));
671
localRepo.setSnapshots(new ArtifactRepositoryPolicy(true, "never", "ignore"));
672
673
return localRepo;
674
}
675
```
676
677
## Installation and Deployment
678
679
### Install and Deploy Operations
680
681
```java { .api }
682
public interface RepositorySystem {
683
/**
684
* Install artifacts to local repository.
685
*
686
* @param session repository system session
687
* @param request installation request containing artifacts to install
688
* @return installation result
689
* @throws InstallationException if installation fails
690
*/
691
InstallResult install(RepositorySystemSession session, InstallRequest request)
692
throws InstallationException;
693
694
/**
695
* Deploy artifacts to remote repository.
696
*
697
* @param session repository system session
698
* @param request deployment request containing artifacts and target repository
699
* @return deployment result
700
* @throws DeploymentException if deployment fails
701
*/
702
DeployResult deploy(RepositorySystemSession session, DeployRequest request)
703
throws DeploymentException;
704
}
705
```
706
707
**Installation and Deployment Example:**
708
```java
709
import org.eclipse.aether.installation.InstallRequest;
710
import org.eclipse.aether.installation.InstallResult;
711
import org.eclipse.aether.deployment.DeployRequest;
712
import org.eclipse.aether.deployment.DeployResult;
713
714
public void installArtifact(RepositorySystemSession session, MavenProject project) throws Exception {
715
// Create artifacts to install
716
Artifact mainArtifact = new DefaultArtifact(
717
project.getGroupId(),
718
project.getArtifactId(),
719
project.getPackaging(),
720
project.getVersion());
721
mainArtifact = mainArtifact.setFile(project.getArtifact().getFile());
722
723
// Create install request
724
InstallRequest installRequest = new InstallRequest();
725
installRequest.addArtifact(mainArtifact);
726
727
// Install POM
728
File pomFile = project.getFile();
729
if (pomFile != null && pomFile.exists()) {
730
Artifact pomArtifact = new SubArtifact(mainArtifact, "", "pom");
731
pomArtifact = pomArtifact.setFile(pomFile);
732
installRequest.addArtifact(pomArtifact);
733
}
734
735
// Install attached artifacts (sources, javadoc, etc.)
736
for (Artifact attached : project.getAttachedArtifacts()) {
737
installRequest.addArtifact(attached);
738
}
739
740
// Perform installation
741
InstallResult result = repositorySystem.install(session, installRequest);
742
743
System.out.println("Installed " + result.getArtifacts().size() + " artifacts to local repository:");
744
for (Artifact artifact : result.getArtifacts()) {
745
System.out.println(" " + artifact);
746
}
747
}
748
749
public void deployArtifact(RepositorySystemSession session, MavenProject project,
750
RemoteRepository deploymentRepository) throws Exception {
751
// Create deployment request
752
DeployRequest deployRequest = new DeployRequest();
753
deployRequest.setRepository(deploymentRepository);
754
755
// Add main artifact
756
Artifact mainArtifact = new DefaultArtifact(
757
project.getGroupId(),
758
project.getArtifactId(),
759
project.getPackaging(),
760
project.getVersion());
761
mainArtifact = mainArtifact.setFile(project.getArtifact().getFile());
762
deployRequest.addArtifact(mainArtifact);
763
764
// Add POM
765
File pomFile = project.getFile();
766
if (pomFile != null && pomFile.exists()) {
767
Artifact pomArtifact = new SubArtifact(mainArtifact, "", "pom");
768
pomArtifact = pomArtifact.setFile(pomFile);
769
deployRequest.addArtifact(pomArtifact);
770
}
771
772
// Add attached artifacts
773
for (Artifact attached : project.getAttachedArtifacts()) {
774
deployRequest.addArtifact(attached);
775
}
776
777
// Perform deployment
778
DeployResult result = repositorySystem.deploy(session, deployRequest);
779
780
System.out.println("Deployed " + result.getArtifacts().size() +
781
" artifacts to " + deploymentRepository.getId() + ":");
782
for (Artifact artifact : result.getArtifacts()) {
783
System.out.println(" " + artifact + " -> " + deploymentRepository.getUrl());
784
}
785
}
786
```
787
788
## Types
789
790
```java { .api }
791
public interface ArtifactRepositoryPolicy {
792
boolean isEnabled();
793
void setEnabled(boolean enabled);
794
795
String getUpdatePolicy();
796
void setUpdatePolicy(String updatePolicy);
797
798
String getChecksumPolicy();
799
void setChecksumPolicy(String checksumPolicy);
800
801
// Update Policy Constants
802
String UPDATE_POLICY_NEVER = "never";
803
String UPDATE_POLICY_ALWAYS = "always";
804
String UPDATE_POLICY_DAILY = "daily";
805
String UPDATE_POLICY_INTERVAL = "interval";
806
807
// Checksum Policy Constants
808
String CHECKSUM_POLICY_FAIL = "fail";
809
String CHECKSUM_POLICY_WARN = "warn";
810
String CHECKSUM_POLICY_IGNORE = "ignore";
811
}
812
813
public interface ArtifactRepositoryLayout {
814
String pathOf(Artifact artifact);
815
String pathOfLocalRepositoryMetadata(Metadata metadata, ArtifactRepository repository);
816
String pathOfRemoteRepositoryMetadata(Metadata metadata);
817
}
818
819
public interface RepositorySystemSession {
820
boolean isOffline();
821
boolean isIgnoreArtifactDescriptorRepositories();
822
ResolutionErrorPolicy getResolutionErrorPolicy();
823
ArtifactTypeRegistry getArtifactTypeRegistry();
824
DependencyTraverser getDependencyTraverser();
825
DependencyManager getDependencyManager();
826
DependencySelector getDependencySelector();
827
VersionFilter getVersionFilter();
828
VersionRangeResolver getVersionRangeResolver();
829
VersionResolver getVersionResolver();
830
ArtifactResolver getArtifactResolver();
831
MetadataResolver getMetadataResolver();
832
FileTransformerManager getFileTransformerManager();
833
SessionData getData();
834
RepositoryCache getCache();
835
LocalRepository getLocalRepository();
836
LocalRepositoryManager getLocalRepositoryManager();
837
WorkspaceReader getWorkspaceReader();
838
RepositoryListener getRepositoryListener();
839
TransferListener getTransferListener();
840
Map<String, String> getSystemProperties();
841
Map<String, String> getUserProperties();
842
Map<String, Object> getConfigProperties();
843
MirrorSelector getMirrorSelector();
844
ProxySelector getProxySelector();
845
AuthenticationSelector getAuthenticationSelector();
846
ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
847
}
848
849
public interface LocalRepositoryManager {
850
LocalRepository getRepository();
851
String getPathForLocalArtifact(Artifact artifact);
852
String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context);
853
String getPathForLocalMetadata(Metadata metadata);
854
String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context);
855
LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request);
856
void add(RepositorySystemSession session, LocalArtifactRegistration request);
857
LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request);
858
void add(RepositorySystemSession session, LocalMetadataRegistration request);
859
}
860
861
public interface SyncContext extends Closeable {
862
void acquire(Collection<? extends Artifact> artifacts, Collection<? extends Metadata> metadatas);
863
void close();
864
}
865
```