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 PluginManagement
32 extends PluginContainer
33 implements Serializable, InputLocationTracker
34 {
35
36
37
38
39
40 protected PluginManagement(Builder builder) {
41 super(builder);
42 }
43
44
45
46
47
48
49 @Nonnull
50 public Builder with() {
51 return newBuilder(this);
52 }
53
54
55
56
57
58
59 @Nonnull
60 public PluginManagement withPlugins(Collection<Plugin> plugins) {
61 return newBuilder(this, true).plugins(plugins).build();
62 }
63
64
65
66
67
68
69
70
71 @Nonnull
72 public static PluginManagement newInstance() {
73 return newInstance(true);
74 }
75
76
77
78
79
80
81
82
83 @Nonnull
84 public static PluginManagement newInstance(boolean withDefaults) {
85 return newBuilder(withDefaults).build();
86 }
87
88
89
90
91
92
93
94
95 @Nonnull
96 public static Builder newBuilder() {
97 return newBuilder(true);
98 }
99
100
101
102
103
104
105
106 @Nonnull
107 public static Builder newBuilder(boolean withDefaults) {
108 return new Builder(withDefaults);
109 }
110
111
112
113
114
115
116
117
118 @Nonnull
119 public static Builder newBuilder(PluginManagement from) {
120 return newBuilder(from, false);
121 }
122
123
124
125
126
127
128
129
130 @Nonnull
131 public static Builder newBuilder(PluginManagement from, boolean forceCopy) {
132 return new Builder(from, forceCopy);
133 }
134
135
136
137
138
139
140 @NotThreadSafe
141 public static class Builder
142 extends PluginContainer.Builder
143 {
144 PluginManagement base;
145
146 protected Builder(boolean withDefaults) {
147 super(withDefaults);
148 if (withDefaults) {
149 }
150 }
151
152 protected Builder(PluginManagement base, boolean forceCopy) {
153 super(base, forceCopy);
154 if (forceCopy) {
155 this.locations = base.locations;
156 this.importedFrom = base.importedFrom;
157 } else {
158 this.base = base;
159 }
160 }
161
162 @Nonnull
163 public Builder plugins(Collection<Plugin> plugins) {
164 this.plugins = plugins;
165 return this;
166 }
167
168
169 @Nonnull
170 public Builder location(Object key, InputLocation location) {
171 if (location != null) {
172 if (!(this.locations instanceof HashMap)) {
173 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
174 }
175 this.locations.put(key, location);
176 }
177 return this;
178 }
179
180 @Nonnull
181 public Builder importedFrom(InputLocation importedFrom) {
182 this.importedFrom = importedFrom;
183 return this;
184 }
185
186 @Nonnull
187 public PluginManagement build() {
188
189 if (base != null
190 && (plugins == null || plugins == base.plugins)
191 ) {
192 return base;
193 }
194 return new PluginManagement(this);
195 }
196
197 }
198
199 }