1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.maven.plugins.externals;
17
18 import java.io.File;
19 import java.util.List;
20 import java.util.Map;
21
22 import javax.swing.tree.DefaultMutableTreeNode;
23
24 import org.apache.maven.plugin.AbstractMojo;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.project.MavenProject;
27
28
29
30
31
32
33
34 public class ValidatePomsMojo extends AbstractMojo {
35
36 SVNUtils svnUtils = SVNUtils.getInstance();
37 MojoHelper helper = MojoHelper.getInstance();
38
39
40
41
42
43
44 private String pom;
45
46
47
48
49
50
51 private String ignoreDirectories;
52
53
54
55
56
57
58
59 private MavenProject project;
60
61
62
63
64
65
66 private List<Mapping> mappings;
67
68 @Override
69 public void execute() throws MojoExecutionException {
70 List<File> files = helper.getPoms(project.getBasedir(), pom, ignoreDirectories);
71 List<DefaultMutableTreeNode> nodes = helper.getNodes(files);
72
73 DefaultMutableTreeNode node = helper.getTree(project.getBasedir(), nodes, pom);
74
75 helper.fillInGavs(node);
76
77 Map<String, DefaultMutableTreeNode> map = helper.getGavMap(node);
78
79 helper.validateParents(node, map);
80 helper.validateMappings(project.getProperties(), mappings, node);
81 int depth = node.getDepth();
82 int size = nodes.size();
83 getLog().info("Validated " + size + " POM's. Multi-module Maven project depth: " + depth);
84 }
85
86 public String getPom() {
87 return pom;
88 }
89
90 public void setPom(String pom) {
91 this.pom = pom;
92 }
93
94 public String getIgnoreDirectories() {
95 return ignoreDirectories;
96 }
97
98 public void setIgnoreDirectories(String ignoreDirectories) {
99 this.ignoreDirectories = ignoreDirectories;
100 }
101
102 public MavenProject getProject() {
103 return project;
104 }
105
106 public void setProject(MavenProject project) {
107 this.project = project;
108 }
109
110 public List<Mapping> getMappings() {
111 return mappings;
112 }
113
114 public void setMappings(List<Mapping> mappings) {
115 this.mappings = mappings;
116 }
117 }