View Javadoc
1   package org.apache.maven.shared.release.transform.jdom2;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.Collections;
24  import java.util.List;
25  import java.util.Map;
26  
27  import org.apache.maven.model.Build;
28  import org.apache.maven.model.Extension;
29  import org.apache.maven.model.Plugin;
30  import org.apache.maven.model.PluginManagement;
31  import org.apache.maven.model.Resource;
32  import org.jdom2.Element;
33  /**
34   * JDOM2 implementation of poms BUILD element
35   *
36   * @author Robert Scholte
37   * @since 3.0
38   */
39  public class JDomBuild
40      extends Build
41  {
42      private final Element build;
43  
44      public JDomBuild( Element build )
45      {
46          this.build = build;
47      }
48  
49      @Override
50      public void addExtension( Extension extension )
51      {
52          throw new UnsupportedOperationException();
53      }
54  
55      @Override
56      public List<Extension> getExtensions()
57      {
58          Element extensionsElm = build.getChild( "extensions", build.getNamespace() );
59          if ( extensionsElm == null )
60          {
61              return Collections.emptyList();
62          }
63          else
64          {
65              List<Element> extensionElms = extensionsElm.getChildren( "extension", build.getNamespace() );
66  
67              List<Extension> extensions = new ArrayList<>( extensionElms.size() );
68              for ( Element extensionElm : extensionElms )
69              {
70                  extensions.add( new JDomExtension( extensionElm ) );
71              }
72              return extensions;
73          }
74      }
75  
76      @Override
77      public String getOutputDirectory()
78      {
79          throw new UnsupportedOperationException();
80      }
81  
82      @Override
83      public String getScriptSourceDirectory()
84      {
85          throw new UnsupportedOperationException();
86      }
87  
88      @Override
89      public String getSourceDirectory()
90      {
91          throw new UnsupportedOperationException();
92      }
93  
94      @Override
95      public String getTestOutputDirectory()
96      {
97          throw new UnsupportedOperationException();
98      }
99  
100     @Override
101     public String getTestSourceDirectory()
102     {
103         throw new UnsupportedOperationException();
104     }
105 
106     @Override
107     public void removeExtension( Extension extension )
108     {
109         throw new UnsupportedOperationException();
110     }
111 
112     @Override
113     public void setExtensions( List<Extension> extensions )
114     {
115         throw new UnsupportedOperationException();
116     }
117 
118     @Override
119     public void setOutputDirectory( String outputDirectory )
120     {
121         throw new UnsupportedOperationException();
122     }
123 
124     @Override
125     public void setScriptSourceDirectory( String scriptSourceDirectory )
126     {
127         throw new UnsupportedOperationException();
128     }
129 
130     @Override
131     public void setSourceDirectory( String sourceDirectory )
132     {
133         throw new UnsupportedOperationException();
134     }
135 
136     @Override
137     public void setTestOutputDirectory( String testOutputDirectory )
138     {
139         throw new UnsupportedOperationException();
140     }
141 
142     @Override
143     public void setTestSourceDirectory( String testSourceDirectory )
144     {
145         throw new UnsupportedOperationException();
146     }
147 
148     @Override
149     public void addFilter( String string )
150     {
151         throw new UnsupportedOperationException();
152     }
153 
154     @Override
155     public void addResource( Resource resource )
156     {
157         throw new UnsupportedOperationException();
158     }
159 
160     @Override
161     public void addTestResource( Resource resource )
162     {
163         throw new UnsupportedOperationException();
164     }
165 
166     @Override
167     public String getDefaultGoal()
168     {
169         throw new UnsupportedOperationException();
170     }
171 
172     @Override
173     public String getDirectory()
174     {
175         throw new UnsupportedOperationException();
176     }
177 
178     @Override
179     public List<String> getFilters()
180     {
181         throw new UnsupportedOperationException();
182     }
183 
184     @Override
185     public String getFinalName()
186     {
187         throw new UnsupportedOperationException();
188     }
189 
190     @Override
191     public List<Resource> getResources()
192     {
193         throw new UnsupportedOperationException();
194     }
195 
196     @Override
197     public List<Resource> getTestResources()
198     {
199         throw new UnsupportedOperationException();
200     }
201 
202     @Override
203     public void removeFilter( String string )
204     {
205         throw new UnsupportedOperationException();
206     }
207 
208     @Override
209     public void removeResource( Resource resource )
210     {
211         throw new UnsupportedOperationException();
212     }
213 
214     @Override
215     public void removeTestResource( Resource resource )
216     {
217         throw new UnsupportedOperationException();
218     }
219 
220     @Override
221     public void setDefaultGoal( String defaultGoal )
222     {
223         throw new UnsupportedOperationException();
224     }
225 
226     @Override
227     public void setDirectory( String directory )
228     {
229         throw new UnsupportedOperationException();
230     }
231 
232     @Override
233     public void setFilters( List<String> filters )
234     {
235         throw new UnsupportedOperationException();
236     }
237 
238     @Override
239     public void setFinalName( String finalName )
240     {
241         throw new UnsupportedOperationException();
242     }
243 
244     @Override
245     public void setResources( List<Resource> resources )
246     {
247         throw new UnsupportedOperationException();
248     }
249 
250     @Override
251     public void setTestResources( List<Resource> testResources )
252     {
253         throw new UnsupportedOperationException();
254     }
255 
256     @Override
257     public PluginManagement getPluginManagement()
258     {
259         Element pluginManagementElm = build.getChild( "pluginManagement", build.getNamespace() );
260         if ( pluginManagementElm == null )
261         {
262             return null;
263         }
264         else
265         {
266             return new JDomPluginManagement( pluginManagementElm );
267         }
268     }
269 
270     @Override
271     public void setPluginManagement( PluginManagement pluginManagement )
272     {
273         throw new UnsupportedOperationException();
274     }
275 
276     @Override
277     public void addPlugin( Plugin plugin )
278     {
279         throw new UnsupportedOperationException();
280     }
281 
282     @Override
283     public List<Plugin> getPlugins()
284     {
285         Element pluginsElm = build.getChild( "plugins", build.getNamespace() );
286         if ( pluginsElm == null )
287         {
288             return Collections.emptyList();
289         }
290         else
291         {
292             List<Element> pluginElms =
293                 pluginsElm.getChildren( "plugin", build.getNamespace() );
294 
295             List<Plugin> plugins = new ArrayList<>( pluginElms.size() );
296 
297             for ( Element pluginElm : pluginElms )
298             {
299                 plugins.add( new JDomPlugin( pluginElm ) );
300             }
301 
302             return plugins;
303         }
304     }
305 
306     @Override
307     public void removePlugin( Plugin plugin )
308     {
309         throw new UnsupportedOperationException();
310     }
311 
312     @Override
313     public void setPlugins( List<Plugin> plugins )
314     {
315         throw new UnsupportedOperationException();
316     }
317 
318     @Override
319     public void flushPluginMap()
320     {
321         throw new UnsupportedOperationException();
322     }
323 
324     @Override
325     public Map<String, Plugin> getPluginsAsMap()
326     {
327         throw new UnsupportedOperationException();
328     }
329 }