1 | |
package org.apache.maven.project; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.model.Activation; |
23 | |
import org.apache.maven.model.ActivationFile; |
24 | |
import org.apache.maven.model.ActivationProperty; |
25 | |
import org.apache.maven.model.Build; |
26 | |
import org.apache.maven.model.BuildBase; |
27 | |
import org.apache.maven.model.Dependency; |
28 | |
import org.apache.maven.model.DependencyManagement; |
29 | |
import org.apache.maven.model.DeploymentRepository; |
30 | |
import org.apache.maven.model.DistributionManagement; |
31 | |
import org.apache.maven.model.Exclusion; |
32 | |
import org.apache.maven.model.Extension; |
33 | |
import org.apache.maven.model.Model; |
34 | |
import org.apache.maven.model.Parent; |
35 | |
import org.apache.maven.model.Plugin; |
36 | |
import org.apache.maven.model.PluginContainer; |
37 | |
import org.apache.maven.model.PluginExecution; |
38 | |
import org.apache.maven.model.PluginManagement; |
39 | |
import org.apache.maven.model.Profile; |
40 | |
import org.apache.maven.model.Relocation; |
41 | |
import org.apache.maven.model.ReportPlugin; |
42 | |
import org.apache.maven.model.ReportSet; |
43 | |
import org.apache.maven.model.Reporting; |
44 | |
import org.apache.maven.model.Repository; |
45 | |
import org.apache.maven.model.RepositoryBase; |
46 | |
import org.apache.maven.model.RepositoryPolicy; |
47 | |
import org.apache.maven.model.Resource; |
48 | |
import org.apache.maven.model.Site; |
49 | |
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler; |
50 | |
import org.apache.maven.project.inheritance.ModelInheritanceAssembler; |
51 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
52 | |
|
53 | |
import java.util.ArrayList; |
54 | |
import java.util.Iterator; |
55 | |
import java.util.LinkedHashMap; |
56 | |
import java.util.List; |
57 | |
import java.util.Map; |
58 | |
import java.util.Properties; |
59 | |
import java.util.TreeMap; |
60 | |
|
61 | 0 | public final class ModelUtils |
62 | |
{ |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
public static void mergeDuplicatePluginDefinitions( PluginContainer pluginContainer ) |
77 | |
{ |
78 | 0 | if ( pluginContainer == null ) |
79 | |
{ |
80 | 0 | return; |
81 | |
} |
82 | |
|
83 | 0 | List originalPlugins = pluginContainer.getPlugins(); |
84 | |
|
85 | 0 | if ( ( originalPlugins == null ) || originalPlugins.isEmpty() ) |
86 | |
{ |
87 | 0 | return; |
88 | |
} |
89 | |
|
90 | 0 | List normalized = new ArrayList( originalPlugins.size() ); |
91 | |
|
92 | 0 | for ( Iterator it = originalPlugins.iterator(); it.hasNext(); ) |
93 | |
{ |
94 | 0 | Plugin currentPlugin = (Plugin) it.next(); |
95 | |
|
96 | 0 | if ( normalized.contains( currentPlugin ) ) |
97 | |
{ |
98 | 0 | int idx = normalized.indexOf( currentPlugin ); |
99 | 0 | Plugin firstPlugin = (Plugin) normalized.get( idx ); |
100 | |
|
101 | |
|
102 | |
|
103 | 0 | mergePluginDefinitions( currentPlugin, firstPlugin, false ); |
104 | 0 | normalized.set(idx, currentPlugin); |
105 | 0 | } |
106 | |
else |
107 | |
{ |
108 | 0 | normalized.add( currentPlugin ); |
109 | |
} |
110 | 0 | } |
111 | |
|
112 | 0 | pluginContainer.setPlugins( normalized ); |
113 | 0 | } |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
public static void mergePluginLists( PluginContainer child, PluginContainer parent, |
128 | |
boolean handleAsInheritance ) |
129 | |
{ |
130 | 0 | if ( ( child == null ) || ( parent == null ) ) |
131 | |
{ |
132 | |
|
133 | 0 | return; |
134 | |
} |
135 | |
|
136 | 0 | List parentPlugins = parent.getPlugins(); |
137 | |
|
138 | 0 | if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) |
139 | |
{ |
140 | 0 | parentPlugins = new ArrayList( parentPlugins ); |
141 | |
|
142 | |
|
143 | |
|
144 | 0 | if ( handleAsInheritance ) |
145 | |
{ |
146 | 0 | for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) |
147 | |
{ |
148 | 0 | Plugin plugin = (Plugin) it.next(); |
149 | |
|
150 | 0 | String inherited = plugin.getInherited(); |
151 | |
|
152 | 0 | if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() ) |
153 | |
{ |
154 | 0 | it.remove(); |
155 | |
} |
156 | 0 | } |
157 | |
} |
158 | |
|
159 | 0 | List assembledPlugins = new ArrayList(); |
160 | |
|
161 | 0 | Map childPlugins = child.getPluginsAsMap(); |
162 | |
|
163 | 0 | for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) |
164 | |
{ |
165 | 0 | Plugin parentPlugin = (Plugin) it.next(); |
166 | |
|
167 | 0 | String parentInherited = parentPlugin.getInherited(); |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | 0 | if ( !handleAsInheritance || ( parentInherited == null ) || |
175 | |
Boolean.valueOf( parentInherited ).booleanValue() ) |
176 | |
{ |
177 | 0 | Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() ); |
178 | |
|
179 | 0 | if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) |
180 | |
{ |
181 | 0 | Plugin assembledPlugin = childPlugin; |
182 | |
|
183 | 0 | mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); |
184 | |
|
185 | |
|
186 | 0 | assembledPlugins.add( assembledPlugin ); |
187 | |
} |
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | 0 | if ( handleAsInheritance && ( parentInherited == null ) ) |
193 | |
{ |
194 | 0 | parentPlugin.unsetInheritanceApplied(); |
195 | |
} |
196 | |
} |
197 | |
|
198 | |
|
199 | |
|
200 | 0 | List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, |
201 | |
child.getPlugins() ); |
202 | |
|
203 | |
|
204 | 0 | child.setPlugins( results ); |
205 | |
|
206 | 0 | child.flushPluginMap(); |
207 | 0 | } |
208 | |
} |
209 | 0 | } |
210 | |
|
211 | |
public static List orderAfterMerge( List merged, List highPrioritySource, List lowPrioritySource ) |
212 | |
{ |
213 | 0 | List results = new ArrayList(); |
214 | |
|
215 | 0 | if ( !merged.isEmpty() ) |
216 | |
{ |
217 | 0 | results.addAll( merged ); |
218 | |
} |
219 | |
|
220 | 0 | List missingFromResults = new ArrayList(); |
221 | |
|
222 | 0 | List sources = new ArrayList(); |
223 | |
|
224 | 0 | sources.add( highPrioritySource ); |
225 | 0 | sources.add( lowPrioritySource ); |
226 | |
|
227 | 0 | for ( Iterator sourceIterator = sources.iterator(); sourceIterator.hasNext(); ) |
228 | |
{ |
229 | 0 | List source = (List) sourceIterator.next(); |
230 | |
|
231 | 0 | for ( Iterator it = source.iterator(); it.hasNext(); ) |
232 | |
{ |
233 | 0 | Object item = it.next(); |
234 | |
|
235 | 0 | if ( results.contains( item ) ) |
236 | |
{ |
237 | 0 | if ( !missingFromResults.isEmpty() ) |
238 | |
{ |
239 | 0 | int idx = results.indexOf( item ); |
240 | |
|
241 | 0 | if ( idx < 0 ) |
242 | |
{ |
243 | 0 | idx = 0; |
244 | |
} |
245 | |
|
246 | 0 | results.addAll( idx, missingFromResults ); |
247 | |
|
248 | 0 | missingFromResults.clear(); |
249 | 0 | } |
250 | |
} |
251 | |
else |
252 | |
{ |
253 | 0 | missingFromResults.add( item ); |
254 | |
} |
255 | 0 | } |
256 | |
|
257 | 0 | if ( !missingFromResults.isEmpty() ) |
258 | |
{ |
259 | 0 | results.addAll( missingFromResults ); |
260 | |
|
261 | 0 | missingFromResults.clear(); |
262 | |
} |
263 | 0 | } |
264 | |
|
265 | 0 | return results; |
266 | |
} |
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) |
277 | |
{ |
278 | 0 | if ( ( child == null ) || ( parent == null ) ) |
279 | |
{ |
280 | |
|
281 | 0 | return; |
282 | |
} |
283 | |
|
284 | 0 | List parentPlugins = parent.getPlugins(); |
285 | |
|
286 | 0 | if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) |
287 | |
{ |
288 | 0 | parentPlugins = new ArrayList( parentPlugins ); |
289 | |
|
290 | |
|
291 | |
|
292 | 0 | if ( handleAsInheritance ) |
293 | |
{ |
294 | 0 | for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) |
295 | |
{ |
296 | 0 | ReportPlugin plugin = (ReportPlugin) it.next(); |
297 | |
|
298 | 0 | String inherited = plugin.getInherited(); |
299 | |
|
300 | 0 | if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() ) |
301 | |
{ |
302 | 0 | it.remove(); |
303 | |
} |
304 | 0 | } |
305 | |
} |
306 | |
|
307 | 0 | List assembledPlugins = new ArrayList(); |
308 | |
|
309 | 0 | Map childPlugins = child.getReportPluginsAsMap(); |
310 | |
|
311 | 0 | for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) |
312 | |
{ |
313 | 0 | ReportPlugin parentPlugin = (ReportPlugin) it.next(); |
314 | |
|
315 | 0 | String parentInherited = parentPlugin.getInherited(); |
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | 0 | if ( !handleAsInheritance || ( parentInherited == null ) || |
323 | |
Boolean.valueOf( parentInherited ).booleanValue() ) |
324 | |
{ |
325 | 0 | ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() ); |
326 | |
|
327 | 0 | if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) |
328 | |
{ |
329 | 0 | ReportPlugin assembledPlugin = childPlugin; |
330 | |
|
331 | 0 | mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); |
332 | |
|
333 | |
|
334 | 0 | assembledPlugins.add( assembledPlugin ); |
335 | |
} |
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | 0 | if ( handleAsInheritance && ( parentInherited == null ) ) |
341 | |
{ |
342 | 0 | parentPlugin.unsetInheritanceApplied(); |
343 | |
} |
344 | |
} |
345 | |
|
346 | |
|
347 | |
|
348 | 0 | List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, |
349 | |
child.getPlugins() ); |
350 | |
|
351 | 0 | child.setPlugins( results ); |
352 | |
|
353 | 0 | child.flushReportPluginMap(); |
354 | 0 | } |
355 | |
} |
356 | 0 | } |
357 | |
|
358 | |
public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) |
359 | |
{ |
360 | 0 | if ( ( child == null ) || ( parent == null ) ) |
361 | |
{ |
362 | |
|
363 | 0 | return; |
364 | |
} |
365 | |
|
366 | 0 | if ( parent.isExtensions() ) |
367 | |
{ |
368 | 0 | child.setExtensions( true ); |
369 | |
} |
370 | |
|
371 | 0 | if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) |
372 | |
{ |
373 | 0 | child.setVersion( parent.getVersion() ); |
374 | |
} |
375 | |
|
376 | 0 | Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); |
377 | 0 | Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); |
378 | |
|
379 | 0 | childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); |
380 | |
|
381 | 0 | child.setConfiguration( childConfiguration ); |
382 | |
|
383 | 0 | child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) ); |
384 | |
|
385 | |
|
386 | 0 | String parentInherited = parent.getInherited(); |
387 | |
|
388 | 0 | boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue(); |
389 | |
|
390 | 0 | List parentExecutions = parent.getExecutions(); |
391 | |
|
392 | 0 | if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() ) |
393 | |
{ |
394 | 0 | List mergedExecutions = new ArrayList(); |
395 | |
|
396 | 0 | Map assembledExecutions = new TreeMap(); |
397 | |
|
398 | 0 | Map childExecutions = child.getExecutionsAsMap(); |
399 | |
|
400 | 0 | for ( Iterator it = parentExecutions.iterator(); it.hasNext(); ) |
401 | |
{ |
402 | 0 | PluginExecution parentExecution = (PluginExecution) it.next(); |
403 | |
|
404 | 0 | String inherited = parentExecution.getInherited(); |
405 | |
|
406 | 0 | boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() ); |
407 | |
|
408 | 0 | if ( !handleAsInheritance || parentExecInherited ) |
409 | |
{ |
410 | 0 | PluginExecution assembled = parentExecution; |
411 | |
|
412 | 0 | PluginExecution childExecution = (PluginExecution) childExecutions.get( parentExecution.getId() ); |
413 | |
|
414 | 0 | if ( childExecution != null ) |
415 | |
{ |
416 | 0 | mergePluginExecutionDefinitions( childExecution, parentExecution ); |
417 | |
|
418 | 0 | assembled = childExecution; |
419 | |
} |
420 | 0 | else if ( handleAsInheritance && ( parentInherited == null ) ) |
421 | |
{ |
422 | 0 | parentExecution.unsetInheritanceApplied(); |
423 | |
} |
424 | |
|
425 | 0 | assembledExecutions.put( assembled.getId(), assembled ); |
426 | 0 | mergedExecutions.add(assembled); |
427 | |
} |
428 | 0 | } |
429 | |
|
430 | 0 | for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); ) |
431 | |
{ |
432 | 0 | PluginExecution childExecution = (PluginExecution)it.next(); |
433 | |
|
434 | 0 | if ( !assembledExecutions.containsKey( childExecution.getId() ) ) |
435 | |
{ |
436 | 0 | mergedExecutions.add(childExecution); |
437 | |
} |
438 | 0 | } |
439 | |
|
440 | 0 | child.setExecutions(mergedExecutions); |
441 | |
|
442 | 0 | child.flushExecutionMap(); |
443 | |
} |
444 | |
|
445 | 0 | } |
446 | |
|
447 | |
public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, |
448 | |
boolean handleAsInheritance ) |
449 | |
{ |
450 | 0 | if ( ( child == null ) || ( parent == null ) ) |
451 | |
{ |
452 | |
|
453 | 0 | return; |
454 | |
} |
455 | |
|
456 | 0 | if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) |
457 | |
{ |
458 | 0 | child.setVersion( parent.getVersion() ); |
459 | |
} |
460 | |
|
461 | 0 | String parentInherited = parent.getInherited(); |
462 | |
|
463 | 0 | boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue(); |
464 | |
|
465 | |
|
466 | 0 | if ( parentIsInherited ) |
467 | |
{ |
468 | 0 | Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); |
469 | 0 | Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); |
470 | |
|
471 | 0 | childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); |
472 | |
|
473 | 0 | child.setConfiguration( childConfiguration ); |
474 | |
} |
475 | |
|
476 | |
|
477 | 0 | List parentReportSets = parent.getReportSets(); |
478 | |
|
479 | 0 | if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) |
480 | |
{ |
481 | 0 | Map assembledReportSets = new TreeMap(); |
482 | |
|
483 | 0 | Map childReportSets = child.getReportSetsAsMap(); |
484 | |
|
485 | 0 | for ( Iterator it = parentReportSets.iterator(); it.hasNext(); ) |
486 | |
{ |
487 | 0 | ReportSet parentReportSet = (ReportSet) it.next(); |
488 | |
|
489 | 0 | if ( !handleAsInheritance || parentIsInherited ) |
490 | |
{ |
491 | 0 | ReportSet assembledReportSet = parentReportSet; |
492 | |
|
493 | 0 | ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() ); |
494 | |
|
495 | 0 | if ( childReportSet != null ) |
496 | |
{ |
497 | 0 | mergeReportSetDefinitions( childReportSet, parentReportSet ); |
498 | |
|
499 | 0 | assembledReportSet = childReportSet; |
500 | |
} |
501 | 0 | else if ( handleAsInheritance && ( parentInherited == null ) ) |
502 | |
{ |
503 | 0 | parentReportSet.unsetInheritanceApplied(); |
504 | |
} |
505 | |
|
506 | 0 | assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); |
507 | |
} |
508 | 0 | } |
509 | |
|
510 | 0 | for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); ) |
511 | |
{ |
512 | 0 | Map.Entry entry = (Map.Entry) it.next(); |
513 | |
|
514 | 0 | String id = (String) entry.getKey(); |
515 | |
|
516 | 0 | if ( !assembledReportSets.containsKey( id ) ) |
517 | |
{ |
518 | 0 | assembledReportSets.put( id, entry.getValue() ); |
519 | |
} |
520 | 0 | } |
521 | |
|
522 | 0 | child.setReportSets( new ArrayList( assembledReportSets.values() ) ); |
523 | |
|
524 | 0 | child.flushReportSetMap(); |
525 | |
} |
526 | |
|
527 | 0 | } |
528 | |
|
529 | |
private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent ) |
530 | |
{ |
531 | 0 | if ( child.getPhase() == null ) |
532 | |
{ |
533 | 0 | child.setPhase( parent.getPhase() ); |
534 | |
} |
535 | |
|
536 | 0 | List parentGoals = parent.getGoals(); |
537 | 0 | List childGoals = child.getGoals(); |
538 | |
|
539 | 0 | List goals = new ArrayList(); |
540 | |
|
541 | 0 | if ( ( childGoals != null ) && !childGoals.isEmpty() ) |
542 | |
{ |
543 | 0 | goals.addAll( childGoals ); |
544 | |
} |
545 | |
|
546 | 0 | if ( parentGoals != null ) |
547 | |
{ |
548 | 0 | for ( Iterator goalIterator = parentGoals.iterator(); goalIterator.hasNext(); ) |
549 | |
{ |
550 | 0 | String goal = (String) goalIterator.next(); |
551 | |
|
552 | 0 | if ( !goals.contains( goal ) ) |
553 | |
{ |
554 | 0 | goals.add( goal ); |
555 | |
} |
556 | 0 | } |
557 | |
} |
558 | |
|
559 | 0 | child.setGoals( goals ); |
560 | |
|
561 | 0 | Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); |
562 | 0 | Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); |
563 | |
|
564 | 0 | childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); |
565 | |
|
566 | 0 | child.setConfiguration( childConfiguration ); |
567 | 0 | } |
568 | |
|
569 | |
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) |
570 | |
{ |
571 | 0 | List parentReports = parent.getReports(); |
572 | 0 | List childReports = child.getReports(); |
573 | |
|
574 | 0 | List reports = new ArrayList(); |
575 | |
|
576 | 0 | if ( ( childReports != null ) && !childReports.isEmpty() ) |
577 | |
{ |
578 | 0 | reports.addAll( childReports ); |
579 | |
} |
580 | |
|
581 | 0 | if ( parentReports != null ) |
582 | |
{ |
583 | 0 | for ( Iterator i = parentReports.iterator(); i.hasNext(); ) |
584 | |
{ |
585 | 0 | String report = (String) i.next(); |
586 | |
|
587 | 0 | if ( !reports.contains( report ) ) |
588 | |
{ |
589 | 0 | reports.add( report ); |
590 | |
} |
591 | 0 | } |
592 | |
} |
593 | |
|
594 | 0 | child.setReports( reports ); |
595 | |
|
596 | 0 | Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); |
597 | 0 | Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); |
598 | |
|
599 | 0 | childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); |
600 | |
|
601 | 0 | child.setConfiguration( childConfiguration ); |
602 | 0 | } |
603 | |
|
604 | |
public static Model cloneModel( Model model ) |
605 | |
{ |
606 | |
|
607 | 0 | Model newModel = new Model(); |
608 | 0 | ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler(); |
609 | 0 | newModel.setModelVersion( model.getModelVersion() ); |
610 | 0 | newModel.setName( model.getName() ); |
611 | 0 | newModel.setParent( cloneParent( model.getParent() ) ); |
612 | 0 | newModel.setVersion( model.getVersion() ); |
613 | 0 | newModel.setArtifactId( model.getArtifactId() ); |
614 | 0 | newModel.setProperties( new Properties( model.getProperties() ) ); |
615 | 0 | newModel.setGroupId( model.getGroupId() ); |
616 | 0 | newModel.setPackaging( model.getPackaging() ); |
617 | 0 | newModel.setModules( cloneModules( model.getModules() ) ); |
618 | |
|
619 | 0 | newModel.setProfiles( cloneProfiles( model.getProfiles() ) ); |
620 | |
|
621 | 0 | assembler.copyModel( newModel, model ); |
622 | |
|
623 | 0 | return newModel; |
624 | |
} |
625 | |
|
626 | |
private static List cloneProfiles( List profiles ) |
627 | |
{ |
628 | 0 | if ( profiles == null ) |
629 | |
{ |
630 | 0 | return profiles; |
631 | |
} |
632 | |
|
633 | 0 | List newProfiles = new ArrayList( profiles.size() ); |
634 | |
|
635 | 0 | for ( Iterator it = profiles.iterator(); it.hasNext(); ) |
636 | |
{ |
637 | 0 | Profile profile = (Profile) it.next(); |
638 | |
|
639 | 0 | Profile newProfile = new Profile(); |
640 | |
|
641 | 0 | newProfile.setId( profile.getId() ); |
642 | |
|
643 | 0 | newProfile.setActivation( cloneProfileActivation( profile.getActivation() ) ); |
644 | |
|
645 | 0 | newProfile.setBuild( cloneProfileBuild( profile.getBuild() ) ); |
646 | |
|
647 | 0 | newProfile.setDependencies( cloneProfileDependencies( profile.getDependencies() ) ); |
648 | |
|
649 | 0 | DependencyManagement dm = profile.getDependencyManagement(); |
650 | |
|
651 | 0 | if ( dm != null ) |
652 | |
{ |
653 | 0 | DependencyManagement newDM = new DependencyManagement(); |
654 | |
|
655 | 0 | newDM.setDependencies( cloneProfileDependencies( dm.getDependencies() ) ); |
656 | |
|
657 | 0 | newProfile.setDependencyManagement( newDM ); |
658 | |
} |
659 | |
|
660 | 0 | newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile |
661 | |
.getDistributionManagement() ) ); |
662 | |
|
663 | 0 | List modules = profile.getModules(); |
664 | |
|
665 | 0 | if ( ( modules != null ) && !modules.isEmpty() ) |
666 | |
{ |
667 | 0 | newProfile.setModules( new ArrayList( modules ) ); |
668 | |
} |
669 | |
|
670 | 0 | newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) ); |
671 | |
|
672 | 0 | Properties props = profile.getProperties(); |
673 | |
|
674 | 0 | if ( props != null ) |
675 | |
{ |
676 | 0 | Properties newProps = new Properties(); |
677 | 0 | newProps.putAll( props ); |
678 | |
|
679 | 0 | newProfile.setProperties( newProps ); |
680 | |
} |
681 | |
|
682 | 0 | newProfile.setReporting( cloneProfileReporting( profile.getReporting() ) ); |
683 | |
|
684 | 0 | newProfile.setReports( profile.getReports() ); |
685 | |
|
686 | 0 | newProfile.setRepositories( cloneProfileRepositories( profile.getRepositories() ) ); |
687 | |
|
688 | 0 | newProfile.setSource( profile.getSource() ); |
689 | |
|
690 | 0 | newProfiles.add( newProfile ); |
691 | 0 | } |
692 | |
|
693 | 0 | return newProfiles; |
694 | |
} |
695 | |
|
696 | |
private static Reporting cloneProfileReporting( Reporting reporting ) |
697 | |
{ |
698 | 0 | Reporting newR = null; |
699 | |
|
700 | 0 | if ( reporting != null ) |
701 | |
{ |
702 | 0 | newR = new Reporting(); |
703 | |
|
704 | 0 | newR.setOutputDirectory( reporting.getOutputDirectory() ); |
705 | |
|
706 | 0 | List plugins = reporting.getPlugins(); |
707 | |
|
708 | 0 | if ( plugins != null ) |
709 | |
{ |
710 | 0 | List newP = new ArrayList( plugins.size() ); |
711 | |
|
712 | 0 | for ( Iterator it = plugins.iterator(); it.hasNext(); ) |
713 | |
{ |
714 | 0 | ReportPlugin plugin = (ReportPlugin) it.next(); |
715 | |
|
716 | 0 | ReportPlugin newPlugin = new ReportPlugin(); |
717 | |
|
718 | 0 | newPlugin.setArtifactId( plugin.getArtifactId() ); |
719 | 0 | newPlugin.setGroupId( plugin.getGroupId() ); |
720 | 0 | newPlugin.setVersion( plugin.getVersion() ); |
721 | 0 | newPlugin.setInherited( plugin.getInherited() ); |
722 | 0 | newPlugin.setReportSets( cloneReportSets( plugin.getReportSets() ) ); |
723 | |
|
724 | |
|
725 | 0 | newPlugin.setConfiguration( plugin.getConfiguration() ); |
726 | |
|
727 | 0 | newP.add( newPlugin ); |
728 | 0 | } |
729 | |
|
730 | 0 | newR.setPlugins( newP ); |
731 | |
} |
732 | |
} |
733 | |
|
734 | 0 | return newR; |
735 | |
} |
736 | |
|
737 | |
private static List cloneReportSets( List sets ) |
738 | |
{ |
739 | 0 | List newSets = null; |
740 | |
|
741 | 0 | if ( sets != null ) |
742 | |
{ |
743 | 0 | newSets = new ArrayList( sets.size() ); |
744 | |
|
745 | 0 | for ( Iterator it = sets.iterator(); it.hasNext(); ) |
746 | |
{ |
747 | 0 | ReportSet set = (ReportSet) it.next(); |
748 | |
|
749 | 0 | ReportSet newSet = new ReportSet(); |
750 | |
|
751 | |
|
752 | 0 | newSet.setConfiguration( set.getConfiguration() ); |
753 | |
|
754 | 0 | newSet.setId( set.getId() ); |
755 | 0 | newSet.setInherited( set.getInherited() ); |
756 | |
|
757 | 0 | newSet.setReports( new ArrayList( set.getReports() ) ); |
758 | |
|
759 | 0 | newSets.add( newSet ); |
760 | 0 | } |
761 | |
} |
762 | |
|
763 | 0 | return newSets; |
764 | |
} |
765 | |
|
766 | |
private static List cloneProfileRepositories( List repos ) |
767 | |
{ |
768 | 0 | List newRepos = null; |
769 | |
|
770 | 0 | if ( repos != null ) |
771 | |
{ |
772 | 0 | newRepos = new ArrayList( repos.size() ); |
773 | |
|
774 | 0 | for ( Iterator it = repos.iterator(); it.hasNext(); ) |
775 | |
{ |
776 | 0 | Repository repo = (Repository) it.next(); |
777 | |
|
778 | 0 | Repository newRepo = new Repository(); |
779 | |
|
780 | 0 | newRepo.setId( repo.getId() ); |
781 | 0 | newRepo.setLayout( repo.getLayout() ); |
782 | 0 | newRepo.setName( repo.getName() ); |
783 | |
|
784 | 0 | RepositoryPolicy releasePolicy = repo.getReleases(); |
785 | |
|
786 | 0 | if ( releasePolicy != null ) |
787 | |
{ |
788 | 0 | RepositoryPolicy newPolicy = new RepositoryPolicy(); |
789 | 0 | newPolicy.setEnabled( releasePolicy.isEnabled() ); |
790 | 0 | newPolicy.setChecksumPolicy( releasePolicy.getChecksumPolicy() ); |
791 | 0 | newPolicy.setUpdatePolicy( releasePolicy.getUpdatePolicy() ); |
792 | |
|
793 | 0 | newRepo.setReleases( newPolicy ); |
794 | |
} |
795 | |
|
796 | 0 | RepositoryPolicy snapPolicy = repo.getSnapshots(); |
797 | |
|
798 | 0 | if ( snapPolicy != null ) |
799 | |
{ |
800 | 0 | RepositoryPolicy newPolicy = new RepositoryPolicy(); |
801 | 0 | newPolicy.setEnabled( snapPolicy.isEnabled() ); |
802 | 0 | newPolicy.setChecksumPolicy( snapPolicy.getChecksumPolicy() ); |
803 | 0 | newPolicy.setUpdatePolicy( snapPolicy.getUpdatePolicy() ); |
804 | |
|
805 | 0 | newRepo.setSnapshots( newPolicy ); |
806 | |
} |
807 | |
|
808 | 0 | newRepo.setUrl( repo.getUrl() ); |
809 | |
|
810 | 0 | newRepos.add( newRepo ); |
811 | 0 | } |
812 | |
} |
813 | |
|
814 | 0 | return newRepos; |
815 | |
} |
816 | |
|
817 | |
private static DistributionManagement cloneProfileDistributionManagement( DistributionManagement dm ) |
818 | |
{ |
819 | 0 | DistributionManagement newDM = null; |
820 | |
|
821 | 0 | if ( dm != null ) |
822 | |
{ |
823 | 0 | newDM = new DistributionManagement(); |
824 | |
|
825 | 0 | newDM.setDownloadUrl( dm.getDownloadUrl() ); |
826 | 0 | newDM.setStatus( dm.getStatus() ); |
827 | |
|
828 | 0 | Relocation relocation = dm.getRelocation(); |
829 | |
|
830 | 0 | if ( relocation != null ) |
831 | |
{ |
832 | 0 | Relocation newR = new Relocation(); |
833 | |
|
834 | 0 | newR.setArtifactId( relocation.getArtifactId() ); |
835 | 0 | newR.setGroupId( relocation.getGroupId() ); |
836 | 0 | newR.setMessage( relocation.getMessage() ); |
837 | 0 | newR.setVersion( relocation.getVersion() ); |
838 | |
|
839 | 0 | newDM.setRelocation( newR ); |
840 | |
} |
841 | |
|
842 | 0 | DeploymentRepository repo = dm.getRepository(); |
843 | |
|
844 | 0 | if ( repo != null ) |
845 | |
{ |
846 | 0 | DeploymentRepository newRepo = new DeploymentRepository(); |
847 | |
|
848 | 0 | newRepo.setId( repo.getId() ); |
849 | 0 | newRepo.setLayout( repo.getLayout() ); |
850 | 0 | newRepo.setName( repo.getName() ); |
851 | 0 | newRepo.setUrl( repo.getUrl() ); |
852 | 0 | newRepo.setUniqueVersion( repo.isUniqueVersion() ); |
853 | |
|
854 | 0 | newDM.setRepository( newRepo ); |
855 | |
} |
856 | |
|
857 | 0 | Site site = dm.getSite(); |
858 | |
|
859 | 0 | if ( site != null ) |
860 | |
{ |
861 | 0 | Site newSite = new Site(); |
862 | |
|
863 | 0 | newSite.setId( site.getId() ); |
864 | 0 | newSite.setName( site.getName() ); |
865 | 0 | newSite.setUrl( site.getUrl() ); |
866 | |
|
867 | 0 | newDM.setSite( newSite ); |
868 | |
} |
869 | |
|
870 | 0 | DeploymentRepository sRepo = dm.getSnapshotRepository(); |
871 | |
|
872 | 0 | if ( sRepo != null ) |
873 | |
{ |
874 | 0 | DeploymentRepository newRepo = new DeploymentRepository(); |
875 | |
|
876 | 0 | newRepo.setId( sRepo.getId() ); |
877 | 0 | newRepo.setLayout( sRepo.getLayout() ); |
878 | 0 | newRepo.setName( sRepo.getName() ); |
879 | 0 | newRepo.setUrl( sRepo.getUrl() ); |
880 | 0 | newRepo.setUniqueVersion( sRepo.isUniqueVersion() ); |
881 | |
|
882 | 0 | newDM.setSnapshotRepository( newRepo ); |
883 | |
} |
884 | |
} |
885 | |
|
886 | 0 | return newDM; |
887 | |
} |
888 | |
|
889 | |
private static List cloneProfileDependencies( List dependencies ) |
890 | |
{ |
891 | 0 | List newDependencies = null; |
892 | |
|
893 | 0 | if ( dependencies != null ) |
894 | |
{ |
895 | 0 | newDependencies = new ArrayList( dependencies.size() ); |
896 | |
|
897 | 0 | for ( Iterator it = dependencies.iterator(); it.hasNext(); ) |
898 | |
{ |
899 | 0 | Dependency dep = (Dependency) it.next(); |
900 | |
|
901 | 0 | Dependency newDep = new Dependency(); |
902 | |
|
903 | 0 | newDep.setArtifactId( dep.getArtifactId() ); |
904 | 0 | newDep.setClassifier( dep.getClassifier() ); |
905 | 0 | newDep.setExclusions( cloneDependencyExclusions( dep.getExclusions() ) ); |
906 | 0 | newDep.setGroupId( dep.getGroupId() ); |
907 | 0 | newDep.setScope( dep.getScope() ); |
908 | 0 | newDep.setSystemPath( dep.getSystemPath() ); |
909 | 0 | newDep.setType( dep.getType() ); |
910 | 0 | newDep.setVersion( dep.getVersion() ); |
911 | |
|
912 | 0 | newDependencies.add( newDep ); |
913 | 0 | } |
914 | |
} |
915 | |
|
916 | 0 | return newDependencies; |
917 | |
} |
918 | |
|
919 | |
private static List cloneDependencyExclusions( List ex ) |
920 | |
{ |
921 | 0 | List newEx = null; |
922 | |
|
923 | 0 | if ( ex != null ) |
924 | |
{ |
925 | 0 | newEx = new ArrayList( ex.size() ); |
926 | |
|
927 | 0 | for ( Iterator it = ex.iterator(); it.hasNext(); ) |
928 | |
{ |
929 | 0 | Exclusion exclusion = (Exclusion) it.next(); |
930 | |
|
931 | 0 | Exclusion newExclusion = new Exclusion(); |
932 | |
|
933 | 0 | newExclusion.setArtifactId( exclusion.getArtifactId() ); |
934 | 0 | newExclusion.setGroupId( exclusion.getGroupId() ); |
935 | |
|
936 | 0 | newEx.add( newExclusion ); |
937 | 0 | } |
938 | |
} |
939 | |
|
940 | 0 | return newEx; |
941 | |
} |
942 | |
|
943 | |
private static BuildBase cloneProfileBuild( BuildBase build ) |
944 | |
{ |
945 | 0 | BuildBase newBuild = null; |
946 | 0 | if ( build != null ) |
947 | |
{ |
948 | 0 | newBuild = new BuildBase(); |
949 | |
|
950 | 0 | newBuild.setDefaultGoal( build.getDefaultGoal() ); |
951 | 0 | newBuild.setDirectory( build.getDirectory() ); |
952 | 0 | newBuild.setFinalName( build.getFinalName() ); |
953 | |
|
954 | 0 | newBuild.setPluginManagement( cloneProfilePluginManagement( build.getPluginManagement() ) ); |
955 | 0 | newBuild.setPlugins( cloneProfilePlugins( build.getPlugins() ) ); |
956 | 0 | newBuild.setResources( cloneProfileResources( build.getResources() ) ); |
957 | 0 | newBuild.setTestResources( cloneProfileResources( build.getTestResources() ) ); |
958 | |
} |
959 | |
|
960 | 0 | return newBuild; |
961 | |
} |
962 | |
|
963 | |
private static List cloneProfileResources( List resources ) |
964 | |
{ |
965 | 0 | List newResources = null; |
966 | |
|
967 | 0 | if ( resources != null ) |
968 | |
{ |
969 | 0 | newResources = new ArrayList( resources.size() ); |
970 | |
|
971 | 0 | for ( Iterator it = resources.iterator(); it.hasNext(); ) |
972 | |
{ |
973 | 0 | Resource resource = (Resource) it.next(); |
974 | |
|
975 | 0 | Resource newResource = new Resource(); |
976 | |
|
977 | 0 | newResource.setDirectory( resource.getDirectory() ); |
978 | 0 | newResource.setExcludes( new ArrayList( resource.getExcludes() ) ); |
979 | 0 | newResource.setFiltering( resource.isFiltering() ); |
980 | 0 | newResource.setIncludes( new ArrayList( resource.getIncludes() ) ); |
981 | 0 | newResource.setTargetPath( resource.getTargetPath() ); |
982 | |
|
983 | 0 | newResources.add( newResource ); |
984 | 0 | } |
985 | |
} |
986 | |
|
987 | 0 | return newResources; |
988 | |
} |
989 | |
|
990 | |
private static PluginManagement cloneProfilePluginManagement( PluginManagement pluginManagement ) |
991 | |
{ |
992 | 0 | PluginManagement newPM = null; |
993 | |
|
994 | 0 | if ( pluginManagement != null ) |
995 | |
{ |
996 | 0 | newPM = new PluginManagement(); |
997 | |
|
998 | 0 | List plugins = pluginManagement.getPlugins(); |
999 | |
|
1000 | 0 | newPM.setPlugins( cloneProfilePlugins( plugins ) ); |
1001 | |
} |
1002 | |
|
1003 | 0 | return newPM; |
1004 | |
} |
1005 | |
|
1006 | |
private static List cloneProfilePlugins( List plugins ) |
1007 | |
{ |
1008 | 0 | List newPlugins = null; |
1009 | |
|
1010 | 0 | if ( plugins != null ) |
1011 | |
{ |
1012 | 0 | newPlugins = new ArrayList( plugins.size() ); |
1013 | |
|
1014 | 0 | for ( Iterator it = plugins.iterator(); it.hasNext(); ) |
1015 | |
{ |
1016 | 0 | Plugin plugin = (Plugin) it.next(); |
1017 | |
|
1018 | 0 | Plugin newPlugin = new Plugin(); |
1019 | |
|
1020 | 0 | newPlugin.setArtifactId( plugin.getArtifactId() ); |
1021 | 0 | newPlugin.setExtensions( plugin.isExtensions() ); |
1022 | 0 | newPlugin.setGroupId( plugin.getGroupId() ); |
1023 | 0 | newPlugin.setInherited( plugin.getInherited() ); |
1024 | 0 | newPlugin.setVersion( plugin.getVersion() ); |
1025 | |
|
1026 | |
|
1027 | 0 | newPlugin.setConfiguration( plugin.getConfiguration() ); |
1028 | |
|
1029 | 0 | newPlugin.setExecutions( cloneExecutions( plugin.getExecutions() ) ); |
1030 | |
|
1031 | 0 | newPlugins.add( newPlugin ); |
1032 | 0 | } |
1033 | |
} |
1034 | |
|
1035 | 0 | return newPlugins; |
1036 | |
} |
1037 | |
|
1038 | |
private static List cloneExecutions( List executions ) |
1039 | |
{ |
1040 | 0 | List newExecs = null; |
1041 | |
|
1042 | 0 | if ( executions != null ) |
1043 | |
{ |
1044 | 0 | newExecs = new ArrayList( executions.size() ); |
1045 | |
|
1046 | 0 | for ( Iterator it = executions.iterator(); it.hasNext(); ) |
1047 | |
{ |
1048 | 0 | PluginExecution exec = (PluginExecution) it.next(); |
1049 | |
|
1050 | 0 | PluginExecution newExec = new PluginExecution(); |
1051 | |
|
1052 | |
|
1053 | 0 | newExec.setConfiguration( exec.getConfiguration() ); |
1054 | |
|
1055 | 0 | newExec.setId( exec.getId() ); |
1056 | 0 | newExec.setInherited( exec.getInherited() ); |
1057 | 0 | newExec.setPhase( exec.getPhase() ); |
1058 | |
|
1059 | 0 | List goals = exec.getGoals(); |
1060 | |
|
1061 | 0 | if ( ( goals != null ) && !goals.isEmpty() ) |
1062 | |
{ |
1063 | 0 | newExec.setGoals( new ArrayList( goals ) ); |
1064 | |
} |
1065 | |
|
1066 | 0 | newExecs.add( newExec ); |
1067 | 0 | } |
1068 | |
} |
1069 | |
|
1070 | 0 | return newExecs; |
1071 | |
} |
1072 | |
|
1073 | |
private static Activation cloneProfileActivation( Activation activation ) |
1074 | |
{ |
1075 | 0 | Activation newActivation = null; |
1076 | 0 | if ( activation != null ) |
1077 | |
{ |
1078 | 0 | newActivation = new Activation(); |
1079 | |
|
1080 | 0 | newActivation.setActiveByDefault( activation.isActiveByDefault() ); |
1081 | |
|
1082 | 0 | ActivationFile af = activation.getFile(); |
1083 | |
|
1084 | 0 | if ( af != null ) |
1085 | |
{ |
1086 | 0 | ActivationFile afNew = new ActivationFile(); |
1087 | 0 | afNew.setExists( af.getExists() ); |
1088 | 0 | afNew.setMissing( af.getMissing() ); |
1089 | |
|
1090 | 0 | newActivation.setFile( afNew ); |
1091 | |
} |
1092 | |
|
1093 | 0 | newActivation.setJdk( activation.getJdk() ); |
1094 | |
|
1095 | 0 | ActivationProperty ap = activation.getProperty(); |
1096 | |
|
1097 | 0 | if ( ap != null ) |
1098 | |
{ |
1099 | 0 | ActivationProperty newAp = new ActivationProperty(); |
1100 | |
|
1101 | 0 | newAp.setName( ap.getName() ); |
1102 | 0 | newAp.setValue( ap.getValue() ); |
1103 | |
|
1104 | 0 | newActivation.setProperty( newAp ); |
1105 | |
} |
1106 | |
} |
1107 | |
|
1108 | 0 | return newActivation; |
1109 | |
} |
1110 | |
|
1111 | |
private static List cloneModules( List modules ) |
1112 | |
{ |
1113 | 0 | if ( modules == null ) |
1114 | |
{ |
1115 | 0 | return modules; |
1116 | |
} |
1117 | 0 | return new ArrayList( modules ); |
1118 | |
} |
1119 | |
|
1120 | |
private static Parent cloneParent( Parent parent ) |
1121 | |
{ |
1122 | 0 | if ( parent == null ) |
1123 | |
{ |
1124 | 0 | return parent; |
1125 | |
} |
1126 | |
|
1127 | 0 | Parent newParent = new Parent(); |
1128 | 0 | newParent.setArtifactId( parent.getArtifactId() ); |
1129 | 0 | newParent.setGroupId( parent.getGroupId() ); |
1130 | 0 | newParent.setRelativePath( parent.getRelativePath() ); |
1131 | 0 | newParent.setVersion( parent.getVersion() ); |
1132 | 0 | return newParent; |
1133 | |
} |
1134 | |
|
1135 | |
public static List mergeRepositoryLists( List dominant, List recessive ) |
1136 | |
{ |
1137 | 0 | List repositories = new ArrayList(); |
1138 | |
|
1139 | 0 | for ( Iterator it = dominant.iterator(); it.hasNext(); ) |
1140 | |
{ |
1141 | 0 | Repository repository = (Repository) it.next(); |
1142 | |
|
1143 | 0 | repositories.add( repository ); |
1144 | 0 | } |
1145 | |
|
1146 | 0 | for ( Iterator it = recessive.iterator(); it.hasNext(); ) |
1147 | |
{ |
1148 | 0 | Repository repository = (Repository) it.next(); |
1149 | |
|
1150 | 0 | if ( !repositories.contains( repository ) ) |
1151 | |
{ |
1152 | 0 | repositories.add( repository ); |
1153 | |
} |
1154 | 0 | } |
1155 | |
|
1156 | 0 | return repositories; |
1157 | |
} |
1158 | |
|
1159 | |
public static void mergeExtensionLists( Build childBuild, Build parentBuild ) |
1160 | |
{ |
1161 | 0 | Map extMap = new LinkedHashMap(); |
1162 | |
|
1163 | 0 | List ext = childBuild.getExtensions(); |
1164 | |
|
1165 | 0 | if ( ext != null ) |
1166 | |
{ |
1167 | 0 | for ( Iterator it = ext.iterator(); it.hasNext(); ) |
1168 | |
{ |
1169 | 0 | Extension extension = (Extension) it.next(); |
1170 | 0 | extMap.put( extension.getKey(), extension ); |
1171 | 0 | } |
1172 | |
} |
1173 | |
|
1174 | 0 | ext = parentBuild.getExtensions(); |
1175 | |
|
1176 | 0 | if ( ext != null ) |
1177 | |
{ |
1178 | 0 | for ( Iterator it = ext.iterator(); it.hasNext(); ) |
1179 | |
{ |
1180 | 0 | Extension extension = (Extension) it.next(); |
1181 | 0 | if ( !extMap.containsKey( extension.getKey() ) ) |
1182 | |
{ |
1183 | 0 | extMap.put( extension.getKey(), extension ); |
1184 | |
} |
1185 | 0 | } |
1186 | |
} |
1187 | |
|
1188 | 0 | childBuild.setExtensions( new ArrayList( extMap.values() ) ); |
1189 | 0 | } |
1190 | |
|
1191 | |
public static void mergeResourceLists( List childResources, List parentResources ) |
1192 | |
{ |
1193 | 0 | for ( Iterator i = parentResources.iterator(); i.hasNext(); ) |
1194 | |
{ |
1195 | 0 | Resource r = (Resource) i.next(); |
1196 | 0 | if ( !childResources.contains( r ) ) |
1197 | |
{ |
1198 | 0 | childResources.add( r ); |
1199 | |
} |
1200 | 0 | } |
1201 | 0 | } |
1202 | |
|
1203 | |
public static void mergeFilterLists( List childFilters, List parentFilters ) |
1204 | |
{ |
1205 | 0 | for ( Iterator i = parentFilters.iterator(); i.hasNext(); ) |
1206 | |
{ |
1207 | 0 | String f = (String) i.next(); |
1208 | 0 | if ( !childFilters.contains( f ) ) |
1209 | |
{ |
1210 | 0 | childFilters.add( f ); |
1211 | |
} |
1212 | 0 | } |
1213 | 0 | } |
1214 | |
|
1215 | |
public static List mergeDependencyList( List child, List parent ) |
1216 | |
{ |
1217 | 0 | Map depsMap = new LinkedHashMap(); |
1218 | |
|
1219 | 0 | if ( child != null ) |
1220 | |
{ |
1221 | 0 | for ( Iterator it = child.iterator(); it.hasNext(); ) |
1222 | |
{ |
1223 | 0 | Dependency dependency = (Dependency) it.next(); |
1224 | 0 | depsMap.put( dependency.getManagementKey(), dependency ); |
1225 | 0 | } |
1226 | |
} |
1227 | |
|
1228 | 0 | if ( parent != null ) |
1229 | |
{ |
1230 | 0 | for ( Iterator it = parent.iterator(); it.hasNext(); ) |
1231 | |
{ |
1232 | 0 | Dependency dependency = (Dependency) it.next(); |
1233 | 0 | if ( !depsMap.containsKey( dependency.getManagementKey() ) ) |
1234 | |
{ |
1235 | 0 | depsMap.put( dependency.getManagementKey(), dependency ); |
1236 | |
} |
1237 | 0 | } |
1238 | |
} |
1239 | |
|
1240 | 0 | return new ArrayList( depsMap.values() ); |
1241 | |
} |
1242 | |
|
1243 | |
} |