How configure IntelliJ to use classes from module dependency



I have a multi-module Project imported in IntellJ. For instance: Parent -> Modules (A, B, C).

Modules B and C depends on A. Module A has a dependency to a 3th-Party-library E.

Since E is a very bad assambled library containing a lot of stuff we don't need and can't configure properly, we decided to extract the few classes we need with the machen-dependency-plugin and put them into the target/classes Directory. The Team providing the library is working on modulaizing the Project better but we can't wait unitl they are finished so we used this work around.

This works fine, the only problem we have is that these extracted classes are not found by IntellJ when referencing them in A, so we need to add the dependency in the dependencies section of the A-pom.xml for the Editor showing/handling Imports etcetera properly.

The Services B and C which are depending on A. Won't start since we are adding the dependencies of the 3th-party-libraries for letting the Editor work properly.

How can I tell Intellij to see the extracted (binaries/)classes in target/classes of A so we don't need to add the 3th-Party dependencies explicitly to let the editor work properly? How can I tell IntelliJ to see those classes in the sibling/dependant modules B and C too?

I'm grateful fo any help.


Hi Ruben,

I'll look into it and get back to you.


Does it help if you extract the classes into the target/generated-classes directory of A instead?


Hello Arina,

I extracted the classes to target/generated-classes. It did not help.

What I don't understand is why despite the extracted classes are in target/classes, the Editor is marking the classes Imports as "not existent" in A and in the other sibling submodules depending on A i.e. B,C.

B and C has a dependency to A as a module reference (see screenshot A=common). The classes are in target/classes: where does intelliJ Looks into? The classes are included in the jar built too.



Compiled classes will be ignored by IntelliJ IDEA unless they are located in the Generated Sources directory.

You probably need to either reference the files as separate system dependencies or generate a separate generated sources directory with the build-helper-maven-plugin.




I have used the build-helper-maven-plugin and added the target/generated-classes folder but intelliJ's editor still doesn't check, that they exist.

Adding the dependencies as system dependencies is not a solution path. It should be possible just to tell intelliJ to use the target/classes and target/generated-classes (or whatever target Folder) to recognize them and the editor to show a class importing these extracted binaries/classes properly ie as in classpath.

the configuration for the shared module A looks like this after running maven. Is it correct?

I'm grateful for any help.


Hi Ruben,

  1. Open this test project in IDEA and apply the changes from this commit to it.
  2. Run the script, see the generated-classes and generated-sources directories added to the target dir.
  3. Reload the project ('Maven' tool window > circular arrows icon), see IDEA recognize the generated-sources dir and mark it accordingly.
  4. Open the class, observe no compilation errors in the editor.

Hope this helps.


Hi Arina,

that worked :-). Thank you, for your commitment to helping.

Best regards



I just wanted to provide you a sample for the issue.

In your sample, the shell script creates a java source file in target/generated-sources and compiles it to target/generated-classes. It seems as if IntelliJ/maven does not recognize classes (binaries) that have been extracted from a jar and put into e.g. target/generated-classes. IntelliJ seems to need the source of the binary to work properly (editor). It is when the binary is in a folder e.g. target/generated-classes and not coming from a dependency. If I'm wrong, please correct me.

I have created a sample (2 projects: the simulation of the jar to extract the binaries from, and a second one that simulates the project using these binaries). Feel free to check the sample, it reflects the problem as it is. a project where to extract the binaries from a project using extracted binaries from biglib

Best regards,


You are welcome Ruben, happy to help.

IntelliJ seems to need the source of the binary to work properly (editor)

Yes, you are correct about this. It is how it currently works.


Please sign in to leave a comment.