Having dependency both in "Test" and "Provided" scope in IDEA project

I am trying to configure my build to put certain dependency twice (with two different scopes) in the generated IDEA module (which is produced by “idea” plugin). I want dependency to be in both “Provided” and “Test” scopes.

Reason I need this is that my project is an IntelliJ plugin (let’s call it “A”) which depends on another plugin (let’s call it “B”).

“Provided” scope would, errr, provide a compile-time dependency to my plugin “A” without making the dependency part of the “A” packaging (IntelliJ would not deploy “Provided” dependencies as part of plugin “A”, which is exactly what I need as these libraries are already deployed as part of plugin “B”).

“Test” scope is to add a dependency to test compile classpath and to runtime classpath. This is how plugin tests work in IntelliJ: when you run your test, you code and all its dependencies (including other plugins) are supposed to be part of a single classpath.

The way it used to work (in Gradle 1.9) is the following:

configurations {
dependencies {
  provided pluginBDep // Depend, but do not include in packaging
  testCompile pluginBDep // Depend in tests
idea.module {
  scopes.PROVIDED.plus += [configurations.provided]

However, at some point it stopped working. The dependency is only added once (seems like “Provided” scope always wins).

I looked at the “idea” plugin sources and found that internally it has support for the provided+test scope called PROVIDED_TEST, which would only be triggered if you have a dependency in both “providedRuntime” and “test” configurations.

So, the solution I found is the following:

configurations.compile.extendsFrom configurations.plugin
dependencies {
  plugin pluginBDep // would add to both 'PROVIDED' and 'TEST' in IntelliJ
idea.module {
  scopes.PROVIDED_TEST = [plus: [], minus: []] // Internal scope
  scopes.PROVIDED_TEST.plus += [configurations.plugin]

(I also can make it to work through adding dependency to “test” and “providedRuntime” configurations).

So, the question is simple. Both solutions I have above are kind of hacky and depend on “idea” plugin internals. Is there a better way to achieve what I need? Should “idea” plugin directly support provided+test scope?