Skip to content

Commit

Permalink
Run ktlintFormat
Browse files Browse the repository at this point in the history
Signed-off-by: mramotar <[email protected]>
  • Loading branch information
matt-ramotar committed Mar 16, 2024
1 parent b7aa329 commit 3f232e7
Show file tree
Hide file tree
Showing 118 changed files with 4,208 additions and 3,650 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ captures/
# Keystore files
*.jks

store/kover
*/kover
*.podspec
yarn.lock
21 changes: 18 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask

plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("com.diffplug.spotless") version "6.4.1"
Expand Down Expand Up @@ -49,15 +53,26 @@ subprojects {
tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
}

withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_11.name
targetCompatibility = JavaVersion.VERSION_11.name
sourceCompatibility = JavaVersion.VERSION_17.name
targetCompatibility = JavaVersion.VERSION_17.name
}
}

// Workaround for https://youtrack.jetbrains.com/issue/KT-62040
tasks.getByName("wrapper")

// Workaround for https://youtrack.jetbrains.com/issue/KT-63014
plugins.withType<NodeJsRootPlugin> {
extensions.configure(NodeJsRootExtension::class) {
nodeVersion = "21.0.0-v8-canary20231019bd785be450"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}
tasks.withType<KotlinNpmInstallTask> {
args.add("--ignore-engines")
}
}
17 changes: 3 additions & 14 deletions cache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.vanniktech.maven.publish.SonatypeHost.S01
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask

plugins {
kotlin("multiplatform")
Expand Down Expand Up @@ -70,7 +68,7 @@ kotlin {
}
}

jvmToolchain(11)
jvmToolchain(17)
}

android {
Expand All @@ -92,8 +90,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

Expand Down Expand Up @@ -127,12 +125,3 @@ koverMerged {
onCheck.set(true)
}
}

// See https://youtrack.jetbrains.com/issue/KT-63014
rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary20231024d0ddc81258"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}
tasks.withType<KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ interface Cache<Key : Any, Value : Any> {
* @throws UncheckedExecutionException If an unchecked exception was thrown while loading the value.
* @throws ExecutionError If an error was thrown while loading the value.
*/
fun getOrPut(key: Key, valueProducer: () -> Value): Value
fun getOrPut(
key: Key,
valueProducer: () -> Value,
): Value

/**
* @return Map of the [Value] associated with each [Key] in [keys]. Returned map only contains entries already present in the cache.
Expand All @@ -26,7 +29,10 @@ interface Cache<Key : Any, Value : Any> {
* If the cache previously contained a value associated with [key], the old value is replaced by [value].
* Prefer [getOrPut] when using the conventional "If cached, then return. Otherwise create, cache, and then return" pattern.
*/
fun put(key: Key, value: Value)
fun put(
key: Key,
value: Value,
)

/**
* Copies all of the mappings from the specified map to the cache. The effect of this call is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,52 @@ class CacheBuilder<Key : Any, Output : Any> {
internal var ticker: Ticker? = null
private set

fun concurrencyLevel(producer: () -> Int): CacheBuilder<Key, Output> = apply {
concurrencyLevel = producer.invoke()
}

fun maximumSize(maximumSize: Long): CacheBuilder<Key, Output> = apply {
if (maximumSize < 0) {
throw IllegalArgumentException("Maximum size must be non-negative.")
fun concurrencyLevel(producer: () -> Int): CacheBuilder<Key, Output> =
apply {
concurrencyLevel = producer.invoke()
}
this.maximumSize = maximumSize
}

fun expireAfterAccess(duration: Duration): CacheBuilder<Key, Output> = apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
fun maximumSize(maximumSize: Long): CacheBuilder<Key, Output> =
apply {
if (maximumSize < 0) {
throw IllegalArgumentException("Maximum size must be non-negative.")
}
this.maximumSize = maximumSize
}
expireAfterAccess = duration
}

fun expireAfterWrite(duration: Duration): CacheBuilder<Key, Output> = apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
fun expireAfterAccess(duration: Duration): CacheBuilder<Key, Output> =
apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
}
expireAfterAccess = duration
}
expireAfterWrite = duration
}

fun ticker(ticker: Ticker): CacheBuilder<Key, Output> = apply {
this.ticker = ticker
}
fun expireAfterWrite(duration: Duration): CacheBuilder<Key, Output> =
apply {
if (duration.isNegative()) {
throw IllegalArgumentException("Duration must be non-negative.")
}
expireAfterWrite = duration
}

fun weigher(maximumWeight: Long, weigher: Weigher<Key, Output>): CacheBuilder<Key, Output> = apply {
if (maximumWeight < 0) {
throw IllegalArgumentException("Maximum weight must be non-negative.")
fun ticker(ticker: Ticker): CacheBuilder<Key, Output> =
apply {
this.ticker = ticker
}

this.maximumWeight = maximumWeight
this.weigher = weigher
}
fun weigher(
maximumWeight: Long,
weigher: Weigher<Key, Output>,
): CacheBuilder<Key, Output> =
apply {
if (maximumWeight < 0) {
throw IllegalArgumentException("Maximum weight must be non-negative.")
}

this.maximumWeight = maximumWeight
this.weigher = weigher
}

fun build(): Cache<Key, Output> {
if (maximumSize != -1L && weigher != null) {
Expand Down
Loading

0 comments on commit 3f232e7

Please sign in to comment.