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.Plugin;
28  import org.apache.maven.model.PluginManagement;
29  import org.jdom2.Element;
30  
31  /**
32   * JDOM2 implementation of poms PLUGINMANAGEMENT element
33   *
34   * @author Robert Scholte
35   * @since 3.0
36   */
37  public class JDomPluginManagement extends PluginManagement
38  {
39      private final Element pluginManagement;
40  
41      /**
42       * <p>Constructor for JDomPluginManagement.</p>
43       *
44       * @param pluginManagement a {@link org.jdom2.Element} object
45       */
46      public JDomPluginManagement( Element pluginManagement )
47      {
48          this.pluginManagement = pluginManagement;
49      }
50  
51      @Override
52      public void addPlugin( Plugin plugin )
53      {
54          throw new UnsupportedOperationException();
55      }
56  
57      @Override
58      public List<Plugin> getPlugins()
59      {
60          Element pluginsElm = pluginManagement.getChild( "plugins", pluginManagement.getNamespace() );
61          if ( pluginsElm == null )
62          {
63              return Collections.emptyList();
64          }
65          else
66          {
67              List<Element> pluginElms = pluginsElm.getChildren( "plugin", pluginManagement.getNamespace() );
68  
69              List<Plugin> plugins = new ArrayList<>( pluginElms.size() );
70  
71              for ( Element pluginElm : pluginElms )
72              {
73                  plugins.add( new JDomPlugin( pluginElm ) );
74              }
75  
76              return plugins;
77          }
78      }
79  
80      @Override
81      public void removePlugin( Plugin plugin )
82      {
83          throw new UnsupportedOperationException();
84      }
85  
86      @Override
87      public void setPlugins( List<Plugin> plugins )
88      {
89          throw new UnsupportedOperationException();
90      }
91  
92      @Override
93      public void flushPluginMap()
94      {
95          throw new UnsupportedOperationException();
96      }
97  
98      @Override
99      public Map<String, Plugin> getPluginsAsMap()
100     {
101         throw new UnsupportedOperationException();
102     }
103 }