Config

data class Config(val logLevel: String = env["DEVELOCITY_API_LOG_LEVEL"] ?: "off", val apiUrl: String = env["DEVELOCITY_API_URL"] ?: error("DEVELOCITY_API_URL is required"), val apiToken: () -> String = { env["DEVELOCITY_API_TOKEN"] ?: error("DEVELOCITY_API_TOKEN is required") }, val clientBuilder: OkHttpClient.Builder = basicOkHttpClient.newBuilder(), val maxConcurrentRequests: Int? = env["DEVELOCITY_API_MAX_CONCURRENT_REQUESTS"]?.toInt(), val readTimeoutMillis: Long = env["DEVELOCITY_API_READ_TIMEOUT_MILLIS"]?.toLong() ?: 60_000L, val cacheConfig: Config.CacheConfig = CacheConfig())(source)

Library configuration options.

Constructors

Link copied to clipboard
constructor(logLevel: String = env["DEVELOCITY_API_LOG_LEVEL"] ?: "off", apiUrl: String = env["DEVELOCITY_API_URL"] ?: error("DEVELOCITY_API_URL is required"), apiToken: () -> String = { env["DEVELOCITY_API_TOKEN"] ?: error("DEVELOCITY_API_TOKEN is required") }, clientBuilder: OkHttpClient.Builder = basicOkHttpClient.newBuilder(), maxConcurrentRequests: Int? = env["DEVELOCITY_API_MAX_CONCURRENT_REQUESTS"]?.toInt(), readTimeoutMillis: Long = env["DEVELOCITY_API_READ_TIMEOUT_MILLIS"]?.toLong() ?: 60_000L, cacheConfig: Config.CacheConfig = CacheConfig())

Types

Link copied to clipboard
data class CacheConfig(val cacheEnabled: Boolean = env["DEVELOCITY_API_CACHE_ENABLED"].toBoolean(), val cacheDir: File = env["DEVELOCITY_API_CACHE_DIR"]?.let(::File) ?: File(systemProperties["user.home"], ".develocity-api-kotlin-cache"), val maxCacheSize: Long = env["DEVELOCITY_API_MAX_CACHE_SIZE"]?.toLong() ?: 1_000_000_000L, val longTermCacheUrlPattern: Regex = env["DEVELOCITY_API_LONG_TERM_CACHE_URL_PATTERN"]?.toRegex() ?: Regex( """ .*/api/builds/[\d\w]+/(?:gradle|maven)-(?:attributes|build-cache-performance) """.trimIndent() ), val longTermCacheMaxAge: Long = env["DEVELOCITY_API_SHORT_TERM_CACHE_MAX_AGE"]?.toLong() ?: 365.days.inWholeSeconds, val shortTermCacheUrlPattern: Regex = env["DEVELOCITY_API_SHORT_TERM_CACHE_URL_PATTERN"]?.toRegex() ?: """.*/builds(?:\?.*|\Z)""".toRegex(), val shortTermCacheMaxAge: Long = env["DEVELOCITY_API_SHORT_TERM_CACHE_MAX_AGE"]?.toLong() ?: 1.days.inWholeSeconds)

HTTP cache is off by default, but can speed up requests significantly. The Develocity API disallows HTTP caching, but this library forcefully enables it by overwriting cache-related headers in API responses. Enable with cacheEnabled.

Properties

Link copied to clipboard
val apiToken: () -> String

Provides the access token for a Develocity API instance. By default, uses environment variable DEVELOCITY_API_TOKEN.

Link copied to clipboard

Provides the URL of a Develocity API instance REST API. By default, uses environment variable DEVELOCITY_API_URL. Must end with /api/.

Link copied to clipboard
Link copied to clipboard
val clientBuilder: OkHttpClient.Builder

OkHttpClient.Builder to use when building the library's internal OkHttpClient.

Link copied to clipboard

Changes the default log level for library classes, such as the HTTP client. By default, log level is the value of org.slf4j.simpleLogger.defaultLogLevel system property or "off".

Link copied to clipboard

Maximum amount of concurrent requests allowed. Further requests will be queued. By default, uses environment variable DEVELOCITY_API_MAX_CONCURRENT_REQUESTS or 5 (OkHttp's default value of Dispatcher.maxRequestsPerHost).

Link copied to clipboard

Timeout for reading an API response, used for OkHttpClient.readTimeoutMillis. By default, uses environment variable DEVELOCITY_API_READ_TIMEOUT_MILLIS or 60_000. Keep in mind that Develocity API responses can be big and slow to send depending on the endpoint.