How to programmatically apply plugins using the plugins-block..?

when I call the new plugins-block like this:

plugins {
id (“android”)

the PluginManagement-Resolutionstrategy is queried to modify the request.

How can I apply plugins in binary plugin code that works essentially identical to the way the plugins-block does?

Hello, there is example from my custom plugin:

/Main plugin and entry point for applying all other plugins. /
public class GripBuildPlugin implements Plugin< Project> {

* {@inheritDoc}
public void apply(@NotNull final Project prj) {
this.project = prj;

* Apply idea plugin to given project and configure source downloading.
private void setupIdeaPlugin() {
IdeaPlugin idea = project.getPlugins().apply(IdeaPlugin.class);
* Apply java plugin to given project with UTF-8 encoding.
private void setupJavaPlugin() {“Apply java plugin default configuration from {}”, project);
JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class);
JavaCompile compileJava = (JavaCompile) project.getTasks().getByName(“compileJava”);