1 package org.apache.maven.plugin.testing.stubs;
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.List;
28 import java.util.Map;
29 import java.util.Properties;
30 import java.util.Set;
31
32 import org.apache.maven.artifact.Artifact;
33 import org.apache.maven.artifact.DependencyResolutionRequiredException;
34 import org.apache.maven.artifact.factory.ArtifactFactory;
35 import org.apache.maven.artifact.repository.ArtifactRepository;
36 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
37 import org.apache.maven.model.Build;
38 import org.apache.maven.model.CiManagement;
39 import org.apache.maven.model.Contributor;
40 import org.apache.maven.model.DependencyManagement;
41 import org.apache.maven.model.Developer;
42 import org.apache.maven.model.DistributionManagement;
43 import org.apache.maven.model.IssueManagement;
44 import org.apache.maven.model.License;
45 import org.apache.maven.model.MailingList;
46 import org.apache.maven.model.Model;
47 import org.apache.maven.model.Organization;
48 import org.apache.maven.model.Plugin;
49 import org.apache.maven.model.PluginManagement;
50 import org.apache.maven.model.Prerequisites;
51 import org.apache.maven.model.Reporting;
52 import org.apache.maven.model.Resource;
53 import org.apache.maven.model.Scm;
54 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
55 import org.apache.maven.project.MavenProject;
56 import org.codehaus.plexus.PlexusTestCase;
57 import org.codehaus.plexus.util.ReaderFactory;
58 import org.codehaus.plexus.util.xml.Xpp3Dom;
59 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
60
61
62
63
64
65
66
67
68 public class MavenProjectStub
69 extends MavenProject
70 {
71 private String groupId;
72
73 private String artifactId;
74
75 private String name;
76
77 private Model model;
78
79 private MavenProject parent;
80
81 private File file;
82
83 private List collectedProjects;
84
85 private List attachedArtifacts;
86
87 private List compileSourceRoots;
88
89 private List testCompileSourceRoots;
90
91 private List scriptSourceRoots;
92
93 private List pluginArtifactRepositories;
94
95 private ArtifactRepository releaseArtifactRepository;
96
97 private ArtifactRepository snapshotArtifactRepository;
98
99 private List activeProfiles;
100
101 private Set dependencyArtifacts;
102
103 private Artifact artifact;
104
105 private Map artifactMap;
106
107 private Model originalModel;
108
109 private Map pluginArtifactMap;
110
111 private Map reportArtifactMap;
112
113 private Map extensionArtifactMap;
114
115 private Map projectReferences;
116
117 private Build buildOverlay;
118
119 private boolean executionRoot;
120
121 private List compileArtifacts;
122
123 private List compileDependencies;
124
125 private List systemDependencies;
126
127 private List testClasspathElements;
128
129 private List testDependencies;
130
131 private List systemClasspathElements;
132
133 private List systemArtifacts;
134
135 private List testArtifacts;
136
137 private List runtimeArtifacts;
138
139 private List runtimeDependencies;
140
141 private List runtimeClasspathElements;
142
143 private String modelVersion;
144
145 private String packaging;
146
147 private String inceptionYear;
148
149 private String url;
150
151 private String description;
152
153 private String version;
154
155 private String defaultGoal;
156
157 private List licenses;
158
159 private Build build;
160
161
162
163
164 public MavenProjectStub()
165 {
166 this( new Model() );
167 }
168
169
170
171
172 public MavenProjectStub( Model model )
173 {
174 super( (Model) null );
175 this.model = model;
176 }
177
178
179
180
181
182
183
184
185 protected void readModel( File pomFile )
186 {
187 if ( !pomFile.isAbsolute() )
188 {
189 pomFile = new File( getBasedir(), pomFile.getPath() );
190 }
191 try
192 {
193 setModel( new MavenXpp3Reader().read( ReaderFactory.newXmlReader( pomFile ) ) );
194 }
195 catch ( IOException e )
196 {
197 throw new RuntimeException( "Failed to read POM file: " + pomFile, e );
198 }
199 catch ( XmlPullParserException e )
200 {
201 throw new RuntimeException( "Failed to parse POM file: " + pomFile, e );
202 }
203 }
204
205
206
207
208
209
210 public MavenProjectStub( MavenProject project )
211 {
212 super( (Model) null );
213 }
214
215
216
217
218
219
220 public String getModulePathAdjustment( MavenProject mavenProject )
221 throws IOException
222 {
223 return "";
224 }
225
226
227 public Artifact getArtifact()
228 {
229 return artifact;
230 }
231
232
233 public void setArtifact( Artifact artifact )
234 {
235 this.artifact = artifact;
236 }
237
238
239 public Model getModel()
240 {
241 return model;
242 }
243
244
245 public MavenProject getParent()
246 {
247 return parent;
248 }
249
250
251 public void setParent( MavenProject mavenProject )
252 {
253 this.parent = mavenProject;
254 }
255
256
257
258
259
260
261 public void setRemoteArtifactRepositories( List list )
262 {
263
264 }
265
266
267
268
269
270
271 public List getRemoteArtifactRepositories()
272 {
273 return Collections.EMPTY_LIST;
274 }
275
276
277 public boolean hasParent()
278 {
279 if ( parent != null )
280 {
281 return true;
282 }
283
284 return false;
285 }
286
287
288 public File getFile()
289 {
290 return file;
291 }
292
293
294 public void setFile( File file )
295 {
296 this.file = file;
297 }
298
299
300 public File getBasedir()
301 {
302 return new File( PlexusTestCase.getBasedir() );
303 }
304
305
306
307
308
309
310 public void setDependencies( List list )
311 {
312
313 }
314
315
316
317
318
319
320 public List getDependencies()
321 {
322 return Collections.EMPTY_LIST;
323 }
324
325
326
327
328
329
330 public DependencyManagement getDependencyManagement()
331 {
332 return null;
333 }
334
335
336 public void addCompileSourceRoot( String string )
337 {
338 if ( compileSourceRoots == null )
339 {
340 compileSourceRoots = new ArrayList( Collections.singletonList( string ) );
341 }
342 else
343 {
344 compileSourceRoots.add( string );
345 }
346 }
347
348
349 public void addScriptSourceRoot( String string )
350 {
351 if ( scriptSourceRoots == null )
352 {
353 scriptSourceRoots = new ArrayList( Collections.singletonList( string ) );
354 }
355 else
356 {
357 scriptSourceRoots.add( string );
358 }
359 }
360
361
362 public void addTestCompileSourceRoot( String string )
363 {
364 if ( testCompileSourceRoots == null )
365 {
366 testCompileSourceRoots = new ArrayList( Collections.singletonList( string ) );
367 }
368 else
369 {
370 testCompileSourceRoots.add( string );
371 }
372 }
373
374
375 public List getCompileSourceRoots()
376 {
377 return compileSourceRoots;
378 }
379
380
381 public List getScriptSourceRoots()
382 {
383 return scriptSourceRoots;
384 }
385
386
387 public List getTestCompileSourceRoots()
388 {
389 return testCompileSourceRoots;
390 }
391
392
393 public List getCompileClasspathElements()
394 throws DependencyResolutionRequiredException
395 {
396 return compileSourceRoots;
397 }
398
399
400
401
402 public void setCompileArtifacts( List compileArtifacts )
403 {
404 this.compileArtifacts = compileArtifacts;
405 }
406
407
408 public List getCompileArtifacts()
409 {
410 return compileArtifacts;
411 }
412
413
414 public List getCompileDependencies()
415 {
416 return compileDependencies;
417 }
418
419
420 public List getTestClasspathElements()
421 throws DependencyResolutionRequiredException
422 {
423 return testClasspathElements;
424 }
425
426
427 public List getTestArtifacts()
428 {
429 return testArtifacts;
430 }
431
432
433 public List getTestDependencies()
434 {
435 return testDependencies;
436 }
437
438
439 public List getRuntimeClasspathElements()
440 throws DependencyResolutionRequiredException
441 {
442 return runtimeClasspathElements;
443 }
444
445
446 public List getRuntimeArtifacts()
447 {
448 return runtimeArtifacts;
449 }
450
451
452 public List getRuntimeDependencies()
453 {
454 return runtimeDependencies;
455 }
456
457
458 public List getSystemClasspathElements()
459 throws DependencyResolutionRequiredException
460 {
461 return systemClasspathElements;
462 }
463
464
465 public List getSystemArtifacts()
466 {
467 return systemArtifacts;
468 }
469
470
471
472
473 public void setRuntimeClasspathElements( List runtimeClasspathElements )
474 {
475 this.runtimeClasspathElements = runtimeClasspathElements;
476 }
477
478
479
480
481 public void setAttachedArtifacts( List attachedArtifacts )
482 {
483 this.attachedArtifacts = attachedArtifacts;
484 }
485
486
487
488
489 public void setCompileSourceRoots( List compileSourceRoots )
490 {
491 this.compileSourceRoots = compileSourceRoots;
492 }
493
494
495
496
497 public void setTestCompileSourceRoots( List testCompileSourceRoots )
498 {
499 this.testCompileSourceRoots = testCompileSourceRoots;
500 }
501
502
503
504
505 public void setScriptSourceRoots( List scriptSourceRoots )
506 {
507 this.scriptSourceRoots = scriptSourceRoots;
508 }
509
510
511
512
513 public void setArtifactMap( Map artifactMap )
514 {
515 this.artifactMap = artifactMap;
516 }
517
518
519
520
521 public void setPluginArtifactMap( Map pluginArtifactMap )
522 {
523 this.pluginArtifactMap = pluginArtifactMap;
524 }
525
526
527
528
529 public void setReportArtifactMap( Map reportArtifactMap )
530 {
531 this.reportArtifactMap = reportArtifactMap;
532 }
533
534
535
536
537 public void setExtensionArtifactMap( Map extensionArtifactMap )
538 {
539 this.extensionArtifactMap = extensionArtifactMap;
540 }
541
542
543
544
545 public void setProjectReferences( Map projectReferences )
546 {
547 this.projectReferences = projectReferences;
548 }
549
550
551
552
553 public void setBuildOverlay( Build buildOverlay )
554 {
555 this.buildOverlay = buildOverlay;
556 }
557
558
559
560
561 public void setCompileDependencies( List compileDependencies )
562 {
563 this.compileDependencies = compileDependencies;
564 }
565
566
567
568
569 public void setSystemDependencies( List systemDependencies )
570 {
571 this.systemDependencies = systemDependencies;
572 }
573
574
575
576
577 public void setTestClasspathElements( List testClasspathElements )
578 {
579 this.testClasspathElements = testClasspathElements;
580 }
581
582
583
584
585 public void setTestDependencies( List testDependencies )
586 {
587 this.testDependencies = testDependencies;
588 }
589
590
591
592
593 public void setSystemClasspathElements( List systemClasspathElements )
594 {
595 this.systemClasspathElements = systemClasspathElements;
596 }
597
598
599
600
601 public void setSystemArtifacts( List systemArtifacts )
602 {
603 this.systemArtifacts = systemArtifacts;
604 }
605
606
607
608
609 public void setTestArtifacts( List testArtifacts )
610 {
611 this.testArtifacts = testArtifacts;
612 }
613
614
615
616
617 public void setRuntimeArtifacts( List runtimeArtifacts )
618 {
619 this.runtimeArtifacts = runtimeArtifacts;
620 }
621
622
623
624
625 public void setRuntimeDependencies( List runtimeDependencies )
626 {
627 this.runtimeDependencies = runtimeDependencies;
628 }
629
630
631
632
633 public void setModel( Model model )
634 {
635 this.model = model;
636 }
637
638
639 public List getSystemDependencies()
640 {
641 return systemDependencies;
642 }
643
644
645 public void setModelVersion( String string )
646 {
647 this.modelVersion = string;
648 }
649
650
651 public String getModelVersion()
652 {
653 return modelVersion;
654 }
655
656
657
658
659
660
661 public String getId()
662 {
663 return "";
664 }
665
666
667 public void setGroupId( String string )
668 {
669 this.groupId = string;
670 }
671
672
673 public String getGroupId()
674 {
675 return groupId;
676 }
677
678
679 public void setArtifactId( String string )
680 {
681 this.artifactId = string;
682 }
683
684
685 public String getArtifactId()
686 {
687 return artifactId;
688 }
689
690
691 public void setName( String string )
692 {
693 this.name = string;
694 }
695
696
697 public String getName()
698 {
699 return name;
700 }
701
702
703 public void setVersion( String string )
704 {
705 this.version = string;
706 }
707
708
709 public String getVersion()
710 {
711 return version;
712 }
713
714
715 public String getPackaging()
716 {
717 return packaging;
718 }
719
720
721 public void setPackaging( String string )
722 {
723 this.packaging = string;
724 }
725
726
727 public void setInceptionYear( String string )
728 {
729 this.inceptionYear = string;
730 }
731
732
733 public String getInceptionYear()
734 {
735 return inceptionYear;
736 }
737
738
739 public void setUrl( String string )
740 {
741 this.url = string;
742 }
743
744
745 public String getUrl()
746 {
747 return url;
748 }
749
750
751
752
753
754
755 public Prerequisites getPrerequisites()
756 {
757 return null;
758 }
759
760
761
762
763
764
765 public void setIssueManagement( IssueManagement issueManagement )
766 {
767
768 }
769
770
771
772
773
774
775 public CiManagement getCiManagement()
776 {
777 return null;
778 }
779
780
781
782
783
784
785 public void setCiManagement( CiManagement ciManagement )
786 {
787
788 }
789
790
791
792
793
794
795 public IssueManagement getIssueManagement()
796 {
797 return null;
798 }
799
800
801
802
803
804
805 public void setDistributionManagement( DistributionManagement distributionManagement )
806 {
807
808 }
809
810
811
812
813
814
815 public DistributionManagement getDistributionManagement()
816 {
817 return null;
818 }
819
820
821 public void setDescription( String string )
822 {
823 this.description = string;
824 }
825
826
827 public String getDescription()
828 {
829 return description;
830 }
831
832
833
834
835
836
837 public void setOrganization( Organization organization )
838 {
839
840 }
841
842
843
844
845
846
847 public Organization getOrganization()
848 {
849 return null;
850 }
851
852
853
854
855
856
857 public void setScm( Scm scm )
858 {
859
860 }
861
862
863
864
865
866
867 public Scm getScm()
868 {
869 return null;
870 }
871
872
873
874
875
876
877 public void setMailingLists( List list )
878 {
879
880 }
881
882
883
884
885
886
887 public List getMailingLists()
888 {
889 return Collections.EMPTY_LIST;
890 }
891
892
893
894
895
896
897 public void addMailingList( MailingList mailingList )
898 {
899
900 }
901
902
903
904
905
906
907 public void setDevelopers( List list )
908 {
909
910 }
911
912
913
914
915
916
917 public List getDevelopers()
918 {
919 return Collections.EMPTY_LIST;
920 }
921
922
923
924
925
926
927 public void addDeveloper( Developer developer )
928 {
929
930 }
931
932
933
934
935
936
937 public void setContributors( List list )
938 {
939
940 }
941
942
943
944
945
946
947 public List getContributors()
948 {
949 return Collections.EMPTY_LIST;
950 }
951
952
953
954
955
956
957 public void addContributor( Contributor contributor )
958 {
959
960 }
961
962
963 public void setBuild( Build build )
964 {
965 this.build = build;
966 }
967
968
969 public Build getBuild()
970 {
971 return build;
972 }
973
974
975
976
977
978
979 public List getResources()
980 {
981 return Collections.EMPTY_LIST;
982 }
983
984
985
986
987
988
989 public List getTestResources()
990 {
991 return Collections.EMPTY_LIST;
992 }
993
994
995
996
997
998
999 public void addResource( Resource resource )
1000 {
1001
1002 }
1003
1004
1005
1006
1007
1008
1009 public void addTestResource( Resource resource )
1010 {
1011
1012 }
1013
1014
1015
1016
1017
1018
1019 public void setReporting( Reporting reporting )
1020 {
1021
1022 }
1023
1024
1025
1026
1027
1028
1029 public Reporting getReporting()
1030 {
1031 return null;
1032 }
1033
1034
1035 public void setLicenses( List licenses )
1036 {
1037 this.licenses = licenses;
1038 }
1039
1040
1041 public List getLicenses()
1042 {
1043 return licenses;
1044 }
1045
1046
1047
1048
1049
1050
1051 public void addLicense( License license )
1052 {
1053
1054 }
1055
1056
1057
1058
1059
1060
1061 public void setArtifacts( Set set )
1062 {
1063
1064 }
1065
1066
1067
1068
1069
1070
1071 public Set getArtifacts()
1072 {
1073 return Collections.EMPTY_SET;
1074 }
1075
1076
1077
1078
1079
1080
1081 public Map getArtifactMap()
1082 {
1083 return Collections.EMPTY_MAP;
1084 }
1085
1086
1087
1088
1089
1090
1091 public void setPluginArtifacts( Set set )
1092 {
1093
1094 }
1095
1096
1097
1098
1099
1100
1101 public Set getPluginArtifacts()
1102 {
1103 return Collections.EMPTY_SET;
1104 }
1105
1106
1107
1108
1109
1110
1111 public Map getPluginArtifactMap()
1112 {
1113 return Collections.EMPTY_MAP;
1114 }
1115
1116
1117
1118
1119
1120
1121 public void setReportArtifacts( Set set )
1122 {
1123
1124 }
1125
1126
1127
1128
1129
1130
1131 public Set getReportArtifacts()
1132 {
1133 return Collections.EMPTY_SET;
1134 }
1135
1136
1137
1138
1139
1140
1141 public Map getReportArtifactMap()
1142 {
1143 return Collections.EMPTY_MAP;
1144 }
1145
1146
1147
1148
1149
1150
1151 public void setExtensionArtifacts( Set set )
1152 {
1153
1154 }
1155
1156
1157
1158
1159
1160
1161 public Set getExtensionArtifacts()
1162 {
1163 return Collections.EMPTY_SET;
1164 }
1165
1166
1167
1168
1169
1170
1171 public Map getExtensionArtifactMap()
1172 {
1173 return Collections.EMPTY_MAP;
1174 }
1175
1176
1177
1178
1179
1180
1181 public void setParentArtifact( Artifact artifact )
1182 {
1183
1184 }
1185
1186
1187
1188
1189
1190
1191 public Artifact getParentArtifact()
1192 {
1193 return null;
1194 }
1195
1196
1197
1198
1199
1200
1201 public List getRepositories()
1202 {
1203 return Collections.EMPTY_LIST;
1204 }
1205
1206
1207
1208
1209
1210
1211 public List getReportPlugins()
1212 {
1213 return Collections.EMPTY_LIST;
1214 }
1215
1216
1217
1218
1219
1220
1221 public List getBuildPlugins()
1222 {
1223 return Collections.EMPTY_LIST;
1224 }
1225
1226
1227
1228
1229
1230
1231 public List getModules()
1232 {
1233 return Collections.EMPTY_LIST;
1234 }
1235
1236
1237
1238
1239
1240
1241 public PluginManagement getPluginManagement()
1242 {
1243 return null;
1244 }
1245
1246
1247
1248
1249
1250
1251 public void addPlugin( Plugin plugin )
1252 {
1253
1254 }
1255
1256
1257
1258
1259
1260
1261 public void injectPluginManagementInfo( Plugin plugin )
1262 {
1263
1264 }
1265
1266
1267 public List getCollectedProjects()
1268 {
1269 return collectedProjects;
1270 }
1271
1272
1273 public void setCollectedProjects( List list )
1274 {
1275 this.collectedProjects = list;
1276 }
1277
1278
1279 public void setPluginArtifactRepositories( List list )
1280 {
1281 this.pluginArtifactRepositories = list;
1282 }
1283
1284
1285 public List getPluginArtifactRepositories()
1286 {
1287 return pluginArtifactRepositories;
1288 }
1289
1290
1291
1292
1293
1294
1295 public ArtifactRepository getDistributionManagementArtifactRepository()
1296 {
1297 return null;
1298 }
1299
1300
1301
1302
1303
1304
1305 public List getPluginRepositories()
1306 {
1307 return Collections.EMPTY_LIST;
1308 }
1309
1310
1311 public void setActiveProfiles( List list )
1312 {
1313 activeProfiles = list;
1314 }
1315
1316
1317 public List getActiveProfiles()
1318 {
1319 return activeProfiles;
1320 }
1321
1322
1323 public void addAttachedArtifact( Artifact artifact )
1324 {
1325 if ( attachedArtifacts == null )
1326 {
1327 this.attachedArtifacts = new ArrayList( Collections.singletonList( artifact ) );
1328 }
1329 else
1330 {
1331 attachedArtifacts.add( artifact );
1332 }
1333 }
1334
1335
1336 public List getAttachedArtifacts()
1337 {
1338 return attachedArtifacts;
1339 }
1340
1341
1342
1343
1344
1345
1346 public Xpp3Dom getGoalConfiguration( String string, String string1, String string2, String string3 )
1347 {
1348 return null;
1349 }
1350
1351
1352
1353
1354
1355
1356 public Xpp3Dom getReportConfiguration( String string, String string1, String string2 )
1357 {
1358 return null;
1359 }
1360
1361
1362
1363
1364
1365
1366 public MavenProject getExecutionProject()
1367 {
1368 return null;
1369 }
1370
1371
1372
1373
1374
1375
1376 public void setExecutionProject( MavenProject mavenProject )
1377 {
1378
1379 }
1380
1381
1382
1383
1384
1385
1386 public void writeModel( Writer writer )
1387 throws IOException
1388 {
1389
1390 }
1391
1392
1393
1394
1395
1396
1397 public void writeOriginalModel( Writer writer )
1398 throws IOException
1399 {
1400
1401 }
1402
1403
1404 public Set getDependencyArtifacts()
1405 {
1406 return dependencyArtifacts;
1407 }
1408
1409
1410 public void setDependencyArtifacts( Set set )
1411 {
1412 this.dependencyArtifacts = set;
1413 }
1414
1415
1416 public void setReleaseArtifactRepository( ArtifactRepository artifactRepository )
1417 {
1418 this.releaseArtifactRepository = artifactRepository;
1419 }
1420
1421
1422 public void setSnapshotArtifactRepository( ArtifactRepository artifactRepository )
1423 {
1424 this.snapshotArtifactRepository = artifactRepository;
1425 }
1426
1427
1428 public void setOriginalModel( Model model )
1429 {
1430 this.originalModel = model;
1431 }
1432
1433
1434 public Model getOriginalModel()
1435 {
1436 return originalModel;
1437 }
1438
1439
1440
1441
1442
1443
1444 public List getBuildExtensions()
1445 {
1446 return Collections.EMPTY_LIST;
1447 }
1448
1449
1450
1451
1452
1453
1454 public Set createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
1455 {
1456 return Collections.EMPTY_SET;
1457 }
1458
1459
1460
1461
1462
1463
1464 public void addProjectReference( MavenProject mavenProject )
1465 {
1466
1467 }
1468
1469
1470
1471
1472
1473
1474 public void attachArtifact( String string, String string1, File file )
1475 {
1476
1477 }
1478
1479
1480
1481
1482
1483
1484 public Properties getProperties()
1485 {
1486 return new Properties();
1487 }
1488
1489
1490
1491
1492
1493
1494 public List getFilters()
1495 {
1496 return Collections.EMPTY_LIST;
1497 }
1498
1499
1500
1501
1502
1503
1504 public Map getProjectReferences()
1505 {
1506 return Collections.EMPTY_MAP;
1507 }
1508
1509
1510 public boolean isExecutionRoot()
1511 {
1512 return executionRoot;
1513 }
1514
1515
1516 public void setExecutionRoot( boolean b )
1517 {
1518 this.executionRoot = b;
1519 }
1520
1521
1522 public String getDefaultGoal()
1523 {
1524 return defaultGoal;
1525 }
1526
1527
1528
1529
1530
1531
1532 public Artifact replaceWithActiveArtifact( Artifact artifact )
1533 {
1534 return null;
1535 }
1536 }