Coverage Report - org.apache.maven.model.converter.ModelUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
ModelUtils
0%
0/17
0%
0/20
6
 
 1  
 package org.apache.maven.model.converter;
 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 org.apache.maven.model.Model;
 23  
 import org.apache.maven.model.Plugin;
 24  
 import org.apache.maven.model.ReportPlugin;
 25  
 
 26  
 import java.util.Iterator;
 27  
 
 28  
 /**
 29  
  * Utility class which features various methods associated with Maven model.
 30  
  *
 31  
  * @author Dennis Lundberg
 32  
  * @version $Id: ModelUtils.java 661727 2008-05-30 14:21:49Z bentmann $
 33  
  */
 34  0
 public class ModelUtils
 35  
 {
 36  
     /**
 37  
      * Try to find a build plugin in a model.
 38  
      *
 39  
      * @param model      Look for the build plugin in this model
 40  
      * @param groupId    The groupId for the build plugin to look for
 41  
      * @param artifactId The artifactId for the build plugin to look for
 42  
      * @return The requested build plugin if it exists, otherwise null
 43  
      */
 44  
     public static Plugin findBuildPlugin( Model model, String groupId, String artifactId )
 45  
     {
 46  0
         if ( model.getBuild() == null || model.getBuild().getPlugins() == null )
 47  
         {
 48  0
             return null;
 49  
         }
 50  
 
 51  0
         Iterator iterator = model.getBuild().getPlugins().iterator();
 52  0
         while ( iterator.hasNext() )
 53  
         {
 54  0
             Plugin plugin = (Plugin) iterator.next();
 55  0
             if ( plugin.getGroupId().equals( groupId ) && plugin.getArtifactId().equals( artifactId ) )
 56  
             {
 57  0
                 return plugin;
 58  
             }
 59  
         }
 60  0
         return null;
 61  
     }
 62  
 
 63  
     /**
 64  
      * Try to find a report plugin in a model.
 65  
      *
 66  
      * @param model      Look for the report plugin in this model
 67  
      * @param groupId    The groupId for the report plugin to look for
 68  
      * @param artifactId The artifactId for the report plugin to look for
 69  
      * @return The requested report plugin if it exists, otherwise null
 70  
      */
 71  
     public static ReportPlugin findReportPlugin( Model model, String groupId, String artifactId )
 72  
     {
 73  0
         if ( model.getReporting() == null || model.getReporting().getPlugins() == null )
 74  
         {
 75  0
             return null;
 76  
         }
 77  
         
 78  0
         Iterator iterator = model.getReporting().getPlugins().iterator();
 79  0
         while ( iterator.hasNext() )
 80  
         {
 81  0
             ReportPlugin plugin = (ReportPlugin) iterator.next();
 82  0
             if ( plugin.getGroupId().equals( groupId ) && plugin.getArtifactId().equals( artifactId ) )
 83  
             {
 84  0
                 return plugin;
 85  
             }
 86  
         }
 87  0
         return null;
 88  
     }
 89  
 }