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

org.realityforge.bazel.depgen.DepGenConfig Maven / Gradle / Ivy

Go to download

bazel-depgen: Generate Bazel dependency scripts by traversing Maven repositories

There is a newer version: 0.19
Show newest version
package org.realityforge.bazel.depgen;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import java.util.Properties;
import javax.annotation.Nonnull;

public final class DepGenConfig
{
  @Nonnull
  static final String PROPERTY_KEY = "bazel-degen.version";
  @Nonnull
  private static final Properties c_config = loadConfig();

  @Nonnull
  public static String getVersion()
  {
    final String versionProperty = System.getProperty( PROPERTY_KEY );
    if ( null != versionProperty )
    {
      return versionProperty;
    }
    else
    {
      return Objects.requireNonNull( c_config.getProperty( "version" ) );
    }
  }

  @Nonnull
  public static String getCoord()
  {
    return getGroupId() + ":" + getArtifactId() + ":jar:" + getClassifier() + ":" + getVersion();
  }

  @Nonnull
  public static String getGroupId()
  {
    return Objects.requireNonNull( c_config.getProperty( "group" ) );
  }

  @Nonnull
  public static String getArtifactId()
  {
    return Objects.requireNonNull( c_config.getProperty( "id" ) );
  }

  @Nonnull
  public static String getClassifier()
  {
    return "all";
  }

  @Nonnull
  private static Properties loadConfig()
  {
    final InputStream inputStream = DepGenConfig.class.getResourceAsStream( "config.properties" );
    assert null != inputStream;

    try
    {
      final Properties properties = new Properties();
      properties.load( inputStream );
      return properties;
    }
    catch ( final IOException e )
    {
      throw new IllegalStateException( "Failed to load config.properties", e );
    }
  }

  private DepGenConfig()
  {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy