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 java.io.File; |
23 | |
import java.io.IOException; |
24 | |
import java.io.Writer; |
25 | |
import java.util.ArrayList; |
26 | |
import java.util.Collections; |
27 | |
import java.util.HashMap; |
28 | |
import java.util.Iterator; |
29 | |
import java.util.List; |
30 | |
import java.util.Map; |
31 | |
import java.util.Properties; |
32 | |
import java.util.Set; |
33 | |
|
34 | |
import org.apache.maven.artifact.Artifact; |
35 | |
import org.apache.maven.artifact.ArtifactUtils; |
36 | |
import org.apache.maven.artifact.DependencyResolutionRequiredException; |
37 | |
import org.apache.maven.artifact.versioning.ManagedVersionMap; |
38 | |
import org.apache.maven.artifact.factory.ArtifactFactory; |
39 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
40 | |
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; |
41 | |
import org.apache.maven.model.Build; |
42 | |
import org.apache.maven.model.CiManagement; |
43 | |
import org.apache.maven.model.Contributor; |
44 | |
import org.apache.maven.model.Dependency; |
45 | |
import org.apache.maven.model.DependencyManagement; |
46 | |
import org.apache.maven.model.Developer; |
47 | |
import org.apache.maven.model.DistributionManagement; |
48 | |
import org.apache.maven.model.IssueManagement; |
49 | |
import org.apache.maven.model.License; |
50 | |
import org.apache.maven.model.MailingList; |
51 | |
import org.apache.maven.model.Model; |
52 | |
import org.apache.maven.model.Organization; |
53 | |
import org.apache.maven.model.Plugin; |
54 | |
import org.apache.maven.model.PluginExecution; |
55 | |
import org.apache.maven.model.PluginManagement; |
56 | |
import org.apache.maven.model.Prerequisites; |
57 | |
import org.apache.maven.model.ReportPlugin; |
58 | |
import org.apache.maven.model.ReportSet; |
59 | |
import org.apache.maven.model.Reporting; |
60 | |
import org.apache.maven.model.Resource; |
61 | |
import org.apache.maven.model.Scm; |
62 | |
import org.apache.maven.model.io.xpp3.MavenXpp3Writer; |
63 | |
import org.apache.maven.project.artifact.ActiveProjectArtifact; |
64 | |
import org.apache.maven.project.artifact.InvalidDependencyVersionException; |
65 | |
import org.apache.maven.project.artifact.MavenMetadataSource; |
66 | |
import org.apache.maven.project.overlay.BuildOverlay; |
67 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public class MavenProject |
83 | |
implements Cloneable |
84 | |
{ |
85 | |
public static final String EMPTY_PROJECT_GROUP_ID = "unknown"; |
86 | |
|
87 | |
public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project"; |
88 | |
|
89 | |
public static final String EMPTY_PROJECT_VERSION = "0"; |
90 | |
|
91 | |
private Model model; |
92 | |
|
93 | |
private MavenProject parent; |
94 | |
|
95 | |
private File file; |
96 | |
|
97 | |
private Set artifacts; |
98 | |
|
99 | |
private Artifact parentArtifact; |
100 | |
|
101 | |
private Set pluginArtifacts; |
102 | |
|
103 | |
private List remoteArtifactRepositories; |
104 | |
|
105 | 0 | private List collectedProjects = Collections.EMPTY_LIST; |
106 | |
|
107 | |
private List attachedArtifacts; |
108 | |
|
109 | |
private MavenProject executionProject; |
110 | |
|
111 | 0 | private List compileSourceRoots = new ArrayList(); |
112 | |
|
113 | 0 | private List testCompileSourceRoots = new ArrayList(); |
114 | |
|
115 | 0 | private List scriptSourceRoots = new ArrayList(); |
116 | |
|
117 | |
private List pluginArtifactRepositories; |
118 | |
|
119 | |
private ArtifactRepository releaseArtifactRepository; |
120 | |
|
121 | |
private ArtifactRepository snapshotArtifactRepository; |
122 | |
|
123 | 0 | private List activeProfiles = new ArrayList(); |
124 | |
|
125 | |
private Set dependencyArtifacts; |
126 | |
|
127 | |
private Artifact artifact; |
128 | |
|
129 | |
|
130 | |
private Map artifactMap; |
131 | |
|
132 | |
private Model originalModel; |
133 | |
|
134 | |
private Map pluginArtifactMap; |
135 | |
|
136 | |
private Set reportArtifacts; |
137 | |
|
138 | |
private Map reportArtifactMap; |
139 | |
|
140 | |
private Set extensionArtifacts; |
141 | |
|
142 | |
private Map extensionArtifactMap; |
143 | |
|
144 | |
private Map managedVersionMap; |
145 | |
|
146 | 0 | private Map projectReferences = new HashMap(); |
147 | |
|
148 | |
private Build buildOverlay; |
149 | |
|
150 | |
private boolean executionRoot; |
151 | |
|
152 | |
private Map moduleAdjustments; |
153 | |
|
154 | |
public MavenProject() |
155 | 0 | { |
156 | 0 | Model model = new Model(); |
157 | |
|
158 | 0 | model.setGroupId( EMPTY_PROJECT_GROUP_ID ); |
159 | 0 | model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID ); |
160 | 0 | model.setVersion( EMPTY_PROJECT_VERSION ); |
161 | |
|
162 | 0 | this.setModel( model ); |
163 | 0 | } |
164 | |
|
165 | |
public MavenProject( Model model ) |
166 | 0 | { |
167 | 0 | this.setModel( model ); |
168 | 0 | } |
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
public MavenProject( MavenProject project ) |
174 | 0 | { |
175 | 0 | deepCopy( project ); |
176 | 0 | } |
177 | |
|
178 | |
private final void deepCopy(MavenProject project){ |
179 | |
|
180 | |
|
181 | |
|
182 | 0 | setFile( project.getFile() ); |
183 | |
|
184 | |
|
185 | |
|
186 | 0 | if ( project.getDependencyArtifacts() != null ) |
187 | |
{ |
188 | 0 | setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); |
189 | |
} |
190 | |
|
191 | 0 | if ( project.getArtifacts() != null ) |
192 | |
{ |
193 | 0 | setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); |
194 | |
} |
195 | |
|
196 | 0 | if ( project.getPluginArtifacts() != null ) |
197 | |
{ |
198 | 0 | setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) ); |
199 | |
} |
200 | |
|
201 | 0 | if ( project.getReportArtifacts() != null ) |
202 | |
{ |
203 | 0 | setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) ); |
204 | |
} |
205 | |
|
206 | 0 | if ( project.getExtensionArtifacts() != null ) |
207 | |
{ |
208 | 0 | setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) ); |
209 | |
} |
210 | |
|
211 | 0 | setParentArtifact( ( project.getParentArtifact() ) ); |
212 | |
|
213 | 0 | if ( project.getRemoteArtifactRepositories() != null ) |
214 | |
{ |
215 | 0 | setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) ); |
216 | |
} |
217 | |
|
218 | 0 | if ( project.getPluginArtifactRepositories() != null ) |
219 | |
{ |
220 | 0 | setPluginArtifactRepositories( ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) ); |
221 | |
} |
222 | |
|
223 | 0 | if ( project.getCollectedProjects() != null ) |
224 | |
{ |
225 | 0 | setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) ); |
226 | |
} |
227 | |
|
228 | 0 | if ( project.getActiveProfiles() != null ) |
229 | |
{ |
230 | 0 | setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) ); |
231 | |
} |
232 | |
|
233 | 0 | if ( project.getAttachedArtifacts() != null ) |
234 | |
{ |
235 | |
|
236 | 0 | setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) ); |
237 | |
} |
238 | |
|
239 | 0 | if ( project.getCompileSourceRoots() != null ) |
240 | |
{ |
241 | |
|
242 | 0 | setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) ); |
243 | |
} |
244 | |
|
245 | 0 | if ( project.getTestCompileSourceRoots() != null ) |
246 | |
{ |
247 | 0 | setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) ); |
248 | |
} |
249 | |
|
250 | 0 | if ( project.getScriptSourceRoots() != null ) |
251 | |
{ |
252 | 0 | setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) ); |
253 | |
} |
254 | |
|
255 | 0 | setModel( ( ModelUtils.cloneModel( project.getModel() ) ) ); |
256 | |
|
257 | 0 | if ( project.getOriginalModel() != null ) |
258 | |
{ |
259 | 0 | setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) ); |
260 | |
} |
261 | |
|
262 | 0 | setExecutionRoot( project.isExecutionRoot() ); |
263 | |
|
264 | 0 | if ( project.getArtifact() != null ) |
265 | |
{ |
266 | 0 | setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) ); |
267 | |
} |
268 | |
|
269 | 0 | if ( project.getManagedVersionMap() != null ) |
270 | |
{ |
271 | 0 | setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) ); |
272 | |
} |
273 | |
|
274 | 0 | if ( project.getReleaseArtifactRepository() != null ) |
275 | |
{ |
276 | 0 | setReleaseArtifactRepository( project.getReleaseArtifactRepository() ); |
277 | |
} |
278 | |
|
279 | 0 | if ( project.getSnapshotArtifactRepository() != null ) |
280 | |
{ |
281 | 0 | setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() ); |
282 | |
} |
283 | 0 | } |
284 | |
|
285 | |
public String getModulePathAdjustment( MavenProject moduleProject ) throws IOException |
286 | |
{ |
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | 0 | String module = moduleProject.getArtifactId(); |
295 | |
|
296 | 0 | File moduleFile = moduleProject.getFile(); |
297 | |
|
298 | 0 | if ( moduleFile != null ) |
299 | |
{ |
300 | 0 | File moduleDir = moduleFile.getCanonicalFile().getParentFile(); |
301 | |
|
302 | 0 | module = moduleDir.getName(); |
303 | |
} |
304 | |
|
305 | 0 | if ( moduleAdjustments == null ) |
306 | |
{ |
307 | 0 | moduleAdjustments = new HashMap(); |
308 | |
|
309 | 0 | List modules = getModules(); |
310 | 0 | if ( modules != null ) |
311 | |
{ |
312 | 0 | for ( Iterator it = modules.iterator(); it.hasNext(); ) |
313 | |
{ |
314 | 0 | String modulePath = (String) it.next(); |
315 | 0 | String moduleName = modulePath; |
316 | |
|
317 | 0 | if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) ) |
318 | |
{ |
319 | 0 | moduleName = moduleName.substring( 0, moduleName.length() - 1 ); |
320 | |
} |
321 | |
|
322 | 0 | int lastSlash = moduleName.lastIndexOf( '/' ); |
323 | |
|
324 | 0 | if ( lastSlash < 0 ) |
325 | |
{ |
326 | 0 | lastSlash = moduleName.lastIndexOf( '\\' ); |
327 | |
} |
328 | |
|
329 | 0 | String adjustment = null; |
330 | |
|
331 | 0 | if ( lastSlash > -1 ) |
332 | |
{ |
333 | 0 | moduleName = moduleName.substring( lastSlash + 1 ); |
334 | 0 | adjustment = modulePath.substring( 0, lastSlash ); |
335 | |
} |
336 | |
|
337 | 0 | moduleAdjustments.put( moduleName, adjustment ); |
338 | 0 | } |
339 | |
} |
340 | |
} |
341 | |
|
342 | 0 | return (String) moduleAdjustments.get( module ); |
343 | |
} |
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
public Artifact getArtifact() |
350 | |
{ |
351 | 0 | return artifact; |
352 | |
} |
353 | |
|
354 | |
public void setArtifact( Artifact artifact ) |
355 | |
{ |
356 | 0 | this.artifact = artifact; |
357 | 0 | } |
358 | |
|
359 | |
|
360 | |
public Model getModel() |
361 | |
{ |
362 | 0 | return model; |
363 | |
} |
364 | |
|
365 | |
public MavenProject getParent() |
366 | |
{ |
367 | 0 | return parent; |
368 | |
} |
369 | |
|
370 | |
public void setParent( MavenProject parent ) |
371 | |
{ |
372 | 0 | this.parent = parent; |
373 | 0 | } |
374 | |
|
375 | |
public void setRemoteArtifactRepositories( List remoteArtifactRepositories ) |
376 | |
{ |
377 | 0 | this.remoteArtifactRepositories = remoteArtifactRepositories; |
378 | 0 | } |
379 | |
|
380 | |
public List getRemoteArtifactRepositories() |
381 | |
{ |
382 | 0 | return remoteArtifactRepositories; |
383 | |
} |
384 | |
|
385 | |
public boolean hasParent() |
386 | |
{ |
387 | 0 | return getParent() != null; |
388 | |
} |
389 | |
|
390 | |
public File getFile() |
391 | |
{ |
392 | 0 | return file; |
393 | |
} |
394 | |
|
395 | |
public void setFile( File file ) |
396 | |
{ |
397 | 0 | this.file = file; |
398 | 0 | } |
399 | |
|
400 | |
public File getBasedir() |
401 | |
{ |
402 | 0 | if ( getFile() != null ) |
403 | |
{ |
404 | 0 | return getFile().getParentFile(); |
405 | |
} |
406 | |
else |
407 | |
{ |
408 | |
|
409 | 0 | return null; |
410 | |
} |
411 | |
} |
412 | |
|
413 | |
public void setDependencies( List dependencies ) |
414 | |
{ |
415 | 0 | getModel().setDependencies( dependencies ); |
416 | 0 | } |
417 | |
|
418 | |
public List getDependencies() |
419 | |
{ |
420 | 0 | return getModel().getDependencies(); |
421 | |
} |
422 | |
|
423 | |
public DependencyManagement getDependencyManagement() |
424 | |
{ |
425 | 0 | return getModel().getDependencyManagement(); |
426 | |
} |
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
public void addCompileSourceRoot( String path ) |
433 | |
{ |
434 | 0 | if ( path != null ) |
435 | |
{ |
436 | 0 | path = path.trim(); |
437 | 0 | if ( path.length() != 0 ) |
438 | |
{ |
439 | 0 | if ( !getCompileSourceRoots().contains( path ) ) |
440 | |
{ |
441 | 0 | getCompileSourceRoots().add( path ); |
442 | |
} |
443 | |
} |
444 | |
} |
445 | 0 | } |
446 | |
|
447 | |
public void addScriptSourceRoot( String path ) |
448 | |
{ |
449 | 0 | if ( path != null ) |
450 | |
{ |
451 | 0 | path = path.trim(); |
452 | 0 | if ( path.length() != 0 ) |
453 | |
{ |
454 | 0 | if ( !getScriptSourceRoots().contains( path ) ) |
455 | |
{ |
456 | 0 | getScriptSourceRoots().add( path ); |
457 | |
} |
458 | |
} |
459 | |
} |
460 | 0 | } |
461 | |
|
462 | |
public void addTestCompileSourceRoot( String path ) |
463 | |
{ |
464 | 0 | if ( path != null ) |
465 | |
{ |
466 | 0 | path = path.trim(); |
467 | 0 | if ( path.length() != 0 ) |
468 | |
{ |
469 | 0 | if ( !getTestCompileSourceRoots().contains( path ) ) |
470 | |
{ |
471 | 0 | getTestCompileSourceRoots().add( path ); |
472 | |
} |
473 | |
} |
474 | |
} |
475 | 0 | } |
476 | |
|
477 | |
public List getCompileSourceRoots() |
478 | |
{ |
479 | 0 | return compileSourceRoots; |
480 | |
} |
481 | |
|
482 | |
public List getScriptSourceRoots() |
483 | |
{ |
484 | 0 | return scriptSourceRoots; |
485 | |
} |
486 | |
|
487 | |
public List getTestCompileSourceRoots() |
488 | |
{ |
489 | 0 | return testCompileSourceRoots; |
490 | |
} |
491 | |
|
492 | |
public List getCompileClasspathElements() |
493 | |
throws DependencyResolutionRequiredException |
494 | |
{ |
495 | 0 | List list = new ArrayList( getArtifacts().size() ); |
496 | |
|
497 | 0 | list.add( getBuild().getOutputDirectory() ); |
498 | |
|
499 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
500 | |
{ |
501 | 0 | Artifact a = (Artifact) i.next(); |
502 | |
|
503 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
504 | |
{ |
505 | |
|
506 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || |
507 | |
Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
508 | |
{ |
509 | 0 | addArtifactPath( a, list ); |
510 | |
} |
511 | |
} |
512 | 0 | } |
513 | 0 | return list; |
514 | |
} |
515 | |
|
516 | |
public List getCompileArtifacts() |
517 | |
{ |
518 | 0 | List list = new ArrayList( getArtifacts().size() ); |
519 | |
|
520 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
521 | |
{ |
522 | 0 | Artifact a = (Artifact) i.next(); |
523 | |
|
524 | |
|
525 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
526 | |
{ |
527 | |
|
528 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || |
529 | |
Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
530 | |
{ |
531 | 0 | list.add( a ); |
532 | |
} |
533 | |
} |
534 | 0 | } |
535 | 0 | return list; |
536 | |
} |
537 | |
|
538 | |
public List getCompileDependencies() |
539 | |
{ |
540 | 0 | Set artifacts = getArtifacts(); |
541 | |
|
542 | 0 | if ( artifacts == null || artifacts.isEmpty() ) |
543 | |
{ |
544 | 0 | return Collections.EMPTY_LIST; |
545 | |
} |
546 | |
|
547 | 0 | List list = new ArrayList( artifacts.size() ); |
548 | |
|
549 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
550 | |
{ |
551 | 0 | Artifact a = (Artifact) i.next(); |
552 | |
|
553 | |
|
554 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || |
555 | |
Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
556 | |
{ |
557 | 0 | Dependency dependency = new Dependency(); |
558 | |
|
559 | 0 | dependency.setArtifactId( a.getArtifactId() ); |
560 | 0 | dependency.setGroupId( a.getGroupId() ); |
561 | 0 | dependency.setVersion( a.getVersion() ); |
562 | 0 | dependency.setScope( a.getScope() ); |
563 | 0 | dependency.setType( a.getType() ); |
564 | 0 | dependency.setClassifier( a.getClassifier() ); |
565 | |
|
566 | 0 | list.add( dependency ); |
567 | |
} |
568 | 0 | } |
569 | 0 | return list; |
570 | |
} |
571 | |
|
572 | |
public List getTestClasspathElements() |
573 | |
throws DependencyResolutionRequiredException |
574 | |
{ |
575 | 0 | List list = new ArrayList( getArtifacts().size() + 1 ); |
576 | |
|
577 | 0 | list.add( getBuild().getTestOutputDirectory() ); |
578 | |
|
579 | 0 | list.add( getBuild().getOutputDirectory() ); |
580 | |
|
581 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
582 | |
{ |
583 | 0 | Artifact a = (Artifact) i.next(); |
584 | |
|
585 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
586 | |
{ |
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | |
|
594 | 0 | File file = a.getFile(); |
595 | 0 | if ( file == null ) |
596 | |
{ |
597 | 0 | throw new DependencyResolutionRequiredException( a ); |
598 | |
} |
599 | 0 | list.add( file.getPath() ); |
600 | |
} |
601 | 0 | } |
602 | 0 | return list; |
603 | |
} |
604 | |
|
605 | |
public List getTestArtifacts() |
606 | |
{ |
607 | 0 | List list = new ArrayList( getArtifacts().size() ); |
608 | |
|
609 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
610 | |
{ |
611 | 0 | Artifact a = (Artifact) i.next(); |
612 | |
|
613 | |
|
614 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
615 | |
{ |
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | 0 | list.add( a ); |
626 | |
} |
627 | 0 | } |
628 | 0 | return list; |
629 | |
} |
630 | |
|
631 | |
public List getTestDependencies() |
632 | |
{ |
633 | 0 | Set artifacts = getArtifacts(); |
634 | |
|
635 | 0 | if ( artifacts == null || artifacts.isEmpty() ) |
636 | |
{ |
637 | 0 | return Collections.EMPTY_LIST; |
638 | |
} |
639 | |
|
640 | 0 | List list = new ArrayList( artifacts.size() ); |
641 | |
|
642 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
643 | |
{ |
644 | 0 | Artifact a = (Artifact) i.next(); |
645 | |
|
646 | |
|
647 | |
|
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | 0 | Dependency dependency = new Dependency(); |
655 | |
|
656 | 0 | dependency.setArtifactId( a.getArtifactId() ); |
657 | 0 | dependency.setGroupId( a.getGroupId() ); |
658 | 0 | dependency.setVersion( a.getVersion() ); |
659 | 0 | dependency.setScope( a.getScope() ); |
660 | 0 | dependency.setType( a.getType() ); |
661 | 0 | dependency.setClassifier( a.getClassifier() ); |
662 | |
|
663 | 0 | list.add( dependency ); |
664 | 0 | } |
665 | 0 | return list; |
666 | |
} |
667 | |
|
668 | |
public List getRuntimeClasspathElements() |
669 | |
throws DependencyResolutionRequiredException |
670 | |
{ |
671 | 0 | List list = new ArrayList( getArtifacts().size() + 1 ); |
672 | |
|
673 | 0 | list.add( getBuild().getOutputDirectory() ); |
674 | |
|
675 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
676 | |
{ |
677 | 0 | Artifact a = (Artifact) i.next(); |
678 | |
|
679 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
680 | |
{ |
681 | |
|
682 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) |
683 | |
{ |
684 | 0 | File file = a.getFile(); |
685 | 0 | if ( file == null ) |
686 | |
{ |
687 | 0 | throw new DependencyResolutionRequiredException( a ); |
688 | |
} |
689 | 0 | list.add( file.getPath() ); |
690 | |
} |
691 | |
} |
692 | 0 | } |
693 | 0 | return list; |
694 | |
} |
695 | |
|
696 | |
public List getRuntimeArtifacts() |
697 | |
{ |
698 | 0 | List list = new ArrayList( getArtifacts().size() ); |
699 | |
|
700 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
701 | |
{ |
702 | 0 | Artifact a = (Artifact) i.next(); |
703 | |
|
704 | |
|
705 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
706 | |
{ |
707 | |
|
708 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) |
709 | |
{ |
710 | 0 | list.add( a ); |
711 | |
} |
712 | |
} |
713 | 0 | } |
714 | 0 | return list; |
715 | |
} |
716 | |
|
717 | |
public List getRuntimeDependencies() |
718 | |
{ |
719 | 0 | Set artifacts = getArtifacts(); |
720 | |
|
721 | 0 | if ( artifacts == null || artifacts.isEmpty() ) |
722 | |
{ |
723 | 0 | return Collections.EMPTY_LIST; |
724 | |
} |
725 | |
|
726 | 0 | List list = new ArrayList( artifacts.size() ); |
727 | |
|
728 | 0 | for ( Iterator i = artifacts.iterator(); i.hasNext(); ) |
729 | |
{ |
730 | 0 | Artifact a = (Artifact) i.next(); |
731 | |
|
732 | |
|
733 | 0 | if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) |
734 | |
{ |
735 | 0 | Dependency dependency = new Dependency(); |
736 | |
|
737 | 0 | dependency.setArtifactId( a.getArtifactId() ); |
738 | 0 | dependency.setGroupId( a.getGroupId() ); |
739 | 0 | dependency.setVersion( a.getVersion() ); |
740 | 0 | dependency.setScope( a.getScope() ); |
741 | 0 | dependency.setType( a.getType() ); |
742 | 0 | dependency.setClassifier( a.getClassifier() ); |
743 | |
|
744 | 0 | list.add( dependency ); |
745 | |
} |
746 | 0 | } |
747 | 0 | return list; |
748 | |
} |
749 | |
|
750 | |
public List getSystemClasspathElements() |
751 | |
throws DependencyResolutionRequiredException |
752 | |
{ |
753 | 0 | List list = new ArrayList( getArtifacts().size() ); |
754 | |
|
755 | 0 | list.add( getBuild().getOutputDirectory() ); |
756 | |
|
757 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
758 | |
{ |
759 | 0 | Artifact a = (Artifact) i.next(); |
760 | |
|
761 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
762 | |
{ |
763 | |
|
764 | 0 | if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
765 | |
{ |
766 | 0 | addArtifactPath( a, list ); |
767 | |
} |
768 | |
} |
769 | 0 | } |
770 | 0 | return list; |
771 | |
} |
772 | |
|
773 | |
public List getSystemArtifacts() |
774 | |
{ |
775 | 0 | List list = new ArrayList( getArtifacts().size() ); |
776 | |
|
777 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
778 | |
{ |
779 | 0 | Artifact a = (Artifact) i.next(); |
780 | |
|
781 | |
|
782 | 0 | if ( a.getArtifactHandler().isAddedToClasspath() ) |
783 | |
{ |
784 | |
|
785 | 0 | if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
786 | |
{ |
787 | 0 | list.add( a ); |
788 | |
} |
789 | |
} |
790 | 0 | } |
791 | 0 | return list; |
792 | |
} |
793 | |
|
794 | |
public List getSystemDependencies() |
795 | |
{ |
796 | 0 | Set artifacts = getArtifacts(); |
797 | |
|
798 | 0 | if ( artifacts == null || artifacts.isEmpty() ) |
799 | |
{ |
800 | 0 | return Collections.EMPTY_LIST; |
801 | |
} |
802 | |
|
803 | 0 | List list = new ArrayList( artifacts.size() ); |
804 | |
|
805 | 0 | for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) |
806 | |
{ |
807 | 0 | Artifact a = (Artifact) i.next(); |
808 | |
|
809 | |
|
810 | 0 | if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) |
811 | |
{ |
812 | 0 | Dependency dependency = new Dependency(); |
813 | |
|
814 | 0 | dependency.setArtifactId( a.getArtifactId() ); |
815 | 0 | dependency.setGroupId( a.getGroupId() ); |
816 | 0 | dependency.setVersion( a.getVersion() ); |
817 | 0 | dependency.setScope( a.getScope() ); |
818 | 0 | dependency.setType( a.getType() ); |
819 | 0 | dependency.setClassifier( a.getClassifier() ); |
820 | |
|
821 | 0 | list.add( dependency ); |
822 | |
} |
823 | 0 | } |
824 | 0 | return list; |
825 | |
} |
826 | |
|
827 | |
|
828 | |
|
829 | |
|
830 | |
|
831 | |
public void setModelVersion( String pomVersion ) |
832 | |
{ |
833 | 0 | getModel().setModelVersion( pomVersion ); |
834 | 0 | } |
835 | |
|
836 | |
public String getModelVersion() |
837 | |
{ |
838 | 0 | return getModel().getModelVersion(); |
839 | |
} |
840 | |
|
841 | |
public String getId() |
842 | |
{ |
843 | 0 | return getModel().getId(); |
844 | |
} |
845 | |
|
846 | |
public void setGroupId( String groupId ) |
847 | |
{ |
848 | 0 | getModel().setGroupId( groupId ); |
849 | 0 | } |
850 | |
|
851 | |
public String getGroupId() |
852 | |
{ |
853 | 0 | String groupId = getModel().getGroupId(); |
854 | |
|
855 | 0 | if ( ( groupId == null ) && ( getModel().getParent() != null ) ) |
856 | |
{ |
857 | 0 | groupId = getModel().getParent().getGroupId(); |
858 | |
} |
859 | |
|
860 | 0 | return groupId; |
861 | |
} |
862 | |
|
863 | |
public void setArtifactId( String artifactId ) |
864 | |
{ |
865 | 0 | getModel().setArtifactId( artifactId ); |
866 | 0 | } |
867 | |
|
868 | |
public String getArtifactId() |
869 | |
{ |
870 | 0 | return getModel().getArtifactId(); |
871 | |
} |
872 | |
|
873 | |
public void setName( String name ) |
874 | |
{ |
875 | 0 | getModel().setName( name ); |
876 | 0 | } |
877 | |
|
878 | |
public String getName() |
879 | |
{ |
880 | |
|
881 | 0 | if ( getModel().getName() != null ) |
882 | |
{ |
883 | 0 | return getModel().getName(); |
884 | |
} |
885 | |
else |
886 | |
{ |
887 | 0 | return "Unnamed - " + getId(); |
888 | |
} |
889 | |
} |
890 | |
|
891 | |
public void setVersion( String version ) |
892 | |
{ |
893 | 0 | getModel().setVersion( version ); |
894 | 0 | } |
895 | |
|
896 | |
public String getVersion() |
897 | |
{ |
898 | 0 | String version = getModel().getVersion(); |
899 | |
|
900 | 0 | if ( ( version == null ) && ( getModel().getParent() != null ) ) |
901 | |
{ |
902 | 0 | version = getModel().getParent().getVersion(); |
903 | |
} |
904 | |
|
905 | 0 | return version; |
906 | |
} |
907 | |
|
908 | |
public String getPackaging() |
909 | |
{ |
910 | 0 | return getModel().getPackaging(); |
911 | |
} |
912 | |
|
913 | |
public void setPackaging( String packaging ) |
914 | |
{ |
915 | 0 | getModel().setPackaging( packaging ); |
916 | 0 | } |
917 | |
|
918 | |
public void setInceptionYear( String inceptionYear ) |
919 | |
{ |
920 | 0 | getModel().setInceptionYear( inceptionYear ); |
921 | 0 | } |
922 | |
|
923 | |
public String getInceptionYear() |
924 | |
{ |
925 | 0 | return getModel().getInceptionYear(); |
926 | |
} |
927 | |
|
928 | |
public void setUrl( String url ) |
929 | |
{ |
930 | 0 | getModel().setUrl( url ); |
931 | 0 | } |
932 | |
|
933 | |
public String getUrl() |
934 | |
{ |
935 | 0 | return getModel().getUrl(); |
936 | |
} |
937 | |
|
938 | |
public Prerequisites getPrerequisites() |
939 | |
{ |
940 | 0 | return getModel().getPrerequisites(); |
941 | |
} |
942 | |
|
943 | |
public void setIssueManagement( IssueManagement issueManagement ) |
944 | |
{ |
945 | 0 | getModel().setIssueManagement( issueManagement ); |
946 | 0 | } |
947 | |
|
948 | |
public CiManagement getCiManagement() |
949 | |
{ |
950 | 0 | return getModel().getCiManagement(); |
951 | |
} |
952 | |
|
953 | |
public void setCiManagement( CiManagement ciManagement ) |
954 | |
{ |
955 | 0 | getModel().setCiManagement( ciManagement ); |
956 | 0 | } |
957 | |
|
958 | |
public IssueManagement getIssueManagement() |
959 | |
{ |
960 | 0 | return getModel().getIssueManagement(); |
961 | |
} |
962 | |
|
963 | |
public void setDistributionManagement( DistributionManagement distributionManagement ) |
964 | |
{ |
965 | 0 | getModel().setDistributionManagement( distributionManagement ); |
966 | 0 | } |
967 | |
|
968 | |
public DistributionManagement getDistributionManagement() |
969 | |
{ |
970 | 0 | return getModel().getDistributionManagement(); |
971 | |
} |
972 | |
|
973 | |
public void setDescription( String description ) |
974 | |
{ |
975 | 0 | getModel().setDescription( description ); |
976 | 0 | } |
977 | |
|
978 | |
public String getDescription() |
979 | |
{ |
980 | 0 | return getModel().getDescription(); |
981 | |
} |
982 | |
|
983 | |
public void setOrganization( Organization organization ) |
984 | |
{ |
985 | 0 | getModel().setOrganization( organization ); |
986 | 0 | } |
987 | |
|
988 | |
public Organization getOrganization() |
989 | |
{ |
990 | 0 | return getModel().getOrganization(); |
991 | |
} |
992 | |
|
993 | |
public void setScm( Scm scm ) |
994 | |
{ |
995 | 0 | getModel().setScm( scm ); |
996 | 0 | } |
997 | |
|
998 | |
public Scm getScm() |
999 | |
{ |
1000 | 0 | return getModel().getScm(); |
1001 | |
} |
1002 | |
|
1003 | |
public void setMailingLists( List mailingLists ) |
1004 | |
{ |
1005 | 0 | getModel().setMailingLists( mailingLists ); |
1006 | 0 | } |
1007 | |
|
1008 | |
public List getMailingLists() |
1009 | |
{ |
1010 | 0 | return getModel().getMailingLists(); |
1011 | |
} |
1012 | |
|
1013 | |
public void addMailingList( MailingList mailingList ) |
1014 | |
{ |
1015 | 0 | getModel().addMailingList( mailingList ); |
1016 | 0 | } |
1017 | |
|
1018 | |
public void setDevelopers( List developers ) |
1019 | |
{ |
1020 | 0 | getModel().setDevelopers( developers ); |
1021 | 0 | } |
1022 | |
|
1023 | |
public List getDevelopers() |
1024 | |
{ |
1025 | 0 | return getModel().getDevelopers(); |
1026 | |
} |
1027 | |
|
1028 | |
public void addDeveloper( Developer developer ) |
1029 | |
{ |
1030 | 0 | getModel().addDeveloper( developer ); |
1031 | 0 | } |
1032 | |
|
1033 | |
public void setContributors( List contributors ) |
1034 | |
{ |
1035 | 0 | getModel().setContributors( contributors ); |
1036 | 0 | } |
1037 | |
|
1038 | |
public List getContributors() |
1039 | |
{ |
1040 | 0 | return getModel().getContributors(); |
1041 | |
} |
1042 | |
|
1043 | |
public void addContributor( Contributor contributor ) |
1044 | |
{ |
1045 | 0 | getModel().addContributor( contributor ); |
1046 | 0 | } |
1047 | |
|
1048 | |
public void setBuild( Build build ) |
1049 | |
{ |
1050 | 0 | this.buildOverlay = new BuildOverlay( build ); |
1051 | |
|
1052 | 0 | getModel().setBuild( build ); |
1053 | 0 | } |
1054 | |
|
1055 | |
public Build getBuild() |
1056 | |
{ |
1057 | 0 | if ( buildOverlay == null ) |
1058 | |
{ |
1059 | 0 | buildOverlay = new BuildOverlay( getModelBuild() ); |
1060 | |
} |
1061 | |
|
1062 | 0 | return buildOverlay; |
1063 | |
} |
1064 | |
|
1065 | |
public List getResources() |
1066 | |
{ |
1067 | 0 | return getBuild().getResources(); |
1068 | |
} |
1069 | |
|
1070 | |
public List getTestResources() |
1071 | |
{ |
1072 | 0 | return getBuild().getTestResources(); |
1073 | |
} |
1074 | |
|
1075 | |
public void addResource( Resource resource ) |
1076 | |
{ |
1077 | 0 | getBuild().addResource( resource ); |
1078 | 0 | } |
1079 | |
|
1080 | |
public void addTestResource( Resource testResource ) |
1081 | |
{ |
1082 | 0 | getBuild().addTestResource( testResource ); |
1083 | 0 | } |
1084 | |
|
1085 | |
public void setReporting( Reporting reporting ) |
1086 | |
{ |
1087 | 0 | getModel().setReporting( reporting ); |
1088 | 0 | } |
1089 | |
|
1090 | |
public Reporting getReporting() |
1091 | |
{ |
1092 | 0 | return getModel().getReporting(); |
1093 | |
} |
1094 | |
|
1095 | |
public void setLicenses( List licenses ) |
1096 | |
{ |
1097 | 0 | getModel().setLicenses( licenses ); |
1098 | 0 | } |
1099 | |
|
1100 | |
public List getLicenses() |
1101 | |
{ |
1102 | 0 | return getModel().getLicenses(); |
1103 | |
} |
1104 | |
|
1105 | |
public void addLicense( License license ) |
1106 | |
{ |
1107 | 0 | getModel().addLicense( license ); |
1108 | 0 | } |
1109 | |
|
1110 | |
public void setArtifacts( Set artifacts ) |
1111 | |
{ |
1112 | 0 | this.artifacts = artifacts; |
1113 | |
|
1114 | |
|
1115 | 0 | this.artifactMap = null; |
1116 | 0 | } |
1117 | |
|
1118 | |
|
1119 | |
|
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
|
1125 | |
public Set getArtifacts() |
1126 | |
{ |
1127 | 0 | return artifacts == null ? Collections.EMPTY_SET : artifacts; |
1128 | |
} |
1129 | |
|
1130 | |
public Map getArtifactMap() |
1131 | |
{ |
1132 | 0 | if ( artifactMap == null ) |
1133 | |
{ |
1134 | 0 | artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); |
1135 | |
} |
1136 | |
|
1137 | 0 | return artifactMap; |
1138 | |
} |
1139 | |
|
1140 | |
public void setPluginArtifacts( Set pluginArtifacts ) |
1141 | |
{ |
1142 | 0 | this.pluginArtifacts = pluginArtifacts; |
1143 | |
|
1144 | 0 | this.pluginArtifactMap = null; |
1145 | 0 | } |
1146 | |
|
1147 | |
public Set getPluginArtifacts() |
1148 | |
{ |
1149 | 0 | return pluginArtifacts; |
1150 | |
} |
1151 | |
|
1152 | |
public Map getPluginArtifactMap() |
1153 | |
{ |
1154 | 0 | if ( pluginArtifactMap == null ) |
1155 | |
{ |
1156 | 0 | pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() ); |
1157 | |
} |
1158 | |
|
1159 | 0 | return pluginArtifactMap; |
1160 | |
} |
1161 | |
|
1162 | |
public void setReportArtifacts( Set reportArtifacts ) |
1163 | |
{ |
1164 | 0 | this.reportArtifacts = reportArtifacts; |
1165 | |
|
1166 | 0 | this.reportArtifactMap = null; |
1167 | 0 | } |
1168 | |
|
1169 | |
public Set getReportArtifacts() |
1170 | |
{ |
1171 | 0 | return reportArtifacts; |
1172 | |
} |
1173 | |
|
1174 | |
public Map getReportArtifactMap() |
1175 | |
{ |
1176 | 0 | if ( reportArtifactMap == null ) |
1177 | |
{ |
1178 | 0 | reportArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getReportArtifacts() ); |
1179 | |
} |
1180 | |
|
1181 | 0 | return reportArtifactMap; |
1182 | |
} |
1183 | |
|
1184 | |
public void setExtensionArtifacts( Set extensionArtifacts ) |
1185 | |
{ |
1186 | 0 | this.extensionArtifacts = extensionArtifacts; |
1187 | |
|
1188 | 0 | this.extensionArtifactMap = null; |
1189 | 0 | } |
1190 | |
|
1191 | |
public Set getExtensionArtifacts() |
1192 | |
{ |
1193 | 0 | return this.extensionArtifacts; |
1194 | |
} |
1195 | |
|
1196 | |
public Map getExtensionArtifactMap() |
1197 | |
{ |
1198 | 0 | if ( extensionArtifactMap == null ) |
1199 | |
{ |
1200 | 0 | extensionArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getExtensionArtifacts() ); |
1201 | |
} |
1202 | |
|
1203 | 0 | return extensionArtifactMap; |
1204 | |
} |
1205 | |
|
1206 | |
public void setParentArtifact( Artifact parentArtifact ) |
1207 | |
{ |
1208 | 0 | this.parentArtifact = parentArtifact; |
1209 | 0 | } |
1210 | |
|
1211 | |
public Artifact getParentArtifact() |
1212 | |
{ |
1213 | 0 | return parentArtifact; |
1214 | |
} |
1215 | |
|
1216 | |
public List getRepositories() |
1217 | |
{ |
1218 | 0 | return getModel().getRepositories(); |
1219 | |
} |
1220 | |
|
1221 | |
|
1222 | |
|
1223 | |
|
1224 | |
|
1225 | |
public List getReportPlugins() |
1226 | |
{ |
1227 | 0 | if ( getModel().getReporting() == null ) |
1228 | |
{ |
1229 | 0 | return null; |
1230 | |
} |
1231 | 0 | return getModel().getReporting().getPlugins(); |
1232 | |
|
1233 | |
} |
1234 | |
|
1235 | |
public List getBuildPlugins() |
1236 | |
{ |
1237 | 0 | if ( getModel().getBuild() == null ) |
1238 | |
{ |
1239 | 0 | return null; |
1240 | |
} |
1241 | 0 | return getModel().getBuild().getPlugins(); |
1242 | |
} |
1243 | |
|
1244 | |
public List getModules() |
1245 | |
{ |
1246 | 0 | return getModel().getModules(); |
1247 | |
} |
1248 | |
|
1249 | |
public PluginManagement getPluginManagement() |
1250 | |
{ |
1251 | 0 | PluginManagement pluginMgmt = null; |
1252 | |
|
1253 | 0 | Build build = getModel().getBuild(); |
1254 | 0 | if ( build != null ) |
1255 | |
{ |
1256 | 0 | pluginMgmt = build.getPluginManagement(); |
1257 | |
} |
1258 | |
|
1259 | 0 | return pluginMgmt; |
1260 | |
} |
1261 | |
|
1262 | |
private Build getModelBuild() |
1263 | |
{ |
1264 | 0 | Build build = getModel().getBuild(); |
1265 | |
|
1266 | 0 | if ( build == null ) |
1267 | |
{ |
1268 | 0 | build = new Build(); |
1269 | |
|
1270 | 0 | getModel().setBuild( build ); |
1271 | |
} |
1272 | |
|
1273 | 0 | return build; |
1274 | |
} |
1275 | |
|
1276 | |
public void addPlugin( Plugin plugin ) |
1277 | |
{ |
1278 | 0 | Build build = getModelBuild(); |
1279 | |
|
1280 | 0 | if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) ) |
1281 | |
{ |
1282 | 0 | injectPluginManagementInfo( plugin ); |
1283 | |
|
1284 | 0 | build.addPlugin( plugin ); |
1285 | 0 | build.flushPluginMap(); |
1286 | |
} |
1287 | 0 | } |
1288 | |
|
1289 | |
public void injectPluginManagementInfo( Plugin plugin ) |
1290 | |
{ |
1291 | 0 | PluginManagement pm = getModelBuild().getPluginManagement(); |
1292 | |
|
1293 | 0 | if ( pm != null ) |
1294 | |
{ |
1295 | 0 | Map pmByKey = pm.getPluginsAsMap(); |
1296 | |
|
1297 | 0 | String pluginKey = plugin.getKey(); |
1298 | |
|
1299 | 0 | if ( pmByKey != null && pmByKey.containsKey( pluginKey ) ) |
1300 | |
{ |
1301 | 0 | Plugin pmPlugin = (Plugin) pmByKey.get( pluginKey ); |
1302 | |
|
1303 | 0 | ModelUtils.mergePluginDefinitions( plugin, pmPlugin, false ); |
1304 | |
} |
1305 | |
} |
1306 | 0 | } |
1307 | |
|
1308 | |
public List getCollectedProjects() |
1309 | |
{ |
1310 | 0 | return collectedProjects; |
1311 | |
} |
1312 | |
|
1313 | |
public void setCollectedProjects( List collectedProjects ) |
1314 | |
{ |
1315 | 0 | this.collectedProjects = collectedProjects; |
1316 | 0 | } |
1317 | |
|
1318 | |
public void setPluginArtifactRepositories( List pluginArtifactRepositories ) |
1319 | |
{ |
1320 | 0 | this.pluginArtifactRepositories = pluginArtifactRepositories; |
1321 | 0 | } |
1322 | |
|
1323 | |
|
1324 | |
|
1325 | |
|
1326 | |
|
1327 | |
public List getPluginArtifactRepositories() |
1328 | |
{ |
1329 | 0 | return pluginArtifactRepositories; |
1330 | |
} |
1331 | |
|
1332 | |
public ArtifactRepository getDistributionManagementArtifactRepository() |
1333 | |
{ |
1334 | 0 | return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository() |
1335 | |
: getReleaseArtifactRepository(); |
1336 | |
} |
1337 | |
|
1338 | |
public List getPluginRepositories() |
1339 | |
{ |
1340 | 0 | return getModel().getPluginRepositories(); |
1341 | |
} |
1342 | |
|
1343 | |
public void setActiveProfiles( List activeProfiles ) |
1344 | |
{ |
1345 | 0 | this.activeProfiles.addAll( activeProfiles ); |
1346 | 0 | } |
1347 | |
|
1348 | |
public List getActiveProfiles() |
1349 | |
{ |
1350 | 0 | return activeProfiles; |
1351 | |
} |
1352 | |
|
1353 | |
public void addAttachedArtifact( Artifact artifact ) |
1354 | |
{ |
1355 | 0 | getAttachedArtifacts().add( artifact ); |
1356 | 0 | } |
1357 | |
|
1358 | |
public List getAttachedArtifacts() |
1359 | |
{ |
1360 | 0 | if ( attachedArtifacts == null ) |
1361 | |
{ |
1362 | 0 | attachedArtifacts = new ArrayList(); |
1363 | |
} |
1364 | 0 | return attachedArtifacts; |
1365 | |
} |
1366 | |
|
1367 | |
public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId, |
1368 | |
String goalId ) |
1369 | |
{ |
1370 | 0 | Xpp3Dom dom = null; |
1371 | |
|
1372 | |
|
1373 | |
|
1374 | |
|
1375 | |
|
1376 | |
|
1377 | |
|
1378 | 0 | if ( getBuildPlugins() != null ) |
1379 | |
{ |
1380 | 0 | for ( Iterator iterator = getBuildPlugins().iterator(); iterator.hasNext(); ) |
1381 | |
{ |
1382 | 0 | Plugin plugin = (Plugin) iterator.next(); |
1383 | |
|
1384 | 0 | if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) |
1385 | |
{ |
1386 | 0 | dom = (Xpp3Dom) plugin.getConfiguration(); |
1387 | |
|
1388 | 0 | if ( executionId != null ) |
1389 | |
{ |
1390 | 0 | PluginExecution execution = (PluginExecution) plugin.getExecutionsAsMap().get( executionId ); |
1391 | 0 | if ( execution != null ) |
1392 | |
{ |
1393 | 0 | Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); |
1394 | 0 | if ( executionConfiguration != null ) |
1395 | |
{ |
1396 | 0 | Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); |
1397 | 0 | dom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); |
1398 | |
} |
1399 | |
} |
1400 | 0 | } |
1401 | |
break; |
1402 | |
} |
1403 | 0 | } |
1404 | |
} |
1405 | |
|
1406 | 0 | if ( dom != null ) |
1407 | |
{ |
1408 | |
|
1409 | 0 | dom = new Xpp3Dom( dom ); |
1410 | |
} |
1411 | |
|
1412 | 0 | return dom; |
1413 | |
} |
1414 | |
|
1415 | |
public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId ) |
1416 | |
{ |
1417 | 0 | Xpp3Dom dom = null; |
1418 | |
|
1419 | |
|
1420 | |
|
1421 | |
|
1422 | |
|
1423 | |
|
1424 | |
|
1425 | 0 | if ( getReportPlugins() != null ) |
1426 | |
{ |
1427 | 0 | for ( Iterator iterator = getReportPlugins().iterator(); iterator.hasNext(); ) |
1428 | |
{ |
1429 | 0 | ReportPlugin plugin = (ReportPlugin) iterator.next(); |
1430 | |
|
1431 | 0 | if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) |
1432 | |
{ |
1433 | 0 | dom = (Xpp3Dom) plugin.getConfiguration(); |
1434 | |
|
1435 | 0 | if ( reportSetId != null ) |
1436 | |
{ |
1437 | 0 | ReportSet reportSet = (ReportSet) plugin.getReportSetsAsMap().get( reportSetId ); |
1438 | 0 | if ( reportSet != null ) |
1439 | |
{ |
1440 | 0 | Xpp3Dom executionConfiguration = (Xpp3Dom) reportSet.getConfiguration(); |
1441 | 0 | if ( executionConfiguration != null ) |
1442 | |
{ |
1443 | 0 | Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); |
1444 | 0 | dom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); |
1445 | |
} |
1446 | |
} |
1447 | 0 | } |
1448 | |
break; |
1449 | |
} |
1450 | 0 | } |
1451 | |
} |
1452 | |
|
1453 | 0 | if ( dom != null ) |
1454 | |
{ |
1455 | |
|
1456 | 0 | dom = new Xpp3Dom( dom ); |
1457 | |
} |
1458 | |
|
1459 | 0 | return dom; |
1460 | |
} |
1461 | |
|
1462 | |
public MavenProject getExecutionProject() |
1463 | |
{ |
1464 | 0 | return executionProject; |
1465 | |
} |
1466 | |
|
1467 | |
public void setExecutionProject( MavenProject executionProject ) |
1468 | |
{ |
1469 | 0 | this.executionProject = executionProject; |
1470 | 0 | } |
1471 | |
|
1472 | |
public void writeModel( Writer writer ) |
1473 | |
throws IOException |
1474 | |
{ |
1475 | 0 | MavenXpp3Writer pomWriter = new MavenXpp3Writer(); |
1476 | |
|
1477 | 0 | pomWriter.write( writer, getModel() ); |
1478 | 0 | } |
1479 | |
|
1480 | |
public void writeOriginalModel( Writer writer ) |
1481 | |
throws IOException |
1482 | |
{ |
1483 | 0 | MavenXpp3Writer pomWriter = new MavenXpp3Writer(); |
1484 | |
|
1485 | 0 | pomWriter.write( writer, getOriginalModel() ); |
1486 | 0 | } |
1487 | |
|
1488 | |
|
1489 | |
|
1490 | |
|
1491 | |
|
1492 | |
|
1493 | |
public Set getDependencyArtifacts() |
1494 | |
{ |
1495 | 0 | return dependencyArtifacts; |
1496 | |
} |
1497 | |
|
1498 | |
public void setDependencyArtifacts( Set dependencyArtifacts ) |
1499 | |
{ |
1500 | 0 | this.dependencyArtifacts = dependencyArtifacts; |
1501 | 0 | } |
1502 | |
|
1503 | |
public void setReleaseArtifactRepository( ArtifactRepository releaseArtifactRepository ) |
1504 | |
{ |
1505 | 0 | this.releaseArtifactRepository = releaseArtifactRepository; |
1506 | 0 | } |
1507 | |
|
1508 | |
public void setSnapshotArtifactRepository( ArtifactRepository snapshotArtifactRepository ) |
1509 | |
{ |
1510 | 0 | this.snapshotArtifactRepository = snapshotArtifactRepository; |
1511 | 0 | } |
1512 | |
|
1513 | |
public void setOriginalModel( Model originalModel ) |
1514 | |
{ |
1515 | 0 | this.originalModel = originalModel; |
1516 | 0 | } |
1517 | |
|
1518 | |
public Model getOriginalModel() |
1519 | |
{ |
1520 | 0 | return originalModel; |
1521 | |
} |
1522 | |
|
1523 | |
public void setManagedVersionMap( Map map ) |
1524 | |
{ |
1525 | 0 | this.managedVersionMap = map; |
1526 | 0 | } |
1527 | |
|
1528 | |
public Map getManagedVersionMap() |
1529 | |
{ |
1530 | 0 | return this.managedVersionMap; |
1531 | |
} |
1532 | |
|
1533 | |
public boolean equals( Object other ) |
1534 | |
{ |
1535 | 0 | if ( other == this ) |
1536 | |
{ |
1537 | 0 | return true; |
1538 | |
} |
1539 | 0 | else if ( !( other instanceof MavenProject ) ) |
1540 | |
{ |
1541 | 0 | return false; |
1542 | |
} |
1543 | |
else |
1544 | |
{ |
1545 | 0 | MavenProject otherProject = (MavenProject) other; |
1546 | |
|
1547 | 0 | return getId().equals( otherProject.getId() ); |
1548 | |
} |
1549 | |
} |
1550 | |
|
1551 | |
public int hashCode() |
1552 | |
{ |
1553 | 0 | return getId().hashCode(); |
1554 | |
} |
1555 | |
|
1556 | |
public List getBuildExtensions() |
1557 | |
{ |
1558 | 0 | Build build = getBuild(); |
1559 | 0 | if ( build == null || build.getExtensions() == null ) |
1560 | |
{ |
1561 | 0 | return Collections.EMPTY_LIST; |
1562 | |
} |
1563 | |
else |
1564 | |
{ |
1565 | 0 | return build.getExtensions(); |
1566 | |
} |
1567 | |
} |
1568 | |
|
1569 | |
|
1570 | |
|
1571 | |
|
1572 | |
|
1573 | |
public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope, |
1574 | |
ArtifactFilter dependencyFilter ) |
1575 | |
throws InvalidDependencyVersionException |
1576 | |
{ |
1577 | 0 | return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope, |
1578 | |
dependencyFilter, this ); |
1579 | |
} |
1580 | |
|
1581 | |
public void addProjectReference( MavenProject project ) |
1582 | |
{ |
1583 | 0 | projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project ); |
1584 | 0 | } |
1585 | |
|
1586 | |
private static String getProjectReferenceId( String groupId, String artifactId, String version ) |
1587 | |
{ |
1588 | 0 | return groupId + ":" + artifactId + ":" + version; |
1589 | |
} |
1590 | |
|
1591 | |
|
1592 | |
|
1593 | |
|
1594 | |
public void attachArtifact( String type, String classifier, File file ) |
1595 | |
{ |
1596 | 0 | } |
1597 | |
|
1598 | |
public Properties getProperties() |
1599 | |
{ |
1600 | 0 | return getModel().getProperties(); |
1601 | |
} |
1602 | |
|
1603 | |
public List getFilters() |
1604 | |
{ |
1605 | 0 | return getBuild().getFilters(); |
1606 | |
} |
1607 | |
|
1608 | |
public Map getProjectReferences() |
1609 | |
{ |
1610 | 0 | return projectReferences; |
1611 | |
} |
1612 | |
|
1613 | |
public boolean isExecutionRoot() |
1614 | |
{ |
1615 | 0 | return executionRoot; |
1616 | |
} |
1617 | |
|
1618 | |
public void setExecutionRoot( boolean executionRoot ) |
1619 | |
{ |
1620 | 0 | this.executionRoot = executionRoot; |
1621 | 0 | } |
1622 | |
|
1623 | |
public String getDefaultGoal() |
1624 | |
{ |
1625 | 0 | return getBuild() != null ? getBuild().getDefaultGoal() : null; |
1626 | |
} |
1627 | |
|
1628 | |
|
1629 | |
protected void setModel( Model model ) |
1630 | |
{ |
1631 | 0 | this.model = model; |
1632 | 0 | } |
1633 | |
|
1634 | |
protected void setAttachedArtifacts( List attachedArtifacts ) |
1635 | |
{ |
1636 | 0 | this.attachedArtifacts = attachedArtifacts; |
1637 | 0 | } |
1638 | |
|
1639 | |
protected void setCompileSourceRoots( List compileSourceRoots ) |
1640 | |
{ |
1641 | 0 | this.compileSourceRoots = compileSourceRoots; |
1642 | 0 | } |
1643 | |
|
1644 | |
protected void setTestCompileSourceRoots( List testCompileSourceRoots ) |
1645 | |
{ |
1646 | 0 | this.testCompileSourceRoots = testCompileSourceRoots; |
1647 | 0 | } |
1648 | |
|
1649 | |
protected void setScriptSourceRoots( List scriptSourceRoots ) |
1650 | |
{ |
1651 | 0 | this.scriptSourceRoots = scriptSourceRoots; |
1652 | 0 | } |
1653 | |
|
1654 | |
protected ArtifactRepository getReleaseArtifactRepository() |
1655 | |
{ |
1656 | 0 | return releaseArtifactRepository; |
1657 | |
} |
1658 | |
|
1659 | |
protected ArtifactRepository getSnapshotArtifactRepository() |
1660 | |
{ |
1661 | 0 | return snapshotArtifactRepository; |
1662 | |
} |
1663 | |
|
1664 | |
public Artifact replaceWithActiveArtifact( Artifact pluginArtifact ) |
1665 | |
{ |
1666 | 0 | if ( getProjectReferences() != null && !getProjectReferences().isEmpty() ) |
1667 | |
{ |
1668 | 0 | String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() ); |
1669 | 0 | MavenProject ref = (MavenProject) getProjectReferences().get( refId ); |
1670 | 0 | if ( ref != null && ref.getArtifact() != null ) |
1671 | |
{ |
1672 | |
|
1673 | 0 | if ( ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) ) |
1674 | |
{ |
1675 | |
|
1676 | 0 | if ( ref.getArtifact().getFile() != null && ref.getArtifact().getFile().exists() ) |
1677 | |
{ |
1678 | 0 | pluginArtifact = new ActiveProjectArtifact( ref, pluginArtifact ); |
1679 | 0 | return pluginArtifact; |
1680 | |
} |
1681 | |
else |
1682 | |
{ |
1683 | |
|
1684 | |
|
1685 | |
|
1686 | |
|
1687 | |
} |
1688 | |
} |
1689 | |
|
1690 | 0 | Iterator itr = ref.getAttachedArtifacts().iterator(); |
1691 | 0 | while(itr.hasNext()) { |
1692 | 0 | Artifact attached = (Artifact) itr.next(); |
1693 | 0 | if( attached.getDependencyConflictId().equals(pluginArtifact.getDependencyConflictId()) ) { |
1694 | |
|
1695 | |
|
1696 | |
|
1697 | |
|
1698 | |
|
1699 | |
|
1700 | |
|
1701 | |
|
1702 | |
|
1703 | |
|
1704 | |
|
1705 | |
|
1706 | |
|
1707 | |
|
1708 | |
|
1709 | |
|
1710 | |
|
1711 | |
|
1712 | |
|
1713 | |
|
1714 | |
|
1715 | 0 | Artifact resultArtifact=ArtifactUtils.copyArtifact(attached); |
1716 | 0 | resultArtifact.setScope(pluginArtifact.getScope()); |
1717 | 0 | return resultArtifact; |
1718 | |
} |
1719 | 0 | } |
1720 | |
} |
1721 | |
} |
1722 | 0 | return pluginArtifact; |
1723 | |
} |
1724 | |
|
1725 | |
private void addArtifactPath(Artifact a, List list) throws DependencyResolutionRequiredException |
1726 | |
{ |
1727 | 0 | String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() ); |
1728 | 0 | MavenProject project = (MavenProject) projectReferences.get( refId ); |
1729 | |
|
1730 | 0 | boolean projectDirFound = false; |
1731 | 0 | if ( project != null ) |
1732 | |
{ |
1733 | 0 | if (a.getType().equals("test-jar")) |
1734 | |
{ |
1735 | 0 | File testOutputDir = new File( project.getBuild().getTestOutputDirectory() ); |
1736 | 0 | if ( testOutputDir.exists() ) |
1737 | |
{ |
1738 | 0 | list.add( testOutputDir.getAbsolutePath() ); |
1739 | 0 | projectDirFound = true; |
1740 | |
} |
1741 | 0 | } |
1742 | |
else |
1743 | |
{ |
1744 | 0 | list.add( project.getBuild().getOutputDirectory() ); |
1745 | 0 | projectDirFound = true; |
1746 | |
} |
1747 | |
} |
1748 | 0 | if ( ! projectDirFound ) |
1749 | |
{ |
1750 | 0 | File file = a.getFile(); |
1751 | 0 | if ( file == null ) |
1752 | |
{ |
1753 | 0 | throw new DependencyResolutionRequiredException( a ); |
1754 | |
} |
1755 | 0 | list.add( file.getPath() ); |
1756 | |
} |
1757 | 0 | } |
1758 | |
|
1759 | |
|
1760 | |
|
1761 | |
|
1762 | |
public String toString() |
1763 | |
{ |
1764 | 0 | StringBuffer sb = new StringBuffer(30); |
1765 | 0 | sb.append( "MavenProject: " ); |
1766 | 0 | sb.append( this.getGroupId() ); |
1767 | 0 | sb.append( ":" ); |
1768 | 0 | sb.append( this.getArtifactId() ); |
1769 | 0 | sb.append( ":" ); |
1770 | 0 | sb.append( this.getVersion() ); |
1771 | 0 | sb.append( " @ " ); |
1772 | |
|
1773 | |
try |
1774 | |
{ |
1775 | 0 | sb.append( this.getFile().getPath() ); |
1776 | |
} |
1777 | 0 | catch (NullPointerException e) |
1778 | |
{ |
1779 | |
|
1780 | 0 | } |
1781 | |
|
1782 | 0 | return sb.toString(); |
1783 | |
} |
1784 | |
|
1785 | |
|
1786 | |
|
1787 | |
|
1788 | |
|
1789 | |
public Object clone() |
1790 | |
throws CloneNotSupportedException |
1791 | |
{ |
1792 | 0 | MavenProject clone = (MavenProject) super.clone(); |
1793 | 0 | clone.deepCopy( this ); |
1794 | 0 | return clone; |
1795 | |
} |
1796 | |
|
1797 | |
} |