How can I specify a `testRuntimeOnly` dependency u...
# compiler
s
j
testRuntimeOnly
is
Copy code
sourceSets.test.dependencies {
    runtimeOnly(...)
}
Another trick that probably work is
Copy code
dependencies {
    "testRuntimeOnly"(...) // check that is `invoke` over a String with `"`
}
s
ohh, nice. you change the source set that way!
when using the AGP do you know how to access the androidTest source set?
j
I don't know, but you can get the configuration names with
configurations
Copy code
kotlin {
    sourceSets {
        commonTest
        androidUnitTest
        androidInstrumentedTest
(also more of a gradle question than a compiler question)
s
No it's about how to do it in a compiler extension through the kotlin API. @Javier was right
s
Oh yes IC what you mean
This is pure gradle plug-in I was wrong. It's just the difference between doing it in kotlin or groovy. Can I use the syntax you sent in kotlin?
Thanks for the correction. I was confused because this is for the gradle plug-in part of a compiler extension
I'd send the link not I'm AFK
e
most things in Gradle can be configured equally via closures
foo { bar { baz() } }
or as values
foo.bar.baz()
(and regardless of Kotlin or Groovy DSL)
s
Thanks!
something like this:
Copy code
target.configurations.names.forEach { configName ->
				kotlin.sourceSets.getByName(configName).dependencies {
					compileOnly(target.citeApiDependency())
				}
			}
or even:
Copy code
target.configurations.names.forEach { configName ->
				if (configName.contains("androidTest")) {
					kotlin.sourceSets.getByName(configName).dependencies {
						compileOnly(target.citeApiDependency())
					}
				}
			}
This is the PR for anyone interested - https://github.com/JakeWharton/cite/pull/101