I can’t find the plugins{} in project api but only apply(). why can i use plugins{} in build script?
Because build scripts are a DSL.
One with more available than is mentioned in a generated documentation, as much is handled dynamically and con only be descibed in prose documentation.
If you are writing a binary plugin and want to use the plugins
block there, don’t, you add the plugin to the classpath as dependency of the plugin project and apply it using apply
.
If you just want to see what is available to add in writing build scripts, I strongly advice to use the Kotlin DSL instead. With it you will immediately get type-safe build scripts, much more helpful error message if you mess up the syntax, and amazingly better IDE support if you use a proper IDE like IntelliJ.
And btw. the object you configure in the plugins { ... }
block is a PluginDependenciesSpec
, there you can find things like the id
and alias
methods.