Library dependency problems

Hi,

I work for a company which developing a JEE application, with huge code base.
We use Intellij IDEA, the .iml and .ipr files are generated by a gradle task.
We have about 20 modules, one has a module library with test scope, which contains all other module .class files.
Every other module has access to it, through transitive dependencies.
I know, it's sounds weird, as I know it's because some integration tests using dependencies from modules which are not in their dependency tree by default.
The problem is, that sometimes Intellij uses these .class files instead of source files, during testing and debugging.
E.g. I run a test class, has some failing test, click on the test name in the Run view and Intellij opens the .class file, not the .java file.
The same happenig sometimes during debug or when trying to jump to an other java file(go to implementation etc.), even if they are in the same module.

I know the problem is, that the mentioned library contains the .class files for every module, but I don't understand why Intellij found those files first instead of the source files.
If remove the .class files, then the integration test failing to compile, so that's not an option.
Can I see somewhere what's the exact class path when Intellij trying to compile modules/run tests/debugging etc?

6 comments
Comment actions Permalink

Why don't you put your integration tests into a separate module that has dependencies on all other modules? Then you will no longer need the library with all the .class files.

0
Comment actions Permalink

I'm just a developer form the thousand, so I can't restructure the modules.
The module settings are generated by a gradle task for everyone.
I can change my own IDEA settings, but don't know how to solve the mentioned problem, without changing structure.

0
Comment actions Permalink

Well, someone must have written the Gradle task that generates this library full of .class files. Can you talk to them and explain that there is a better approach for solving this problem?

Note that it may be unnecessary to change the package or directory structure; you can create a module that will include only the specific parts of the codebase where the integration tests are located, and IntelliJ IDEA will correctly exclude the contents of that module from the contents of other modules.

0
Comment actions Permalink

Maybe I can, but that will be a very long process and has a low success possibility. :)

But, could you explain me how IDEA searching for java classes?
What determines the order of the search, for example when clicking on a stracktrace item during debug?

0
Comment actions Permalink

Essentially IntelliJ IDEA collects the roots by performing a depth-first traversal of the dependencies of the module specified in the run configuration used to start the debug. If there are multiple classes with the same qualfiied name, it prefers the class which is in a root closer to the beginning of ther roots list.

0
Comment actions Permalink

Thanks, I'm trying to figure out something.

0

Please sign in to leave a comment.