Config

data class Config(val server: URI = requireNotNull(env["DEVELOCITY_URL"]?.let(::URI)) { ERROR_NULL_DEVELOCITY_URL }, val accessKey: () -> String = { requireNotNull(accessKeyResolver.resolve(server.host)) { ERROR_NULL_ACCESS_KEY } }, val clientBuilder: OkHttpClient.Builder = OkHttpClientBuilderFactory.default.create(), 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(server: URI = requireNotNull(env["DEVELOCITY_URL"]?.let(::URI)) { ERROR_NULL_DEVELOCITY_URL }, accessKey: () -> String = { requireNotNull(accessKeyResolver.resolve(server.host)) { ERROR_NULL_ACCESS_KEY } }, clientBuilder: OkHttpClient.Builder = OkHttpClientBuilderFactory.default.create(), 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 accessKey: () -> String

Provides the access key for the Develocity server. By default, resolves to the first key from these sources that matches the host of server:

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

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.

Link copied to clipboard
val server: URI

Provides the URL of a Develocity server to use in API requests. By default, uses environment variable DEVELOCITY_URL. Must be a valid URL with no path segments (trailing slash OK) or query parameters.