All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jayway.maven.plugins.android.PluginInfo Maven / Gradle / Ivy

There is a newer version: 4.0.0-rc.2
Show newest version
package com.jayway.maven.plugins.android;

import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;

/**
 * PluginInfo reads plugin.properties which contains filtered 
 * values from the build like the GAV coordinates of the plugin itself
 * and provides convenience methods for accessing these properties 
 * and related things about the plugin.
 * 
 * @author Manfred Moser
 */
public class PluginInfo 
{

  static 
  {
    loadProperties();
  }

  private static final String COLON = ":";
  private static Properties prop;
  private static String groupId;
  private static String artifactId;
  private static String version;
  
  private static void loadProperties() 
  {
    prop = new Properties();
    InputStream in = PluginInfo.class.getResourceAsStream( "plugin.properties" );
    try 
    {
      prop.load( in );
      groupId = prop.getProperty( "groupId" );
      artifactId = prop.getProperty( "artifactId" );
      version = prop.getProperty( "version" );
      in.close();
    } 
    catch ( IOException e ) 
    {
      e.printStackTrace();
    }
  }
  
  /**
   * Get the Maven GAV string of the plugin.
   * @return
   */
  public static String getGAV()
  {
    StringBuilder builder = new StringBuilder()
      .append( groupId )
      .append( COLON )
      .append( artifactId )
      .append( COLON )
      .append( version );
      return builder.toString();
  }
  
  public static String getGroupId() 
  {
    return groupId;
  }
  
  public static String getArtifactId()
  {
    return artifactId;
  }
  
  public static String getVersion()
  {
    return version;
  }

  public static String getQualifiedGoal( String goal )
  {
    StringBuilder builder = new StringBuilder()
      .append( groupId )
      .append( COLON )
      .append( artifactId )
      .append( COLON )
      .append( version )
      .append( COLON )
      .append( goal );
    return builder.toString();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy