1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.services;
20
21 import static org.apache.maven.api.services.BaseRequest.nonNull;
22
23 import java.util.Collection;
24 import org.apache.maven.api.Artifact;
25 import org.apache.maven.api.RemoteRepository;
26 import org.apache.maven.api.Session;
27 import org.apache.maven.api.annotations.Experimental;
28 import org.apache.maven.api.annotations.Immutable;
29 import org.apache.maven.api.annotations.Nonnull;
30
31
32
33
34
35
36 @Experimental
37 @Immutable
38 public interface ArtifactDeployerRequest {
39
40 @Nonnull
41 Session getSession();
42
43 @Nonnull
44 RemoteRepository getRepository();
45
46 @Nonnull
47 Collection<Artifact> getArtifacts();
48
49 int getRetryFailedDeploymentCount();
50
51 @Nonnull
52 static ArtifactDeployerRequestBuilder builder() {
53 return new ArtifactDeployerRequestBuilder();
54 }
55
56 @Nonnull
57 static ArtifactDeployerRequest build(
58 @Nonnull Session session, @Nonnull RemoteRepository repository, @Nonnull Collection<Artifact> artifacts) {
59 return builder()
60 .session(nonNull(session, "session cannot be null"))
61 .repository(nonNull(repository, "repository cannot be null"))
62 .artifacts(nonNull(artifacts, "artifacts cannot be null"))
63 .build();
64 }
65
66 class ArtifactDeployerRequestBuilder {
67 Session session;
68 RemoteRepository repository;
69 Collection<Artifact> artifacts;
70 int retryFailedDeploymentCount;
71
72 ArtifactDeployerRequestBuilder() {}
73
74 @Nonnull
75 public ArtifactDeployerRequestBuilder session(Session session) {
76 this.session = session;
77 return this;
78 }
79
80 @Nonnull
81 public ArtifactDeployerRequestBuilder repository(RemoteRepository repository) {
82 this.repository = repository;
83 return this;
84 }
85
86 public ArtifactDeployerRequestBuilder artifacts(Collection<Artifact> artifacts) {
87 this.artifacts = artifacts;
88 return this;
89 }
90
91 public ArtifactDeployerRequestBuilder retryFailedDeploymentCount(int retryFailedDeploymentCount) {
92 this.retryFailedDeploymentCount = retryFailedDeploymentCount;
93 return this;
94 }
95
96 @Nonnull
97 public ArtifactDeployerRequest build() {
98 return new DefaultArtifactDeployerRequest(session, repository, artifacts, retryFailedDeploymentCount);
99 }
100
101 private static class DefaultArtifactDeployerRequest extends BaseRequest implements ArtifactDeployerRequest {
102
103 private final RemoteRepository repository;
104 private final Collection<Artifact> artifacts;
105 private final int retryFailedDeploymentCount;
106
107 DefaultArtifactDeployerRequest(
108 @Nonnull Session session,
109 @Nonnull RemoteRepository repository,
110 @Nonnull Collection<Artifact> artifacts,
111 int retryFailedDeploymentCount) {
112 super(session);
113 this.repository = nonNull(repository, "repository cannot be null");
114 this.artifacts = unmodifiable(nonNull(artifacts, "artifacts cannot be null"));
115 this.retryFailedDeploymentCount = retryFailedDeploymentCount;
116 }
117
118 @Nonnull
119 @Override
120 public RemoteRepository getRepository() {
121 return repository;
122 }
123
124 @Nonnull
125 @Override
126 public Collection<Artifact> getArtifacts() {
127 return artifacts;
128 }
129
130 @Override
131 public int getRetryFailedDeploymentCount() {
132 return retryFailedDeploymentCount;
133 }
134 }
135 }
136 }