rascio
rascio

Reputation: 9279

IntelliJ execute gradle test from root project

I've a gradle multiproject importend in my IntelliJ, and I want execute some test classes.

The structure is like:

root
|-module-a
|-module-b

module-a depends on module-b, so in the build.gradle

dependencies {
    compile project('module-b');
}

When I use gradle from the shell everything it's ok, I have to go in the root project dir and write:

./gradlew :module-a:test

And everything it's been tested.

When I click "Run 'Tests' in 'module-a'" from IntelliJ I have this error:

A problem occurred evaluating root project 'module-a'.
> Project with path ':module-b' could not be found in root project ':module-a'.

So it seems, that IntelliJ is executing the gradle command from module-a and not from the root (this should be the correct behavior from what gradle wants).

How can execute this test inside IntelliJ? What I have to configure?

Upvotes: 1

Views: 1887

Answers (1)

RaGe
RaGe

Reputation: 23657

For a multi-project structure that looks like this

root
|-module-a
|-module-b

There is only one settings.gradle in the root folder, with the content:

include 'module-a', 'module-b'

The subproject folders do not contain a settings.gradle file. Then you refer to sibling projects as:

project(':module-b')

so your dependency would be declared as:

dependencies {
  compile project(':module-b');
}

Please see here for more information about multi-project structure.

Upvotes: 2

Related Questions