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