Coverage Report - org.apache.maven.report.projectinfo.DistributionManagementReport
 
Classes in this File Line Coverage Branch Coverage Complexity
DistributionManagementReport
0 %
0/7
N/A
0
DistributionManagementReport$DistributionManagementRenderer
0 %
0/50
0 %
0/28
0
 
 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.Locale;
 23  
 
 24  
 import org.apache.maven.doxia.sink.Sink;
 25  
 import org.apache.maven.model.DistributionManagement;
 26  
 import org.apache.maven.project.MavenProject;
 27  
 import org.codehaus.plexus.i18n.I18N;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 
 30  
 /**
 31  
  * Generates the Project Distribution Management report.
 32  
  *
 33  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
 34  
  * @version $Id: DistributionManagementReport.java 1036268 2010-11-17 22:49:50Z vsiveton $
 35  
  * @since 2.3
 36  
  * @goal distribution-management
 37  
  */
 38  0
 public class DistributionManagementReport
 39  
     extends AbstractProjectInfoReport
 40  
 {
 41  
     // ----------------------------------------------------------------------
 42  
     // Public methods
 43  
     // ----------------------------------------------------------------------
 44  
 
 45  
     @Override
 46  
     public void executeReport( Locale locale )
 47  
     {
 48  0
         DistributionManagementRenderer r =
 49  
             new DistributionManagementRenderer( getSink(), getProject(), getI18N( locale ), locale );
 50  
 
 51  0
         r.render();
 52  0
     }
 53  
 
 54  
     /** {@inheritDoc} */
 55  
     public String getOutputName()
 56  
     {
 57  0
         return "distribution-management";
 58  
     }
 59  
 
 60  
     @Override
 61  
     protected String getI18Nsection()
 62  
     {
 63  0
         return "distributionManagement";
 64  
     }
 65  
 
 66  
     // ----------------------------------------------------------------------
 67  
     // Private
 68  
     // ----------------------------------------------------------------------
 69  
 
 70  
     /**
 71  
      * Internal renderer class
 72  
      */
 73  0
     private static class DistributionManagementRenderer
 74  
         extends AbstractProjectInfoRenderer
 75  
     {
 76  
         private final MavenProject project;
 77  
 
 78  
         DistributionManagementRenderer( Sink sink, MavenProject project, I18N i18n, Locale locale )
 79  
         {
 80  0
             super( sink, i18n, locale );
 81  
 
 82  0
             this.project = project;
 83  0
         }
 84  
 
 85  
         @Override
 86  
         protected String getI18Nsection()
 87  
         {
 88  0
             return "distributionManagement";
 89  
         }
 90  
 
 91  
         @Override
 92  
         public void renderBody()
 93  
         {
 94  0
             DistributionManagement distributionManagement = project.getDistributionManagement();
 95  0
             if ( distributionManagement == null )
 96  
             {
 97  0
                 startSection( getI18nString( "overview.title" ) );
 98  
 
 99  0
                 paragraph( getI18nString( "nodistributionmanagement" ) );
 100  
 
 101  0
                 endSection();
 102  
 
 103  0
                 return;
 104  
             }
 105  
 
 106  0
             startSection( getI18nString( "overview.title" ) );
 107  0
             paragraph( getI18nString( "overview.intro" ) );
 108  
 
 109  0
             if ( StringUtils.isNotEmpty( distributionManagement.getDownloadUrl() ) )
 110  
             {
 111  0
                 startSection( getI18nString( "downloadURL" ) );
 112  0
                 internalLink( distributionManagement.getDownloadUrl() );
 113  0
                 endSection();
 114  
             }
 115  
 
 116  0
             if ( distributionManagement.getRelocation() != null )
 117  
             {
 118  0
                 startSection( getI18nString( "relocation" ) );
 119  0
                 startTable();
 120  0
                 tableHeader( new String[] { getI18nString( "field" ), getI18nString( "value" ) } );
 121  0
                 tableRow( new String[] { getI18nString( "relocation.groupid" ),
 122  
                     distributionManagement.getRelocation().getGroupId() } );
 123  0
                 tableRow( new String[] { getI18nString( "relocation.artifactid" ),
 124  
                     distributionManagement.getRelocation().getArtifactId() } );
 125  0
                 tableRow( new String[] { getI18nString( "relocation.version" ),
 126  
                     distributionManagement.getRelocation().getVersion() } );
 127  0
                 tableRow( new String[] { getI18nString( "relocation.message" ),
 128  
                     distributionManagement.getRelocation().getMessage() } );
 129  0
                 endTable();
 130  0
                 endSection();
 131  
             }
 132  
 
 133  0
             if ( distributionManagement.getRepository() != null
 134  
                 && StringUtils.isNotEmpty( distributionManagement.getRepository().getUrl() ) )
 135  
             {
 136  0
                 startSection( getI18nString( "repository" )
 137  
                     + getRepoName( distributionManagement.getRepository().getId() ) );
 138  0
                 internalLink( distributionManagement.getRepository().getUrl() );
 139  0
                 endSection();
 140  
             }
 141  
 
 142  0
             if ( distributionManagement.getSnapshotRepository() != null
 143  
                 && StringUtils.isNotEmpty( distributionManagement.getSnapshotRepository().getUrl() ) )
 144  
             {
 145  0
                 startSection( getI18nString( "snapshotRepository" )
 146  
                     + getRepoName( distributionManagement.getSnapshotRepository().getId() ) );
 147  0
                 internalLink( distributionManagement.getSnapshotRepository().getUrl() );
 148  0
                 endSection();
 149  
             }
 150  
 
 151  0
             if ( distributionManagement.getSite() != null
 152  
                 && StringUtils.isNotEmpty( distributionManagement.getSite().getUrl() ) )
 153  
             {
 154  0
                 startSection( getI18nString( "site" ) + getRepoName( distributionManagement.getSite().getId() ) );
 155  0
                 internalLink( distributionManagement.getSite().getUrl() );
 156  0
                 endSection();
 157  
             }
 158  
 
 159  0
             endSection();
 160  0
         }
 161  
 
 162  
         private void internalLink( String url )
 163  
         {
 164  0
             if ( StringUtils.isEmpty( url ) )
 165  
             {
 166  0
                 return;
 167  
             }
 168  
 
 169  0
             String urlLowerCase = url.trim().toLowerCase( Locale.ENGLISH );
 170  0
             if ( urlLowerCase.startsWith( "http" ) || urlLowerCase.startsWith( "https" )
 171  
                 || urlLowerCase.startsWith( "ftp" ) )
 172  
             {
 173  0
                 link( url, url );
 174  
             }
 175  
             else
 176  
             {
 177  0
                 paragraph( url );
 178  
             }
 179  0
         }
 180  
 
 181  
         private String getRepoName( String name )
 182  
         {
 183  0
             if ( StringUtils.isNotEmpty( name ) )
 184  
             {
 185  0
                 return " - " + name;
 186  
             }
 187  
 
 188  0
             return "";
 189  
         }
 190  
     }
 191  
 }