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      /**
45       * <p>Constructor for JDomBuild.</p>
46       *
47       * @param build a {@link org.jdom2.Element} object
48       */
49      public JDomBuild( Element build )
50      {
51          this.build = build;
52      }
53  
54      @Override
55      public void addExtension( Extension extension )
56      {
57          throw new UnsupportedOperationException();
58      }
59  
60      @Override
61      public List<Extension> getExtensions()
62      {
63          Element extensionsElm = build.getChild( "extensions", build.getNamespace() );
64          if ( extensionsElm == null )
65          {
66              return Collections.emptyList();
67          }
68          else
69          {
70              List<Element> extensionElms = extensionsElm.getChildren( "extension", build.getNamespace() );
71  
72              List<Extension> extensions = new ArrayList<>( extensionElms.size() );
73              for ( Element extensionElm : extensionElms )
74              {
75                  extensions.add( new JDomExtension( extensionElm ) );
76              }
77              return extensions;
78          }
79      }
80  
81      @Override
82      public String getOutputDirectory()
83      {
84          throw new UnsupportedOperationException();
85      }
86  
87      @Override
88      public String getScriptSourceDirectory()
89      {
90          throw new UnsupportedOperationException();
91      }
92  
93      @Override
94      public String getSourceDirectory()
95      {
96          throw new UnsupportedOperationException();
97      }
98  
99      @Override
100     public String getTestOutputDirectory()
101     {
102         throw new UnsupportedOperationException();
103     }
104 
105     @Override
106     public String getTestSourceDirectory()
107     {
108         throw new UnsupportedOperationException();
109     }
110 
111     @Override
112     public void removeExtension( Extension extension )
113     {
114         throw new UnsupportedOperationException();
115     }
116 
117     @Override
118     public void setExtensions( List<Extension> extensions )
119     {
120         throw new UnsupportedOperationException();
121     }
122 
123     @Override
124     public void setOutputDirectory( String outputDirectory )
125     {
126         throw new UnsupportedOperationException();
127     }
128 
129     @Override
130     public void setScriptSourceDirectory( String scriptSourceDirectory )
131     {
132         throw new UnsupportedOperationException();
133     }
134 
135     @Override
136     public void setSourceDirectory( String sourceDirectory )
137     {
138         throw new UnsupportedOperationException();
139     }
140 
141     @Override
142     public void setTestOutputDirectory( String testOutputDirectory )
143     {
144         throw new UnsupportedOperationException();
145     }
146 
147     @Override
148     public void setTestSourceDirectory( String testSourceDirectory )
149     {
150         throw new UnsupportedOperationException();
151     }
152 
153     @Override
154     public void addFilter( String string )
155     {
156         throw new UnsupportedOperationException();
157     }
158 
159     @Override
160     public void addResource( Resource resource )
161     {
162         throw new UnsupportedOperationException();
163     }
164 
165     @Override
166     public void addTestResource( Resource resource )
167     {
168         throw new UnsupportedOperationException();
169     }
170 
171     @Override
172     public String getDefaultGoal()
173     {
174         throw new UnsupportedOperationException();
175     }
176 
177     @Override
178     public String getDirectory()
179     {
180         throw new UnsupportedOperationException();
181     }
182 
183     @Override
184     public List<String> getFilters()
185     {
186         throw new UnsupportedOperationException();
187     }
188 
189     @Override
190     public String getFinalName()
191     {
192         throw new UnsupportedOperationException();
193     }
194 
195     @Override
196     public List<Resource> getResources()
197     {
198         throw new UnsupportedOperationException();
199     }
200 
201     @Override
202     public List<Resource> getTestResources()
203     {
204         throw new UnsupportedOperationException();
205     }
206 
207     @Override
208     public void removeFilter( String string )
209     {
210         throw new UnsupportedOperationException();
211     }
212 
213     @Override
214     public void removeResource( Resource resource )
215     {
216         throw new UnsupportedOperationException();
217     }
218 
219     @Override
220     public void removeTestResource( Resource resource )
221     {
222         throw new UnsupportedOperationException();
223     }
224 
225     @Override
226     public void setDefaultGoal( String defaultGoal )
227     {
228         throw new UnsupportedOperationException();
229     }
230 
231     @Override
232     public void setDirectory( String directory )
233     {
234         throw new UnsupportedOperationException();
235     }
236 
237     @Override
238     public void setFilters( List<String> filters )
239     {
240         throw new UnsupportedOperationException();
241     }
242 
243     @Override
244     public void setFinalName( String finalName )
245     {
246         throw new UnsupportedOperationException();
247     }
248 
249     @Override
250     public void setResources( List<Resource> resources )
251     {
252         throw new UnsupportedOperationException();
253     }
254 
255     @Override
256     public void setTestResources( List<Resource> testResources )
257     {
258         throw new UnsupportedOperationException();
259     }
260 
261     @Override
262     public PluginManagement getPluginManagement()
263     {
264         Element pluginManagementElm = build.getChild( "pluginManagement", build.getNamespace() );
265         if ( pluginManagementElm == null )
266         {
267             return null;
268         }
269         else
270         {
271             return new JDomPluginManagement( pluginManagementElm );
272         }
273     }
274 
275     @Override
276     public void setPluginManagement( PluginManagement pluginManagement )
277     {
278         throw new UnsupportedOperationException();
279     }
280 
281     @Override
282     public void addPlugin( Plugin plugin )
283     {
284         throw new UnsupportedOperationException();
285     }
286 
287     @Override
288     public List<Plugin> getPlugins()
289     {
290         Element pluginsElm = build.getChild( "plugins", build.getNamespace() );
291         if ( pluginsElm == null )
292         {
293             return Collections.emptyList();
294         }
295         else
296         {
297             List<Element> pluginElms =
298                 pluginsElm.getChildren( "plugin", build.getNamespace() );
299 
300             List<Plugin> plugins = new ArrayList<>( pluginElms.size() );
301 
302             for ( Element pluginElm : pluginElms )
303             {
304                 plugins.add( new JDomPlugin( pluginElm ) );
305             }
306 
307             return plugins;
308         }
309     }
310 
311     @Override
312     public void removePlugin( Plugin plugin )
313     {
314         throw new UnsupportedOperationException();
315     }
316 
317     @Override
318     public void setPlugins( List<Plugin> plugins )
319     {
320         throw new UnsupportedOperationException();
321     }
322 
323     @Override
324     public void flushPluginMap()
325     {
326         throw new UnsupportedOperationException();
327     }
328 
329     @Override
330     public Map<String, Plugin> getPluginsAsMap()
331     {
332         throw new UnsupportedOperationException();
333     }
334 }