1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.ide;
20
21 import java.io.File;
22
23 import org.apache.maven.project.MavenProject;
24
25
26
27
28
29 public class IdeDependency
30 implements Comparable
31 {
32
33
34
35 private boolean referencedProject;
36
37
38
39
40 private boolean testDependency;
41
42
43
44
45 private boolean systemScoped;
46
47
48
49
50 private boolean provided;
51
52
53
54
55 private boolean addedToClasspath;
56
57
58
59
60 private File file;
61
62
63
64
65 private File javadocAttachment;
66
67
68
69
70 private File sourceAttachment;
71
72
73
74
75 private String groupId;
76
77
78
79
80 private String artifactId;
81
82
83
84
85 private String version;
86
87
88
89
90 private String classifier;
91
92
93
94
95 private String type;
96
97
98
99
100 private boolean osgiBundle;
101
102
103
104
105 private String eclipseProjectName;
106
107
108
109
110 private boolean ajdtWeaveDependency;
111
112
113
114
115 private boolean ajdtDependency;
116
117
118
119
120 public IdeDependency()
121 {
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 public IdeDependency( String groupId, String artifactId, String version, String classifier,
142 boolean referencedProject, boolean testDependency, boolean systemScoped, boolean provided,
143 boolean addedToClasspath, File file, String type, boolean osgiBundle,
144 String osgiSymbolicName, int dependencyDepth, String eclipseProjectName )
145 {
146
147 this.groupId = groupId;
148 this.artifactId = artifactId;
149 this.version = version;
150 this.classifier = classifier;
151
152
153 this.referencedProject = referencedProject;
154 this.testDependency = testDependency;
155 this.systemScoped = systemScoped;
156 this.provided = provided;
157 this.addedToClasspath = addedToClasspath;
158
159
160 this.osgiBundle = osgiBundle;
161
162 this.file = file;
163 this.type = type;
164 this.eclipseProjectName = eclipseProjectName;
165 }
166
167
168
169
170
171
172 public File getJavadocAttachment()
173 {
174 return javadocAttachment;
175 }
176
177
178
179
180
181
182 public void setJavadocAttachment( File javadocAttachment )
183 {
184 this.javadocAttachment = javadocAttachment;
185 }
186
187
188
189
190
191
192 public String getArtifactId()
193 {
194 return artifactId;
195 }
196
197
198
199
200
201
202 public void setArtifactId( String artifactId )
203 {
204 this.artifactId = artifactId;
205 }
206
207
208
209
210
211
212 public String getGroupId()
213 {
214 return groupId;
215 }
216
217
218
219
220
221
222 public void setGroupId( String groupId )
223 {
224 this.groupId = groupId;
225 }
226
227
228
229
230
231
232 public String getVersion()
233 {
234 return version;
235 }
236
237
238
239
240
241
242 public void setVersion( String version )
243 {
244 this.version = version;
245 }
246
247
248
249
250
251
252 public String getClassifier()
253 {
254 return classifier;
255 }
256
257
258
259
260
261
262 public void setClassifier( String classifier )
263 {
264 this.classifier = classifier;
265 }
266
267
268
269
270
271
272 public boolean isReferencedProject()
273 {
274 return referencedProject;
275 }
276
277
278
279
280
281
282 public boolean isOsgiBundle()
283 {
284 return osgiBundle;
285 }
286
287
288
289
290
291
292 public void setReferencedProject( boolean referencedProject )
293 {
294 this.referencedProject = referencedProject;
295 }
296
297
298
299
300
301
302 public File getSourceAttachment()
303 {
304 return sourceAttachment;
305 }
306
307
308
309
310
311
312 public void setSourceAttachment( File sourceAttachment )
313 {
314 this.sourceAttachment = sourceAttachment;
315 }
316
317
318
319
320
321
322 public boolean isSystemScoped()
323 {
324 return systemScoped;
325 }
326
327
328
329
330
331
332 public void setSystemScoped( boolean systemScoped )
333 {
334 this.systemScoped = systemScoped;
335 }
336
337
338
339
340
341
342 public boolean isTestDependency()
343 {
344 return testDependency;
345 }
346
347
348
349
350
351
352 public void setTestDependency( boolean testDependency )
353 {
354 this.testDependency = testDependency;
355 }
356
357
358
359
360
361
362 public File getFile()
363 {
364 return file;
365 }
366
367
368
369
370
371
372 public void setFile( File file )
373 {
374 this.file = file;
375 }
376
377
378
379
380
381
382 public String getId()
383 {
384 return groupId + ':' + artifactId + ':' + version;
385 }
386
387
388
389
390
391
392 public String getType()
393 {
394 return type;
395 }
396
397
398
399
400
401
402 public void setType( String type )
403 {
404 this.type = type;
405 }
406
407
408
409
410
411
412 public boolean isAddedToClasspath()
413 {
414 return addedToClasspath;
415 }
416
417
418
419
420
421
422 public void setAddedToClasspath( boolean addedToClasspath )
423 {
424 this.addedToClasspath = addedToClasspath;
425 }
426
427
428
429
430
431
432 public boolean isProvided()
433 {
434 return provided;
435 }
436
437
438
439
440
441
442 public void setProvided( boolean provided )
443 {
444 this.provided = provided;
445 }
446
447
448
449
450
451
452 public String getEclipseProjectName()
453 {
454 return eclipseProjectName;
455 }
456
457
458
459
460
461
462 public void setEclipseProjectName( String eclipseProjectName )
463 {
464 this.eclipseProjectName = eclipseProjectName;
465 }
466
467
468
469
470
471
472 public boolean isAjdtWeaveDependency()
473 {
474 return ajdtWeaveDependency;
475 }
476
477
478
479
480
481
482 public void setAjdtWeaveDependency( boolean ajdtWeaveDependency )
483 {
484 this.ajdtWeaveDependency = ajdtWeaveDependency;
485 }
486
487
488
489
490
491
492 public boolean isAjdtDependency()
493 {
494 return ajdtDependency;
495 }
496
497
498
499
500
501
502 public void setAjdtDependency( boolean ajdtDependency )
503 {
504 this.ajdtDependency = ajdtDependency;
505 }
506
507
508
509
510 public String toString()
511 {
512 return getId();
513 }
514
515
516
517
518 public int compareTo( Object o )
519 {
520 IdeDependency dep = (IdeDependency) o;
521
522 if ( isSystemScoped() && dep.isSystemScoped() && getFile().equals( dep.getFile() ) )
523 {
524 return 0;
525 }
526 int equals = this.getGroupId().compareTo( dep.getGroupId() );
527 if ( equals != 0 )
528 {
529 return equals;
530 }
531 equals = this.getArtifactId().compareTo( dep.getArtifactId() );
532 if ( equals != 0 )
533 {
534 return equals;
535 }
536 equals = this.getType().compareTo( dep.getType() );
537 if ( equals != 0 )
538 {
539 return equals;
540 }
541 if ( this.getClassifier() != null && dep.getClassifier() != null )
542 {
543 equals = this.getClassifier().compareTo( dep.getClassifier() );
544 }
545 else if ( this.getClassifier() != null && dep.getClassifier() == null )
546 {
547 return 1;
548 }
549 else if ( this.getClassifier() == null && dep.getClassifier() != null )
550 {
551 return -1;
552 }
553 if ( equals != 0 )
554 {
555 return equals;
556 }
557 return 0;
558 }
559
560
561
562
563
564
565
566 public boolean isSystemScopedOutsideProject( MavenProject project )
567 {
568 File modulesTop = project.getBasedir();
569 while ( new File( modulesTop.getParentFile(), "pom.xml" ).exists() )
570 {
571 modulesTop = modulesTop.getParentFile();
572 }
573 return isSystemScoped() && !getFile().getAbsolutePath().startsWith( modulesTop.getAbsolutePath() );
574 }
575
576
577
578
579 public boolean isJavaApi()
580 {
581 return groupId.startsWith( "java." ) || groupId.startsWith( "javax." );
582 }
583
584
585
586
587 public boolean equals( Object obj )
588 {
589 return compareTo( obj ) == 0;
590 }
591
592
593
594
595 public int hashCode()
596 {
597 if ( isSystemScoped() )
598 {
599 return getFile().hashCode();
600 }
601 else
602 {
603 int hashCode = this.getGroupId().hashCode() ^ this.getArtifactId().hashCode() ^ this.getType().hashCode();
604 if ( this.getClassifier() == null )
605 {
606 return hashCode;
607 }
608 else
609 {
610 return hashCode ^ this.getClassifier().hashCode();
611 }
612
613 }
614 }
615 }