Coverage Report - org.apache.maven.report.projectinfo.DependencyManagementReport
 
Classes in this File Line Coverage Branch Coverage Complexity
DependencyManagementReport
86%
12/14
75%
3/4
1,5
 
 1  
 package org.apache.maven.report.projectinfo;
 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.List;
 23  
 import java.util.Locale;
 24  
 
 25  
 import org.apache.maven.artifact.factory.ArtifactFactory;
 26  
 import org.apache.maven.project.MavenProjectBuilder;
 27  
 import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies;
 28  
 import org.apache.maven.report.projectinfo.dependencies.renderer.DependencyManagementRenderer;
 29  
 
 30  
 
 31  
 /**
 32  
  * Generates the Project Dependency Management report.
 33  
  *
 34  
  * @author Nick Stolwijk
 35  
  * @version $Id: DependencyManagementReport.java 728546 2008-12-21 22:56:51Z bentmann $
 36  
  * @since 2.1
 37  
  * @goal dependency-management
 38  
  * @requiresDependencyResolution test
 39  
  */
 40  1
 public class DependencyManagementReport
 41  
     extends AbstractProjectInfoReport
 42  
 {
 43  
     // ----------------------------------------------------------------------
 44  
     // Mojo components
 45  
     // ----------------------------------------------------------------------
 46  
 
 47  
     /**
 48  
      * Maven Project Builder component.
 49  
      *
 50  
      * @component
 51  
      */
 52  
     private MavenProjectBuilder mavenProjectBuilder;
 53  
 
 54  
     /**
 55  
      * Maven Artifact Factory component.
 56  
      *
 57  
      * @component
 58  
      */
 59  
     private ArtifactFactory artifactFactory;
 60  
 
 61  
     // ----------------------------------------------------------------------
 62  
     // Mojo parameters
 63  
     // ----------------------------------------------------------------------
 64  
 
 65  
     /**
 66  
      * Remote repositories used for the project.
 67  
      *
 68  
      * @since 2.1
 69  
      * @parameter expression="${project.remoteArtifactRepositories}"
 70  
      */
 71  
     private List remoteRepositories;
 72  
 
 73  
     /**
 74  
      * Lazy instantiation for management dependencies.
 75  
      */
 76  
     private ManagementDependencies managementDependencies;
 77  
 
 78  
     // ----------------------------------------------------------------------
 79  
     // Public methods
 80  
     // ----------------------------------------------------------------------
 81  
 
 82  
     /** {@inheritDoc} */
 83  
     public String getName( Locale locale )
 84  
     {
 85  1
         return i18n.getString( "project-info-report", locale, "report.dependencyManagement.name" );
 86  
     }
 87  
 
 88  
     /** {@inheritDoc} */
 89  
     public String getDescription( Locale locale )
 90  
     {
 91  0
         return i18n.getString( "project-info-report", locale, "report.dependencyManagement.description" );
 92  
     }
 93  
 
 94  
     /** {@inheritDoc} */
 95  
     public void executeReport( Locale locale )
 96  
     {
 97  1
         DependencyManagementRenderer r = new DependencyManagementRenderer( getSink(), locale, i18n, getLog(),
 98  
                                                                            getManagementDependencies(),
 99  
                                                                            artifactFactory, mavenProjectBuilder,
 100  
                                                                            remoteRepositories, localRepository );
 101  1
         r.render();
 102  1
     }
 103  
 
 104  
     /** {@inheritDoc} */
 105  
     public String getOutputName()
 106  
     {
 107  3
         return "dependency-management";
 108  
     }
 109  
 
 110  
     /** {@inheritDoc} */
 111  
     public boolean canGenerateReport()
 112  
     {
 113  1
         return getManagementDependencies().hasDependencies();
 114  
     }
 115  
 
 116  
     // ----------------------------------------------------------------------
 117  
     // Private methods
 118  
     // ----------------------------------------------------------------------
 119  
 
 120  
     private ManagementDependencies getManagementDependencies()
 121  
     {
 122  2
         if ( managementDependencies != null )
 123  
         {
 124  1
             return managementDependencies;
 125  
         }
 126  
 
 127  1
         if ( project.getDependencyManagement() == null )
 128  
         {
 129  0
             managementDependencies = new ManagementDependencies( null );
 130  
         }
 131  
         else
 132  
         {
 133  1
             managementDependencies = new ManagementDependencies( project.getDependencyManagement().getDependencies() );
 134  
         }
 135  
 
 136  1
         return managementDependencies;
 137  
     }
 138  
 }