1 package org_scala_tools_maven_model;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.io.Writer;
6 import java.util.List;
7 import java.util.Map;
8 import java.util.Properties;
9 import java.util.Set;
10
11 import org.apache.maven.artifact.Artifact;
12 import org.apache.maven.artifact.DependencyResolutionRequiredException;
13 import org.apache.maven.artifact.factory.ArtifactFactory;
14 import org.apache.maven.artifact.repository.ArtifactRepository;
15 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
16 import org.apache.maven.model.Build;
17 import org.apache.maven.model.CiManagement;
18 import org.apache.maven.model.Contributor;
19 import org.apache.maven.model.Dependency;
20 import org.apache.maven.model.DependencyManagement;
21 import org.apache.maven.model.Developer;
22 import org.apache.maven.model.DistributionManagement;
23 import org.apache.maven.model.IssueManagement;
24 import org.apache.maven.model.License;
25 import org.apache.maven.model.MailingList;
26 import org.apache.maven.model.Model;
27 import org.apache.maven.model.Organization;
28 import org.apache.maven.model.Plugin;
29 import org.apache.maven.model.PluginManagement;
30 import org.apache.maven.model.Prerequisites;
31 import org.apache.maven.model.Profile;
32 import org.apache.maven.model.Reporting;
33 import org.apache.maven.model.Repository;
34 import org.apache.maven.model.Resource;
35 import org.apache.maven.model.Scm;
36 import org.apache.maven.project.MavenProject;
37 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
38 import org.codehaus.plexus.util.xml.Xpp3Dom;
39
40 @SuppressWarnings("unchecked")
41 public class MavenProjectAdapter {
42
43 final MavenProject wrapped;
44
45 public MavenProjectAdapter(MavenProject project) {
46 this.wrapped = project;
47 }
48
49 public List<Profile> getActiveProfiles() {
50 return wrapped.getActiveProfiles();
51 }
52
53 public Map<String, Artifact> getArtifactMap() {
54 return wrapped.getArtifactMap();
55 }
56
57 public Set<Artifact> getArtifacts() {
58 return wrapped.getArtifacts();
59 }
60
61 public List<Artifact> getAttachedArtifacts() {
62 return wrapped.getAttachedArtifacts();
63 }
64
65 public List<Plugin> getBuildPlugins() {
66 return wrapped.getBuildPlugins();
67 }
68
69 public List<MavenProject> getCollectedProjects() {
70
71 return wrapped.getCollectedProjects();
72 }
73
74 public List<Artifact> getCompileArtifacts() {
75 return wrapped.getCompileArtifacts();
76 }
77
78 public List<String> getCompileClasspathElements()
79 throws DependencyResolutionRequiredException {
80 return wrapped.getCompileClasspathElements();
81 }
82
83 public List<Dependency> getCompileDependencies() {
84 return wrapped.getCompileDependencies();
85 }
86
87 public List<String> getCompileSourceRoots() {
88 return wrapped.getCompileSourceRoots();
89 }
90
91 public List<Contributor> getContributors() {
92 return wrapped.getContributors();
93 }
94
95
96 public List<Dependency> getDependencies() {
97 return wrapped.getDependencies();
98 }
99
100
101 public Set<Artifact> getDependencyArtifacts() {
102 return wrapped.getDependencyArtifacts();
103 }
104
105
106 public List<Developer> getDevelopers() {
107 return wrapped.getDevelopers();
108 }
109
110
111 public Map<String, Artifact> getExtensionArtifactMap() {
112 return wrapped.getExtensionArtifactMap();
113 }
114
115
116 public Set<Artifact> getExtensionArtifacts() {
117 return wrapped.getExtensionArtifacts();
118 }
119
120
121 public List<String> getFilters() {
122 return wrapped.getFilters();
123 }
124
125
126 public List<License> getLicenses() {
127 return wrapped.getLicenses();
128 }
129
130
131 public List<MailingList> getMailingLists() {
132 return wrapped.getMailingLists();
133 }
134
135
136 public Map getManagedVersionMap() {
137
138 return wrapped.getManagedVersionMap();
139 }
140
141
142 public List<String> getModules() {
143 return wrapped.getModules();
144 }
145
146
147 public Map<String, Artifact> getPluginArtifactMap() {
148 return wrapped.getPluginArtifactMap();
149 }
150
151
152 public List<ArtifactRepository> getPluginArtifactRepositories() {
153 return wrapped.getPluginArtifactRepositories();
154 }
155
156
157 public Set<Artifact> getPluginArtifacts() {
158 return wrapped.getPluginArtifacts();
159 }
160
161
162 public List<Repository> getPluginRepositories() {
163 return wrapped.getPluginRepositories();
164 }
165
166
167 public Map<String, MavenProject> getProjectReferences() {
168 return wrapped.getProjectReferences();
169 }
170
171
172 public List<ArtifactRepository> getRemoteArtifactRepositories() {
173 return wrapped.getRemoteArtifactRepositories();
174 }
175
176
177 public Map<String, Artifact> getReportArtifactMap() {
178 return wrapped.getReportArtifactMap();
179 }
180
181
182 public Set<Artifact> getReportArtifacts() {
183 return wrapped.getReportArtifacts();
184 }
185
186
187 public List<Plugin> getReportPlugins() {
188 return wrapped.getReportPlugins();
189 }
190
191
192 public List<Repository> getRepositories() {
193 return wrapped.getRepositories();
194 }
195
196
197 public List<Resource> getResources() {
198 return wrapped.getResources();
199 }
200
201
202 public List<Artifact> getRuntimeArtifacts() {
203 return wrapped.getRuntimeArtifacts();
204 }
205
206
207 public List<String> getRuntimeClasspathElements()
208 throws DependencyResolutionRequiredException {
209 return wrapped.getRuntimeClasspathElements();
210 }
211
212
213 public List<Dependency> getRuntimeDependencies() {
214 return wrapped.getRuntimeDependencies();
215 }
216
217
218 public List<String> getScriptSourceRoots() {
219 return wrapped.getScriptSourceRoots();
220 }
221
222
223 public List<Artifact> getSystemArtifacts() {
224 return wrapped.getSystemArtifacts();
225 }
226
227
228 public List<String> getSystemClasspathElements()
229 throws DependencyResolutionRequiredException {
230 return wrapped.getSystemClasspathElements();
231 }
232
233
234 public List<Dependency> getSystemDependencies() {
235 return wrapped.getSystemDependencies();
236 }
237
238
239 public List<Artifact> getTestArtifacts() {
240 return wrapped.getTestArtifacts();
241 }
242
243
244 public List<String> getTestClasspathElements()
245 throws DependencyResolutionRequiredException {
246 return wrapped.getTestClasspathElements();
247 }
248
249
250 public List<String> getTestCompileSourceRoots() {
251 return wrapped.getTestCompileSourceRoots();
252 }
253
254
255 public List<Dependency> getTestDependencies() {
256 return wrapped.getTestDependencies();
257 }
258
259
260 public List<Resource> getTestResources() {
261 return wrapped.getTestResources();
262 }
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 public String apply(String key) {
284 if (key == null) {
285 return null;
286 }
287 if (System.getProperty(key) != null) {
288 return System.getProperty(key);
289 }
290 if (System.getenv(key) != null) {
291 return System.getenv(key);
292 }
293 if (key.equals("build.directory")
294 || key.equals("project.build.directory")
295 || key.equals("buildDirectory")
296 || key.equals("project.buildDirectory")) {
297 return getBuild().getDirectory();
298 }
299 if (key.equals("outputDirectory")
300 || key.equals("project.outputDirectory")
301 || key.equals("output.directory")
302 || key.equals("project.output.directory"))
303 return getBuild().getOutputDirectory();
304
305 if (key.equals("artifactId") || key.equals("project.artifactId")) {
306 return getArtifactId();
307 }
308
309 if (key.equals("basedir") || key.equals("project.basedir"))
310 return getBasedir().getAbsolutePath();
311
312 if (key.equals("defaultGoal") || key.equals("project.defaultGoal"))
313 return getBuild().getDefaultGoal();
314
315 if (key.equals("finalName") || key.equals("project.finalName"))
316 return getBuild().getFinalName();
317 if (key.equals("scriptSourceDirectory")
318 || key.equals("project.scriptSourceDirectory")
319 || key.equals("script.source.directory")
320 || key.equals("project.script.source.directory"))
321 return getBuild().getScriptSourceDirectory();
322 if (key.equals("source.directory")
323 || key.equals("project.source.directory")
324 || key.equals("sourceDirectory")
325 || key.equals("project.sourceDirectory"))
326 return getBuild().getSourceDirectory();
327 if (key.equals("test.output.directory")
328 || key.equals("project.test.output.directory")
329 || key.equals("testOutputDirectory")
330 || key.equals("project.testOutputDirectory"))
331 return getBuild().getTestOutputDirectory();
332 if (key.equals("test.source.directory")
333 || key.equals("project.test.source.directory")
334 || key.equals("testSourceDirectory")
335 || key.equals("project.testSourceDirectory"))
336 return getBuild().getTestSourceDirectory();
337 if (key.equals("directory") || key.equals("project.directory"))
338 return getDescription();
339 if (key.equals("pom"))
340 return getFile().getAbsolutePath();
341 if (key.equals("groupId") || key.equals("project.groupId"))
342 return getGroupId();
343 if (key.equals("id") || key.equals("project.id"))
344 return getId();
345 if (key.equals("inception") || key.equals("project.inception")
346 || key.equals("inceptionYear")
347 || key.equals("project.inceptionYear")
348 || key.equals("inception.year")
349 || key.equals("project.inception.year"))
350 return getInceptionYear();
351 if (key.equals("name") || key.equals("project.name"))
352 return getName();
353 if (key.equals("packaging") || key.equals("project.packaging"))
354 return getModel().getPackaging();
355 if (key.equals("url") || key.equals("project.url"))
356 return getModel().getUrl();
357 if (key.equals("version") || key.equals("project.version"))
358 return getModel().getVersion();
359
360 return wrapped.getProperties().getProperty(key);
361 }
362
363 public String apply(String key, String defaultValue) {
364 String result = apply(key);
365 if (result == null) {
366 return defaultValue;
367 }
368 return result;
369 }
370
371 public void update(String key, String value) {
372 if (key.equals("build.directory")
373 || key.equals("project.build.directory")
374 || key.equals("buildDirectory")
375 || key.equals("project.buildDirectory")) {
376 getBuild().setDirectory(value);
377 } else if (key.equals("outputDirectory")
378 || key.equals("project.outputDirectory")
379 || key.equals("output.directory")
380 || key.equals("project.output.directory")) {
381 getBuild().setOutputDirectory(value);
382 } else if (key.equals("artifactId") || key.equals("project.artifactId")) {
383 setArtifactId(value);
384 } else if (key.equals("defaultGoal")
385 || key.equals("project.defaultGoal")) {
386 getBuild().setDefaultGoal(value);
387 } else if (key.equals("finalName") || key.equals("project.finalName")) {
388 getBuild().setFinalName(value);
389 } else if (key.equals("scriptSourceDirectory")
390 || key.equals("project.scriptSourceDirectory")
391 || key.equals("script.source.directory")
392 || key.equals("project.script.source.directory")) {
393 getBuild().setScriptSourceDirectory(value);
394 } else if (key.equals("source.directory")
395 || key.equals("project.source.directory")
396 || key.equals("sourceDirectory")
397 || key.equals("project.sourceDirectory")) {
398 getBuild().setSourceDirectory(value);
399 } else if (key.equals("test.output.directory")
400 || key.equals("project.test.output.directory")
401 || key.equals("testOutputDirectory")
402 || key.equals("project.testOutputDirectory")) {
403 getBuild().setTestOutputDirectory(value);
404 } else if (key.equals("test.source.directory")
405 || key.equals("project.test.source.directory")
406 || key.equals("testSourceDirectory")
407 || key.equals("project.testSourceDirectory")) {
408 getBuild().setTestSourceDirectory(value);
409 } else if (key.equals("directory") || key.equals("project.directory")) {
410 setDescription(value);
411 } else if (key.equals("pom")) {
412 setFile(new File(value));
413 } else if (key.equals("groupId") || key.equals("project.groupId")) {
414 setGroupId(value);
415 } else if (key.equals("inception") || key.equals("project.inception")
416 || key.equals("inceptionYear")
417 || key.equals("project.inceptionYear")
418 || key.equals("inception.year")
419 || key.equals("project.inception.year")) {
420 setInceptionYear(value);
421 } else if (key.equals("name") || key.equals("project.name")) {
422 setName(value);
423 } else if (key.equals("packaging") || key.equals("project.packaging")) {
424 getModel().setPackaging(value);
425 } else if (key.equals("url") || key.equals("project.url")) {
426 getModel().setUrl(value);
427 } else if (key.equals("version") || key.equals("project.version")) {
428 getModel().setVersion(value);
429 } else {
430 wrapped.getProperties().setProperty(key, value);
431 }
432 }
433
434 public void update(String key, int value) {
435 update(key, String.valueOf(value));
436 }
437
438 public void update(String key, boolean value) {
439 update(key, String.valueOf(value));
440 }
441
442 public void update(String key, double value) {
443 update(key, String.valueOf(value));
444 }
445
446 public void update(String key, long value) {
447 update(key, String.valueOf(value));
448 }
449
450 public void update(String key, char value) {
451 update(key, String.valueOf(value));
452 }
453
454 public void update(String key, float value) {
455 update(key, String.valueOf(value));
456 }
457
458 public void update(String key, byte value) {
459 update(key, String.valueOf(value));
460 }
461
462 public void addAttachedArtifact(Artifact artifact) {
463 wrapped.addAttachedArtifact(artifact);
464 }
465
466 public void addCompileSourceRoot(String path) {
467 wrapped.addCompileSourceRoot(path);
468 }
469
470 public void addContributor(Contributor contributor) {
471 wrapped.addContributor(contributor);
472 }
473
474 public void addDeveloper(Developer developer) {
475 wrapped.addDeveloper(developer);
476 }
477
478 public void addLicense(License license) {
479 wrapped.addLicense(license);
480 }
481
482 public void addMailingList(MailingList mailingList) {
483 wrapped.addMailingList(mailingList);
484 }
485
486 public void addPlugin(Plugin plugin) {
487 wrapped.addPlugin(plugin);
488 }
489
490 public void addProjectReference(MavenProject project) {
491 wrapped.addProjectReference(project);
492 }
493
494 public void addResource(Resource resource) {
495 wrapped.addResource(resource);
496 }
497
498 public void addScriptSourceRoot(String path) {
499 wrapped.addScriptSourceRoot(path);
500 }
501
502 public void addTestCompileSourceRoot(String path) {
503 wrapped.addTestCompileSourceRoot(path);
504 }
505
506 public void addTestResource(Resource testResource) {
507 wrapped.addTestResource(testResource);
508 }
509
510 public Set<Artifact> createArtifacts(ArtifactFactory artifactFactory,
511 String inheritedScope, ArtifactFilter dependencyFilter)
512 throws InvalidDependencyVersionException {
513 return wrapped.createArtifacts(artifactFactory, inheritedScope,
514 dependencyFilter);
515 }
516
517 @Override
518 public boolean equals(Object arg0) {
519 return wrapped.equals(arg0);
520 }
521
522 public Artifact getArtifact() {
523 return wrapped.getArtifact();
524 }
525
526 public String getArtifactId() {
527 return wrapped.getArtifactId();
528 }
529
530 public File getBasedir() {
531 return wrapped.getBasedir();
532 }
533
534 public Build getBuild() {
535 return wrapped.getBuild();
536 }
537
538 public List getBuildExtensions() {
539 return wrapped.getBuildExtensions();
540 }
541
542 public CiManagement getCiManagement() {
543 return wrapped.getCiManagement();
544 }
545
546 public String getDefaultGoal() {
547 return wrapped.getDefaultGoal();
548 }
549
550 public DependencyManagement getDependencyManagement() {
551 return wrapped.getDependencyManagement();
552 }
553
554 public String getDescription() {
555 return wrapped.getDescription();
556 }
557
558 public DistributionManagement getDistributionManagement() {
559 return wrapped.getDistributionManagement();
560 }
561
562 public ArtifactRepository getDistributionManagementArtifactRepository() {
563 return wrapped.getDistributionManagementArtifactRepository();
564 }
565
566 public MavenProject getExecutionProject() {
567 return wrapped.getExecutionProject();
568 }
569
570 public File getFile() {
571 return wrapped.getFile();
572 }
573
574 public Xpp3Dom getGoalConfiguration(String arg0, String arg1, String arg2,
575 String arg3) {
576 return wrapped.getGoalConfiguration(arg0, arg1, arg2, arg3);
577 }
578
579 public String getGroupId() {
580 return wrapped.getGroupId();
581 }
582
583 public String getId() {
584 return wrapped.getId();
585 }
586
587 public String getInceptionYear() {
588 return wrapped.getInceptionYear();
589 }
590
591 public IssueManagement getIssueManagement() {
592 return wrapped.getIssueManagement();
593 }
594
595 public Model getModel() {
596 return wrapped.getModel();
597 }
598
599 public String getModelVersion() {
600 return wrapped.getModelVersion();
601 }
602
603 public String getModulePathAdjustment(MavenProject arg0) throws IOException {
604 return wrapped.getModulePathAdjustment(arg0);
605 }
606
607 public String getName() {
608 return wrapped.getName();
609 }
610
611 public Organization getOrganization() {
612 return wrapped.getOrganization();
613 }
614
615 public Model getOriginalModel() {
616 return wrapped.getOriginalModel();
617 }
618
619 public String getPackaging() {
620 return wrapped.getPackaging();
621 }
622
623 public MavenProject getParent() {
624 return wrapped.getParent();
625 }
626
627 public Artifact getParentArtifact() {
628 return wrapped.getParentArtifact();
629 }
630
631 public PluginManagement getPluginManagement() {
632 return wrapped.getPluginManagement();
633 }
634
635 public Prerequisites getPrerequisites() {
636 return wrapped.getPrerequisites();
637 }
638
639 public Properties getProperties() {
640 return wrapped.getProperties();
641 }
642
643 public Xpp3Dom getReportConfiguration(String arg0, String arg1, String arg2) {
644 return wrapped.getReportConfiguration(arg0, arg1, arg2);
645 }
646
647 public Reporting getReporting() {
648 return wrapped.getReporting();
649 }
650
651 public Scm getScm() {
652 return wrapped.getScm();
653 }
654
655 public String getUrl() {
656 return wrapped.getUrl();
657 }
658
659 public String getVersion() {
660 return wrapped.getVersion();
661 }
662
663 @Override
664 public int hashCode() {
665 return wrapped.hashCode();
666 }
667
668 public boolean hasParent() {
669 return wrapped.hasParent();
670 }
671
672 public void injectPluginManagementInfo(Plugin arg0) {
673 wrapped.injectPluginManagementInfo(arg0);
674 }
675
676 public boolean isExecutionRoot() {
677 return wrapped.isExecutionRoot();
678 }
679
680 public Artifact replaceWithActiveArtifact(Artifact arg0) {
681 return wrapped.replaceWithActiveArtifact(arg0);
682 }
683
684 public void setActiveProfiles(List<Profile> activeProfiles) {
685 wrapped.setActiveProfiles(activeProfiles);
686 }
687
688 public void setArtifact(Artifact artifact) {
689 wrapped.setArtifact(artifact);
690 }
691
692 public void setArtifactId(String artifactId) {
693 wrapped.setArtifactId(artifactId);
694 }
695
696 public void setArtifacts(Set<Artifact> artifacts) {
697 wrapped.setArtifacts(artifacts);
698 }
699
700 public void setBuild(Build build) {
701 wrapped.setBuild(build);
702 }
703
704 public void setCiManagement(CiManagement ciManagement) {
705 wrapped.setCiManagement(ciManagement);
706 }
707
708 public void setCollectedProjects(List<MavenProject> collectedProjects) {
709 wrapped.setCollectedProjects(collectedProjects);
710 }
711
712 public void setContributors(List<Contributor> contributors) {
713 wrapped.setContributors(contributors);
714 }
715
716 public void setDependencies(List dependencies) {
717 wrapped.setDependencies(dependencies);
718 }
719
720 public void setDependencyArtifacts(Set dependencyArtifacts) {
721 wrapped.setDependencyArtifacts(dependencyArtifacts);
722 }
723
724 public void setDescription(String description) {
725 wrapped.setDescription(description);
726 }
727
728 public void setDevelopers(List developers) {
729 wrapped.setDevelopers(developers);
730 }
731
732 public void setDistributionManagement(
733 DistributionManagement distributionManagement) {
734 wrapped.setDistributionManagement(distributionManagement);
735 }
736
737 public void setExecutionProject(MavenProject executionProject) {
738 wrapped.setExecutionProject(executionProject);
739 }
740
741 public void setExecutionRoot(boolean executionRoot) {
742 wrapped.setExecutionRoot(executionRoot);
743 }
744
745 public void setExtensionArtifacts(Set extensionArtifacts) {
746 wrapped.setExtensionArtifacts(extensionArtifacts);
747 }
748
749 public void setFile(File file) {
750 wrapped.setFile(file);
751 }
752
753 public void setGroupId(String groupId) {
754 wrapped.setGroupId(groupId);
755 }
756
757 public void setInceptionYear(String inceptionYear) {
758 wrapped.setInceptionYear(inceptionYear);
759 }
760
761 public void setIssueManagement(IssueManagement issueManagement) {
762 wrapped.setIssueManagement(issueManagement);
763 }
764
765 public void setLicenses(List licenses) {
766 wrapped.setLicenses(licenses);
767 }
768
769 public void setMailingLists(List mailingLists) {
770 wrapped.setMailingLists(mailingLists);
771 }
772
773 public void setManagedVersionMap(Map map) {
774 wrapped.setManagedVersionMap(map);
775 }
776
777 public void setModelVersion(String pomVersion) {
778 wrapped.setModelVersion(pomVersion);
779 }
780
781 public void setName(String name) {
782 wrapped.setName(name);
783 }
784
785 public void setOrganization(Organization organization) {
786 wrapped.setOrganization(organization);
787 }
788
789 public void setOriginalModel(Model originalModel) {
790 wrapped.setOriginalModel(originalModel);
791 }
792
793 public void setPackaging(String packaging) {
794 wrapped.setPackaging(packaging);
795 }
796
797 public void setParent(MavenProject parent) {
798 wrapped.setParent(parent);
799 }
800
801 public void setParentArtifact(Artifact parentArtifact) {
802 wrapped.setParentArtifact(parentArtifact);
803 }
804
805 public void setPluginArtifactRepositories(List pluginArtifactRepositories) {
806 wrapped.setPluginArtifactRepositories(pluginArtifactRepositories);
807 }
808
809 public void setPluginArtifacts(Set pluginArtifacts) {
810 wrapped.setPluginArtifacts(pluginArtifacts);
811 }
812
813 public void setReleaseArtifactRepository(
814 ArtifactRepository releaseArtifactRepository) {
815 wrapped.setReleaseArtifactRepository(releaseArtifactRepository);
816 }
817
818 public void setRemoteArtifactRepositories(List remoteArtifactRepositories) {
819 wrapped.setRemoteArtifactRepositories(remoteArtifactRepositories);
820 }
821
822 public void setReportArtifacts(Set reportArtifacts) {
823 wrapped.setReportArtifacts(reportArtifacts);
824 }
825
826 public void setReporting(Reporting reporting) {
827 wrapped.setReporting(reporting);
828 }
829
830 public void setScm(Scm scm) {
831 wrapped.setScm(scm);
832 }
833
834 public void setSnapshotArtifactRepository(
835 ArtifactRepository snapshotArtifactRepository) {
836 wrapped.setSnapshotArtifactRepository(snapshotArtifactRepository);
837 }
838
839 public void setUrl(String url) {
840 wrapped.setUrl(url);
841 }
842
843 public void setVersion(String version) {
844 wrapped.setVersion(version);
845 }
846
847 @Override
848 public String toString() {
849 return wrapped.toString();
850 }
851
852 public void writeModel(Writer writer) throws IOException {
853 wrapped.writeModel(writer);
854 }
855
856 public void writeOriginalModel(Writer writer) throws IOException {
857 wrapped.writeOriginalModel(writer);
858 }
859
860 public MavenProject getWrapped() {
861 return wrapped;
862 }
863
864 }