V2 plugin modules in unit tests

I tried to migrate a large plugin to a V2 plugin descriptor to support split-mode. This turned into a Gradle nightmare and I’m now stuck with unit tests.

The main build uses pluginModule(project(":my-current-module")) to put the v2 modules of subprojects into lib/modules/... of the plugin.zip. Executing runIde is working mostly.

In unit tests of a submodule I have a src/test/resources/META-INF/plugin.xml file declaring the basic content modules to provide a v2 descriptor to tests:

<idea-plugin>
    <id>dev.j-a.swift</id>

    <content>
        <!-- my.current.module.xml also declares dependencies, 
               e.g. on my.own.module.dependency -->
        <module name="my.current.module" loading="required"/>
        <module name="my.own.module.dependency" loading="required"/>
    </content>
</idea-plugin>

How can I tell the Gradle build to put the sub-project .jar files into the test sandbox at lib/modules/my.own.module.dependency.jar and so on?

Tests are failing because the modules are not loaded because of the missing modules and unresolved dependencies.

How could I fix this to allow me to run unit tests with a v2 descriptor?

Thanks!

Tool Version
Gradle 9.3.1
IntelliJ Platform Gradle Plugin 2.11.0
1 Like

As far as I understand tests must run on flat classpath still for you. For integration tests we are going to recommend writing them in a bigger tests module and/or module with plugin.xml, having all modules of a plugin as testImplementation dependencies - so all parts are discovered from its tests class path.

Thank you, that was helpful.
I had dependency issues with the v2 descriptors and modules (basically mismatch of Gradle build dependencies vs. runtime dependencies).

The duplication of the main plugin.xml file into my-submodule/src/test/resources/META-INF/plugin.xml is problematic because it’ll easily be out-of-sync and xi:include is apparently unavailable with v2 descriptors.