buildSrc with content imported from another module

I have gradle plugin project which I’m deploying to my artifactory.
But I also want to directly test this plugin, si I have also several testing and samples modules there. But now how to allows directly build the plugin and use it as plugin for another module?

I’m using buildScr folder with this in setting.gradle

include ‘:plugin’
project(’:plugin’).projectDir = new File(’…/plugin’)

and then inside of buil.gradle I have

rootProject.dependencies {
implementation project(’:plugin’)
}

So this setup allows me to have a separate ‘plugin’ module which will be deployed to artifactory and also the possibility to immediately apply this plugin in any sample module.

It works completly fine from commandline. But in the latest Android Studio or clean InteliJ IDEA it crashing on

ERROR: Unable to find module with Gradle path ‘plugin’ (needed by modules: ‘buildSrc’, ‘buildSrc’.)

It was also working on the older version. So I think that it will be some issue on InteliJ IDEA side. But I’m asking if there is some better way how to do the same thing.