View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.shared.release.transform.jdom2;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.maven.model.Plugin;
27  import org.apache.maven.model.PluginManagement;
28  import org.jdom2.Element;
29  
30  /**
31   * JDOM2 implementation of poms PLUGINMANAGEMENT element
32   *
33   * @author Robert Scholte
34   * @since 3.0
35   */
36  public class JDomPluginManagement extends PluginManagement {
37      private final Element pluginManagement;
38  
39      /**
40       * <p>Constructor for JDomPluginManagement.</p>
41       *
42       * @param pluginManagement a {@link org.jdom2.Element} object
43       */
44      public JDomPluginManagement(Element pluginManagement) {
45          this.pluginManagement = pluginManagement;
46      }
47  
48      @Override
49      public void addPlugin(Plugin plugin) {
50          throw new UnsupportedOperationException();
51      }
52  
53      @Override
54      public List<Plugin> getPlugins() {
55          Element pluginsElm = pluginManagement.getChild("plugins", pluginManagement.getNamespace());
56          if (pluginsElm == null) {
57              return Collections.emptyList();
58          } else {
59              List<Element> pluginElms = pluginsElm.getChildren("plugin", pluginManagement.getNamespace());
60  
61              List<Plugin> plugins = new ArrayList<>(pluginElms.size());
62  
63              for (Element pluginElm : pluginElms) {
64                  plugins.add(new JDomPlugin(pluginElm));
65              }
66  
67              return plugins;
68          }
69      }
70  
71      @Override
72      public void removePlugin(Plugin plugin) {
73          throw new UnsupportedOperationException();
74      }
75  
76      @Override
77      public void setPlugins(List<Plugin> plugins) {
78          throw new UnsupportedOperationException();
79      }
80  
81      @Override
82      public void flushPluginMap() {
83          throw new UnsupportedOperationException();
84      }
85  
86      @Override
87      public Map<String, Plugin> getPluginsAsMap() {
88          throw new UnsupportedOperationException();
89      }
90  }