https://kotlinlang.org logo
Title
g

gildor

07/28/2018, 5:29 PM
It should be straightforward now with generated extension accessor:
flyway {
 //some config
}
But your problem is that you applied the plugin, but configure it on a separate script which doesn’t have access to plugins applied on the root build.gradle
x

x80486

07/28/2018, 5:46 PM
So, every
.kts
file only have access to its own
plugins { ... }
block...I guess I remember you (and/or others) stating that here several times.
g

gildor

07/28/2018, 5:50 PM
Not every, it’s more complicated, You can share plugins using buildSrc for example
There is a few issues about this limitation and this planned to solve
This is exactly about your case: https://github.com/gradle/kotlin-dsl/issues/846
x

x80486

07/28/2018, 5:53 PM
Yeah, that would be super! I remember you fixed something like that a while back on a mini-project I have. I really dislike the "stringly" typed scopes...
g

gildor

07/28/2018, 5:55 PM
they are dynamic, so no choice, only proof somehow that configuration is really available. Also, one possible way to define such accessors manually and put them to your kts file or even to buildSrc, so you can use them in any project
x

x80486

07/28/2018, 5:57 PM
Let me explore that approach...sounds better
g

gildor

07/28/2018, 6:00 PM
just define an extension function for DependenciesScope with name of configuration that adds dependency, you can check example if check sources of any generated configuration accessor from Kotlin-DSL
👌 1
x

x80486

07/28/2018, 7:13 PM
...so, even if I bring the Flyway plugin to
database.gradle.kts
it complains about `Unresolved reference: flyway`:
plugins {
  id("org.flywaydb.flyway") version "5.1.4"
}

//apply(plugin = "org.flywaydb.flyway")

dependencies {
  "compile"("org.flywaydb:flyway-core")
}

flyway {  }
g

gildor

07/29/2018, 3:51 AM
No-no, this is not supported yet, as I mentioned before. As I mentioned before you cannot use generated accessors in script plugins
You can use buildSrc or build.gradle.kts