This message was deleted.
# kotlin-dsl
s
This message was deleted.
💙 1
🎉 2
👍 4
p
One thing to be aware of with api/language level 1.5+ is that lambdas are transformed to
invokedynamic
calls, which can cause issues with up-to-date checking and the configuration cache.
-Xsam-conversions=class
works around it.
thank you 2
💯 1
It's less of a problem than it used to be because there's some crazy magic in the bytecode transformer for the build classpath that special cases
Action<T>
and
Spec<T>
, but it can still be problematic for other things like
Function<T, R>
.
🧙 1
t
ah, good catch. We set
-Xsam-conversions=class
for all our gradle plugins
s
Can you provide what I should add to my workaround to enable
sam-conversions
? I can add a comment next to it regarding your comment.
Copy code
afterEvaluate {
    tasks.withType<KotlinCompile>().configureEach {
        kotlinOptions {
            apiVersion = "1.5"
            languageVersion = "1.5"
        }
    }
}
Does this look right?
Copy code
kotlinOptions {
        freeCompilerArgs += ['-Xsam-conversions=class']
    }
👍 2
t
this is what I have in my codebase
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
  kotlinOptions {
    // Resolves warning of this sort when using the configuration cache:
    // Execution optimizations have been disabled for task ':module:testDebugUnitTest' to ensure
    // correctness due to the following reasons:
    //  - Additional action of task ':module:testDebugUnitTest' was implemented by the Java lambda
    //  'com.squareup.gradle.support.UnitTestAgentPlugin$apply$1$2$$Lambda$5945/0x0000001783f92440'.
    //  Reason: Using Java lambdas is not supported as task inputs.
    freeCompilerArgs += '-Xsam-conversions=class'
  }
}
👍 1
thank you 1