View Javadoc
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  public class PluginInfo 
16  {
17  
18    static 
19    {
20      loadProperties();
21    }
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      prop = new Properties();
32      InputStream in = PluginInfo.class.getResourceAsStream( "plugin.properties" );
33      try 
34      {
35        prop.load( in );
36        groupId = prop.getProperty( "groupId" );
37        artifactId = prop.getProperty( "artifactId" );
38        version = prop.getProperty( "version" );
39        in.close();
40      } 
41      catch ( IOException e ) 
42      {
43        e.printStackTrace();
44      }
45    }
46    
47    /**
48     * Get the Maven GAV string of the plugin.
49     * @return
50     */
51    public static String getGAV()
52    {
53      StringBuilder builder = new StringBuilder()
54        .append( groupId )
55        .append( COLON )
56        .append( artifactId )
57        .append( COLON )
58        .append( version );
59        return builder.toString();
60    }
61    
62    public static String getGroupId() 
63    {
64      return groupId;
65    }
66    
67    public static String getArtifactId()
68    {
69      return artifactId;
70    }
71    
72    public static String getVersion()
73    {
74      return version;
75    }
76  
77    public static String getQualifiedGoal( String goal )
78    {
79      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      return builder.toString();
88    }
89  }