1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class WarPluginInfo
40 {
41 private MavenProject _project;
42 private Plugin _plugin;
43 private List<String> _dependentMavenWarIncludes;
44 private List<String> _dependentMavenWarExcludes;
45 private List<OverlayConfig> _overlayConfigs;
46
47
48
49
50
51
52 public WarPluginInfo (MavenProject project)
53 {
54 _project = project;
55 }
56
57
58
59
60
61
62
63
64 public Plugin getPlugin()
65 {
66 if (_plugin == null)
67 {
68 List plugins = _project.getBuildPlugins();
69 if (plugins == null)
70 return null;
71
72
73 Iterator itor = plugins.iterator();
74 while (itor.hasNext() && _plugin==null)
75 {
76 Plugin plugin = (Plugin)itor.next();
77 if ("maven-war-plugin".equals(plugin.getArtifactId()))
78 _plugin = plugin;
79 }
80 }
81 return _plugin;
82 }
83
84
85
86
87
88
89
90
91 public List<String> getDependentMavenWarIncludes()
92 {
93 if (_dependentMavenWarIncludes == null)
94 {
95 getPlugin();
96
97 if (_plugin == null)
98 return null;
99
100 Xpp3Dom node = (Xpp3Dom)_plugin.getConfiguration();
101 if (node == null)
102 return null;
103
104 node = node.getChild("dependentWarIncludes");
105 if (node == null)
106 return null;
107 String val = node.getValue();
108 _dependentMavenWarIncludes = Arrays.asList(val.split(","));
109 }
110 return _dependentMavenWarIncludes;
111 }
112
113
114
115
116
117
118
119
120 public List<String> getDependentMavenWarExcludes()
121 {
122 if (_dependentMavenWarExcludes == null)
123 {
124 getPlugin();
125
126 if (_plugin == null)
127 return null;
128
129 Xpp3Dom node = (Xpp3Dom)_plugin.getConfiguration();
130 if (node == null)
131 return null;
132
133 node = node.getChild("dependentWarExcludes");
134 if (node == null)
135 return null;
136 String val = node.getValue();
137 _dependentMavenWarExcludes = Arrays.asList(val.split(","));
138 }
139 return _dependentMavenWarExcludes;
140 }
141
142
143
144
145
146
147
148
149
150 public List<OverlayConfig> getMavenWarOverlayConfigs ()
151 {
152 if (_overlayConfigs == null)
153 {
154 getPlugin();
155
156 if (_plugin == null)
157 return Collections.emptyList();
158
159 getDependentMavenWarIncludes();
160 getDependentMavenWarExcludes();
161
162 Xpp3Dom node = (Xpp3Dom)_plugin.getConfiguration();
163 if (node == null)
164 return Collections.emptyList();
165
166 node = node.getChild("overlays");
167 if (node == null)
168 return Collections.emptyList();
169
170 Xpp3Dom[] nodes = node.getChildren("overlay");
171 if (nodes == null)
172 return Collections.emptyList();
173
174 _overlayConfigs = new ArrayList<OverlayConfig>();
175 for (int i=0;i<nodes.length;i++)
176 {
177 OverlayConfig overlayConfig = new OverlayConfig(nodes[i], _dependentMavenWarIncludes, _dependentMavenWarExcludes);
178 _overlayConfigs.add(overlayConfig);
179 }
180 }
181
182 return _overlayConfigs;
183 }
184
185
186
187
188
189
190
191 public String getMavenWarOverlayConfigAsString ()
192 {
193 getPlugin();
194
195 if (_plugin == null)
196 return "";
197
198 Xpp3Dom node = (Xpp3Dom)_plugin.getConfiguration();
199 if (node == null)
200 return "";
201 return node.toString();
202 }
203 }