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