Config

data class Config(val debugLoggingEnabled: Boolean = env["GRADLE_ENTERPRISE_API_DEBUG_LOGGING"].toBoolean(), val apiUrl: String = env["GRADLE_ENTERPRISE_API_URL"] ?: error("GRADLE_ENTERPRISE_API_URL is required"), val apiToken: () -> String = { requireEnvOrKeychainToken(debugLoggingEnabled = debugLoggingEnabled) }, val clientBuilder: OkHttpClient.Builder = basicOkHttpClient.newBuilder(), val maxConcurrentRequests: Int? = env["GRADLE_ENTERPRISE_API_MAX_CONCURRENT_REQUESTS"]?.toInt(), val readTimeoutMillis: Long = env["GRADLE_ENTERPRISE_API_READ_TIMEOUT_MILLIS"]?.toLong() ?: 60_000L, val cacheConfig: Config.CacheConfig = CacheConfig())(source)

Library configuration options.

Constructors

Link copied to clipboard
constructor(debugLoggingEnabled: Boolean = env["GRADLE_ENTERPRISE_API_DEBUG_LOGGING"].toBoolean(), apiUrl: String = env["GRADLE_ENTERPRISE_API_URL"] ?: error("GRADLE_ENTERPRISE_API_URL is required"), apiToken: () -> String = { requireEnvOrKeychainToken(debugLoggingEnabled = debugLoggingEnabled) }, clientBuilder: OkHttpClient.Builder = basicOkHttpClient.newBuilder(), maxConcurrentRequests: Int? = env["GRADLE_ENTERPRISE_API_MAX_CONCURRENT_REQUESTS"]?.toInt(), readTimeoutMillis: Long = env["GRADLE_ENTERPRISE_API_READ_TIMEOUT_MILLIS"]?.toLong() ?: 60_000L, cacheConfig: Config.CacheConfig = CacheConfig())

Types

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

HTTP cache is off by default, but can speed up requests significantly. The Gradle Enterprise 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 Gradle Enterprise API instance. By default, uses keychain entry gradle-enterprise-api-token or environment variable GRADLE_ENTERPRISE_API_TOKEN.

Link copied to clipboard

Provides the URL of a Gradle Enterprise API instance REST API. By default, uses environment variable GRADLE_ENTERPRISE_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

Enables debug logging from the library. All logging is output to stderr. By default, uses environment variable GRADLE_ENTERPRISE_API_DEBUG_LOGGING or false.

Link copied to clipboard

Maximum amount of concurrent requests allowed. Further requests will be queued. By default, uses environment variable GRADLE_ENTERPRISE_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 GRADLE_ENTERPRISE_API_READ_TIMEOUT_MILLIS or 60_000. Keep in mind that GE API responses can be big and slow to send depending on the endpoint.