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}
/
@Override
public void apply(@NotNull final Project prj) {
this.project = prj;
setupIdeaPlugin();
setupJavaPlugin();
}
/

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