1
2
3
4
5 package org.apache.maven.api.model;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import java.util.Objects;
15 import java.util.Optional;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19 import org.apache.maven.api.annotations.Experimental;
20 import org.apache.maven.api.annotations.Generated;
21 import org.apache.maven.api.annotations.Immutable;
22 import org.apache.maven.api.annotations.Nonnull;
23 import org.apache.maven.api.annotations.NotThreadSafe;
24 import org.apache.maven.api.annotations.ThreadSafe;
25
26
27
28
29 @Experimental
30 @Generated @ThreadSafe @Immutable
31 public class PluginConfiguration
32 extends PluginContainer
33 implements Serializable, InputLocationTracker
34 {
35
36
37
38
39
40
41 final PluginManagement pluginManagement;
42
43
44
45
46
47 protected PluginConfiguration(Builder builder) {
48 super(builder);
49 this.pluginManagement = builder.pluginManagement != null ? builder.pluginManagement : (builder.base != null ? builder.base.pluginManagement : null);
50 }
51
52
53
54
55
56
57
58
59
60 public PluginManagement getPluginManagement() {
61 return this.pluginManagement;
62 }
63
64
65
66
67
68
69 @Nonnull
70 public Builder with() {
71 return newBuilder(this);
72 }
73
74
75
76
77
78
79 @Nonnull
80 public PluginConfiguration withPlugins(Collection<Plugin> plugins) {
81 return newBuilder(this, true).plugins(plugins).build();
82 }
83
84
85
86
87
88
89 @Nonnull
90 public PluginConfiguration withPluginManagement(PluginManagement pluginManagement) {
91 return newBuilder(this, true).pluginManagement(pluginManagement).build();
92 }
93
94
95
96
97
98
99
100
101 @Nonnull
102 public static PluginConfiguration newInstance() {
103 return newInstance(true);
104 }
105
106
107
108
109
110
111
112
113 @Nonnull
114 public static PluginConfiguration newInstance(boolean withDefaults) {
115 return newBuilder(withDefaults).build();
116 }
117
118
119
120
121
122
123
124
125 @Nonnull
126 public static Builder newBuilder() {
127 return newBuilder(true);
128 }
129
130
131
132
133
134
135
136 @Nonnull
137 public static Builder newBuilder(boolean withDefaults) {
138 return new Builder(withDefaults);
139 }
140
141
142
143
144
145
146
147
148 @Nonnull
149 public static Builder newBuilder(PluginConfiguration from) {
150 return newBuilder(from, false);
151 }
152
153
154
155
156
157
158
159
160 @Nonnull
161 public static Builder newBuilder(PluginConfiguration from, boolean forceCopy) {
162 return new Builder(from, forceCopy);
163 }
164
165
166
167
168
169
170 @NotThreadSafe
171 public static class Builder
172 extends PluginContainer.Builder
173 {
174 PluginConfiguration base;
175 PluginManagement pluginManagement;
176
177 protected Builder(boolean withDefaults) {
178 super(withDefaults);
179 if (withDefaults) {
180 }
181 }
182
183 protected Builder(PluginConfiguration base, boolean forceCopy) {
184 super(base, forceCopy);
185 if (forceCopy) {
186 this.pluginManagement = base.pluginManagement;
187 this.locations = base.locations;
188 this.importedFrom = base.importedFrom;
189 } else {
190 this.base = base;
191 }
192 }
193
194 @Nonnull
195 public Builder plugins(Collection<Plugin> plugins) {
196 this.plugins = plugins;
197 return this;
198 }
199
200 @Nonnull
201 public Builder pluginManagement(PluginManagement pluginManagement) {
202 this.pluginManagement = pluginManagement;
203 return this;
204 }
205
206
207 @Nonnull
208 public Builder location(Object key, InputLocation location) {
209 if (location != null) {
210 if (!(this.locations instanceof HashMap)) {
211 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
212 }
213 this.locations.put(key, location);
214 }
215 return this;
216 }
217
218 @Nonnull
219 public Builder importedFrom(InputLocation importedFrom) {
220 this.importedFrom = importedFrom;
221 return this;
222 }
223
224 @Nonnull
225 public PluginConfiguration build() {
226
227 if (base != null
228 && (plugins == null || plugins == base.plugins)
229 && (pluginManagement == null || pluginManagement == base.pluginManagement)
230 ) {
231 return base;
232 }
233 return new PluginConfiguration(this);
234 }
235
236 }
237
238
239
240
241
242
243 public String toString()
244 {
245 return "PluginConfiguration {" + super.toString() + "}";
246 }
247
248
249 }