In Intellij, you can add module dependency under Project Structure.
There is a checkbox under Export under Dependency tab. As shown below.
I try to select the checkbox for log4j dependency and recompile it. Nothing added in the output path. As shown below.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With