Config

data class Config(val logLevel: String = env["DEVELOCITY_API_LOG_LEVEL"] ?: systemProperties.logLevel ?: "off", val apiUrl: String = env["DEVELOCITY_API_URL"] ?: error(ERROR_NULL_API_URL), val apiToken: () -> String = { env["DEVELOCITY_API_TOKEN"] ?: error(ERROR_NULL_API_TOKEN) }, 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"] ?: systemProperties.logLevel ?: "off", apiUrl: String = env["DEVELOCITY_API_URL"] ?: error(ERROR_NULL_API_URL), apiToken: () -> String = { env["DEVELOCITY_API_TOKEN"] ?: error(ERROR_NULL_API_TOKEN) }, 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) ?: run { val userHome = checkNotNull(systemProperties.userHome) { ERROR_NULL_USER_HOME } File(userHome, ".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. Default value, by order of precedence:

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.