Coverage Report - com.simpligility.maven.plugins.androidndk.PluginInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
PluginInfo
76%
16/21
N/A
1.167
 
 1  
 package com.simpligility.maven.plugins.androidndk;
 2  
 
 3  
 import java.util.Properties;
 4  
 import java.io.InputStream;
 5  
 import java.io.IOException;
 6  
 
 7  
 /**
 8  
  * PluginInfo reads plugin.properties which contains filtered 
 9  
  * values from the build like the GAV coordinates of the plugin itself
 10  
  * and provides convenience methods for accessing these properties 
 11  
  * and related things about the plugin.
 12  
  * 
 13  
  * @author Manfred Moser
 14  
  */
 15  0
 public class PluginInfo 
 16  
 {
 17  
 
 18  
   static 
 19  
   {
 20  1
     loadProperties();
 21  1
   }
 22  
 
 23  
   private static final String COLON = ":";
 24  
   private static Properties prop;
 25  
   private static String groupId;
 26  
   private static String artifactId;
 27  
   private static String version;
 28  
   
 29  
   private static void loadProperties() 
 30  
   {
 31  1
     prop = new Properties();
 32  1
     InputStream in = PluginInfo.class.getResourceAsStream( "plugin.properties" );
 33  
     try 
 34  
     {
 35  1
       prop.load( in );
 36  1
       groupId = prop.getProperty( "groupId" );
 37  1
       artifactId = prop.getProperty( "artifactId" );
 38  1
       version = prop.getProperty( "version" );
 39  1
       in.close();
 40  
     } 
 41  0
     catch ( IOException e ) 
 42  
     {
 43  0
       e.printStackTrace();
 44  1
     }
 45  1
   }
 46  
   
 47  
   /**
 48  
    * Get the Maven GAV string of the plugin.
 49  
    * @return
 50  
    */
 51  
   public static String getGAV()
 52  
   {
 53  1
     StringBuilder builder = new StringBuilder()
 54  
       .append( groupId )
 55  
       .append( COLON )
 56  
       .append( artifactId )
 57  
       .append( COLON )
 58  
       .append( version );
 59  1
       return builder.toString();
 60  
   }
 61  
   
 62  
   public static String getGroupId() 
 63  
   {
 64  1
     return groupId;
 65  
   }
 66  
   
 67  
   public static String getArtifactId()
 68  
   {
 69  1
     return artifactId;
 70  
   }
 71  
   
 72  
   public static String getVersion()
 73  
   {
 74  1
     return version;
 75  
   }
 76  
 
 77  
   public static String getQualifiedGoal( String goal )
 78  
   {
 79  0
     StringBuilder builder = new StringBuilder()
 80  
       .append( groupId )
 81  
       .append( COLON )
 82  
       .append( artifactId )
 83  
       .append( COLON )
 84  
       .append( version )
 85  
       .append( COLON )
 86  
       .append( goal );
 87  0
     return builder.toString();
 88  
   }
 89  
 }