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      public JDomPluginManagement( Element pluginManagement )
42      {
43          this.pluginManagement = pluginManagement;
44      }
45  
46      @Override
47      public void addPlugin( Plugin plugin )
48      {
49          throw new UnsupportedOperationException();
50      }
51  
52      @Override
53      public List<Plugin> getPlugins()
54      {
55          Element pluginsElm = pluginManagement.getChild( "plugins", pluginManagement.getNamespace() );
56          if ( pluginsElm == null )
57          {
58              return Collections.emptyList();
59          }
60          else
61          {
62              List<Element> pluginElms = pluginsElm.getChildren( "plugin", pluginManagement.getNamespace() );
63  
64              List<Plugin> plugins = new ArrayList<>( pluginElms.size() );
65  
66              for ( Element pluginElm : pluginElms )
67              {
68                  plugins.add( new JDomPlugin( pluginElm ) );
69              }
70  
71              return plugins;
72          }
73      }
74  
75      @Override
76      public void removePlugin( Plugin plugin )
77      {
78          throw new UnsupportedOperationException();
79      }
80  
81      @Override
82      public void setPlugins( List<Plugin> plugins )
83      {
84          throw new UnsupportedOperationException();
85      }
86  
87      @Override
88      public void flushPluginMap()
89      {
90          throw new UnsupportedOperationException();
91      }
92  
93      @Override
94      public Map<String, Plugin> getPluginsAsMap()
95      {
96          throw new UnsupportedOperationException();
97      }
98  }