https://kotlinlang.org
Join Slack
I'm trying to configure a ktor application using the configuration file, as described here: <https:/...
s

Serafeim Papastefanos

almost 3 years ago
I'm trying to configure a ktor application using the configuration file, as described here: https://ktor.io/docs/configurations.html#configuration-file ... I've put a file on my
src/main/resources/application.conf
and works great. However, to deploy the app I create a fat jar. Is there a way to override some configuration options when I deploy that fat jar ? I know that I can use env vars but there are too many options that would need overriding. is it possible to pass another configuration file to the fatjar that would be used to override configuration options ? i.e run it like
java -jar ktor-fat.jar -c local.conf
; when trying to read a configuration value, it will first check
local.conf
, if not found then go to
resources/application.conf
inside the jar
s
a
l
  • 3
  • 7
  • 1127
is there a way to globally exclude a directory? we have some generated code checked in (yes… we know...
e

Eric

over 3 years ago
is there a way to globally exclude a directory? we have some generated code checked in (yes… we know). And want to exclude that directory from contributing to score and from being formatted automatically.
e
e
+2
  • 4
  • 6
  • 1126
How to get screen width and height for Ios and Android in common module in compose Multiplatform? s...
s

Shoaib khalid

almost 2 years ago
How to get screen width and height for Ios and Android in common module in compose Multiplatform? see more detail here: https://github.com/JetBrains/compose-multiplatform/discussions/3225
s
a
+2
  • 4
  • 3
  • 1125
what may the cause of "Unresolved reference: Composable" in iosMain? androidx.compose.runtime.Compos...
r

Romão

about 2 years ago
what may the cause of "Unresolved reference: Composable" in iosMain? androidx.compose.runtime.Compose is imported but the compiler outputs error
r
j
+3
  • 5
  • 76
  • 1123
Hey guys, I wrote a guide how to setup firebase on iOS and Android using KMP as I've struggle to fin...
h

Hristijan

over 1 year ago
Hey guys, I wrote a guide how to setup firebase on iOS and Android using KMP as I've struggle to find a guide online that helped me do that https://funkymuse.dev/posts/kmp-firebase/ Hope it helps you too
👍 4
👍🏻 1
h
a
+4
  • 6
  • 8
  • 1122
What is the best practice to refresh OAuth access tokens using a refresh token in OkHttp? I have the...
l

Lukasz Kalnik

about 3 years ago
What is the best practice to refresh OAuth access tokens using a refresh token in OkHttp? I have the following setup, but it's failing in case of parallel calls. The
synchronized(lock)
doesn't seem to prevent the second call to try to refresh the token as well.
val okHttpClient = OkHttpClient.Builder()
    .addInterceptor(AccessTokenInterceptor(oAuthRepository))
    .authenticator(RefreshTokenAuthenticator(oAuthRepository))
    .build()

val lock = Any()

private class AccessTokenInterceptor(
    private val oAuthRepository: OAuthRepository
) : Interceptor {

    override fun intercept(chain: Chain): Response {
        synchronized(lock) {
            val token = oAuthRepository.accessToken

            val request = chain.request().newBuilder().apply {
                if (token != null) header("Authorization", "Bearer $token")
            }.build()
            return chain.proceed(request)
        }
    }
}

private class RefreshTokenAuthenticator(
    private val oAuthRepository: OAuthRepository
) : Authenticator {

    override fun authenticate(route: Route?, response: Response): Request? {
        if (response.responseCount >= 2) return null

        synchronized(lock) {
            return runBlocking {
                oAuthRepository.refreshTokens().map {
                    oAuthRepository.accessToken
                }
            }.fold(
                ifLeft = { null },
                ifRight = {
                    it?.let { token ->
                        response.request.newBuilder()
                            .header("Authorization", "Bearer $token")
                            .build()
                    }
                }
            )
        }
    }
}
l
y
+2
  • 4
  • 8
  • 1121
Hello, I am discovering the new `plugins` declaration. Applying below in the root Gradle file ```pl...
n

nuhkoca

over 3 years ago
Hello, I am discovering the new
plugins
declaration. Applying below in the root Gradle file
plugins {
    id("com.android.application") version "7.2" apply false
    id("com.android.library") version "7.2" apply false
}
But I also need to apply
Gradle
plugin in
buildSrc
so I have this in there
implementation("com.android.tools.build:gradle:7.2.0")
but then IDE throws an exception
Error resolving plugin [id: ‘com.android.application’, version: ‘7.2.0’, apply: false]
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
How do I have the same plugin works for the both places?
n
v
a
  • 3
  • 8
  • 1116
What could cause this exception? (thread)
j

Jan

about 3 years ago
What could cause this exception? (thread)
j
n
  • 2
  • 6
  • 1111
what is the most efficient way to round `Double` up to certain decimal points, there is `round()` ...
d

Danish Ansari

about 4 years ago
what is the most efficient way to round
Double
up to certain decimal points, there is
round()
function in Kotlin but it always completely rounds up to 0 decimals? I want something like
round(1.4999,decimalPrecision = 2) // 1.50
d
j
+2
  • 4
  • 29
  • 1111
Trying out Kotlin 2.0.0-RC1 and getting `Caused by: java.lang.ExceptionInInitializerError: Exception...
j

John O'Reilly

over 1 year ago
Trying out Kotlin 2.0.0-RC1 and getting
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.ArrayStoreException: org.jetbrains.kotlin.konan.target.KonanTarget$IOS_ARM32 [in thread "Daemon worker"]
error when syncing.....this is in KMP project so maybe known issue? Full stack in thread. Tried latest AS canary so far
youtrack 1
✅ 1
j
d
+5
  • 7
  • 43
  • 1110
Previous333435Next

kotlinlang

A modern programming language that makes developers happier.

Powered by