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.ProducedArtifact;
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<ProducedArtifact> 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,
60 @Nonnull RemoteRepository repository,
61 @Nonnull Collection<ProducedArtifact> artifacts) {
62 return builder()
63 .session(nonNull(session, "session cannot be null"))
64 .repository(nonNull(repository, "repository cannot be null"))
65 .artifacts(nonNull(artifacts, "artifacts cannot be null"))
66 .build();
67 }
68
69 class ArtifactDeployerRequestBuilder {
70 Session session;
71 RemoteRepository repository;
72 Collection<ProducedArtifact> artifacts;
73 int retryFailedDeploymentCount;
74
75 ArtifactDeployerRequestBuilder() {}
76
77 @Nonnull
78 public ArtifactDeployerRequestBuilder session(Session session) {
79 this.session = session;
80 return this;
81 }
82
83 @Nonnull
84 public ArtifactDeployerRequestBuilder repository(RemoteRepository repository) {
85 this.repository = repository;
86 return this;
87 }
88
89 public ArtifactDeployerRequestBuilder artifacts(Collection<ProducedArtifact> artifacts) {
90 this.artifacts = artifacts;
91 return this;
92 }
93
94 public ArtifactDeployerRequestBuilder retryFailedDeploymentCount(int retryFailedDeploymentCount) {
95 this.retryFailedDeploymentCount = retryFailedDeploymentCount;
96 return this;
97 }
98
99 @Nonnull
100 public ArtifactDeployerRequest build() {
101 return new DefaultArtifactDeployerRequest(session, repository, artifacts, retryFailedDeploymentCount);
102 }
103
104 private static class DefaultArtifactDeployerRequest extends BaseRequest<Session>
105 implements ArtifactDeployerRequest {
106
107 private final RemoteRepository repository;
108 private final Collection<ProducedArtifact> artifacts;
109 private final int retryFailedDeploymentCount;
110
111 DefaultArtifactDeployerRequest(
112 @Nonnull Session session,
113 @Nonnull RemoteRepository repository,
114 @Nonnull Collection<ProducedArtifact> artifacts,
115 int retryFailedDeploymentCount) {
116 super(session);
117 this.repository = nonNull(repository, "repository cannot be null");
118 this.artifacts = unmodifiable(nonNull(artifacts, "artifacts cannot be null"));
119 this.retryFailedDeploymentCount = retryFailedDeploymentCount;
120 }
121
122 @Nonnull
123 @Override
124 public RemoteRepository getRepository() {
125 return repository;
126 }
127
128 @Nonnull
129 @Override
130 public Collection<ProducedArtifact> getArtifacts() {
131 return artifacts;
132 }
133
134 @Override
135 public int getRetryFailedDeploymentCount() {
136 return retryFailedDeploymentCount;
137 }
138 }
139 }
140 }