Closed Archinamon closed 6 years ago
Hi @Archinamon, Thanks for the report. The availability of Kotlin extensions for dynamic parts of the Gradle model depend on how you apply your Gradle plugins. See https://github.com/gradle/kotlin-dsl/blob/master/doc/getting-started/Configuring-Plugins.md How are your plugins applied?
Hello!
I'm using apply { plugin(<T>::class.java) }
style. Does dsl stricts methods generating upon the way of declaring plugins? I'd found it a bit unobvoius =/
For Kotlin extensions for dynamic parts of the Gradle model to be available your plugins must be either already applied (e.g. by a parent project) or applied using the plugins {}
block. That's a known limitation. Please read the documentation linked above ☝️
Great, thanks!
Does it planning to be fixed? I'm glad you have point me my mistake, but I'd prefer using static types for plugin apply block. Which is not available for plugins {}
block.
You're welcome!
We can't fix this, apply {}
is imperative, and could very well be nested in conditionals and such, so we just can't know what plugins would be applied before compiling/evaluating the scripts. The plugins {}
block on the other hand is declarative, and allow us to provide those extensions. Some more background is available in Gradle's documentation: https://docs.gradle.org/current/userguide/plugins.html
I'm migrating simple gradle project to kotlin-dsl and faced a problem: methods
api
,implementation
,compileOnly
, related to gradle 3.0.0+ api is not properly handling by kotlin-dsl even if AccessorsKt was generated well.Screenshot illustrating my problem.
As well, these methods not always even has been generated. As a workaround I can use
add("api", "dependency:notation:...")
or"api"("dependency:notation:...")
.I have tried also launching gradle from command line with
--recompile-scripts
and no positive changes.Expected Behavior
Proper handling android-related generated methods for
DependencyHandlerScope
.Current Behavior
As I have been described above — these methods not always has been generated at all, or kts file simply not compiling nor from IDEA either from command line.
Context
Simple Android project generated by IDEA/Android Studio.
Steps to Reproduce (for bugs)
api
orimplementation
methods withindependencies
closure block inside default app module.Your Environment