Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Module Dependency Export Option

In Intellij, you can add module dependency under Project Structure.
There is a checkbox under Export under Dependency tab. As shown below. enter image description here

I try to select the checkbox for log4j dependency and recompile it. Nothing added in the output path. As shown below. enter image description here

Can anyone tell me what is the use of the checkbox under Export? What is the expected behavior with this checkbox selected?

Remark:
In the official document, it said

The Export option lets you control the compilation classpath for the modules that depend on this one: the marked items will be included in the compilation classpath of the dependent module.

But I don't understand what is that mean. Thanks a lot.

like image 668
HKIT Avatar asked Nov 06 '22 06:11

HKIT


1 Answers

Sometimes, you need to urge leaking dependencies in dependent modules. For example, you have module C, which is dependency of B, and if B provides some API methods you want to expose, for example, B is library, you probably use some structures from module C and without "export" checked when someone in module A, for example will use your API, there are issues with access to these structures, because these classes will not be added to compile classpath of module A.

A --- using this API requires C in compile classpath
    |
    B --- API uses these structures
         C - data structures (should be exported when enumerated in B)

And sometimes you don't want leaking dependencies into compile classpath, so you need uncheck this option

If you don't know what does it mean compile classpath, read this: https://dzone.com/articles/runtime-classpath-vs-compile

like image 96
Singletron Avatar answered Dec 15 '22 14:12

Singletron