https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

basher

02/24/2019, 1:40 AM
Is there a way to add compiler options in your build.gradle that apply to all test targets?
r

russhwolf

02/24/2019, 2:17 AM
Probably something like this would work
Copy code
targets.all {
        compilations.test {
            kotlinOptions {
                // ...
            }
        }
    }
Further documentation on configuring compilations at https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#configuring-compilations
b

basher

02/25/2019, 4:51 PM
using
compilations.test
there didn't work for some reason, ended up getting it to work like this:
Copy code
afterEvaluate {
    kotlin {
        targets.all {
            compilations.configureEach {
                if (name == "test") {
                    kotlinOptions {
                        freeCompilerArgs = listOf("-Xuse-experimental=kotlin.Experimental")
                    }
                }
            }
        }
    }
}
okay so i'm back to trying to get this to work in groovy gradle. i tried what I think is the same thing (and also matches your suggestion):
Copy code
afterEvaluate {
    kotlin {
        targets.all {
            compilations.test {
                kotlinOptions {
                    freeCompilerArgs = ["-Xuse-experimental=kotlin.Experimental"]
                }
            }
        }
    }
}
i'm doing it in
afterEvaluate
, so that I can be sure that all compilations are present
i get:
Could not find method test() for arguments [build_6renavqykv9709il5jhhsfcc8$_run_closure5$_closure13$_closure14$_closure15@2f32fced] on KotlinCommonCompilation container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.
3 Views