Modules and libraries

Suppose I have two modules, Module A and the Project Module. Module A has a jar added to the modules' Libraries tab. Module A is specified as a dependency for the Project Module. However, classes in this module cannot see the classes in the jar added to Module A. It seems to me the libraries should be included as dependencies. Should I file an SCR for this?

0
11 comments

No, the behaviour is intentional. Libraries are properties of a module and if one module depends on another, it means that it can
directly use another module's code, but not its libraries. If your Project module needs the jar, it should be explicitly added to
the module's "Libraries" tab.


--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"

"Kirk Woll" <kirk@digimax.com> wrote in message news:24177694.1066724876268.JavaMail.itn@is.intellij.net...

Suppose I have two modules, Module A and the Project Module. Module A has a jar added to the modules' Libraries tab. Module A is

specified as a dependency for the Project Module. However, classes in this module cannot see the classes in the jar added to Module
A. It seems to me the libraries should be included as dependencies. Should I file an SCR for this?


0

I think it might be a good idea to put this choice in the user's hands. If
the user could explicitly say "include the libraries from module XXX"
somehow - maybe a checkbox in the dependencies tab? - that could be a
convenient feature. The particular use case I'm thinking of is this:

I have a baseline API which I use in multiple projects. Part of the
functionality of this API comes from external jars. For example, I consider
Jakarta's commons-lang and commons-collections to be part of this baseline
and any code which uses the baseline API should be able to rely on having
access to those classes. If I decide that another jar should be added to the
baseline I'd prefer to add it just once, rather than separately in each
project that uses the baseline. This could be done with a library, but for
the fact that parts of the API are my own code, which I want to be able to
edit - ideally without having to switch out of whatever project I happen to
be in at the time.

Does that seem reasonable? Is there a better way to manage this than with
modules? I suppose it could be done by defining a library containing all the
external jars for the baseline and a module for my own source, but that does
seem less convenient (two things to add to each dependent project, instead
of just one). I'm interested in peoples thoughts on this.

Vil.

Eugene Zhuravlev (JetBrains) wrote:

No, the behaviour is intentional. Libraries are properties of a module and if one module depends on another, it means that it can
directly use another module's code, but not its libraries. If your Project module needs the jar, it should be explicitly added to
the module's "Libraries" tab.


--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

Yes, this sounds reasonable. I think it's a good feature request. We could
implement in the version right after Aurora.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Vilya Harvey" <vilya.harvey@digitalsteps.com> wrote in message
news:bn33u9$5e5$1@is.intellij.net...

I think it might be a good idea to put this choice in the user's hands. If
the user could explicitly say "include the libraries from module XXX"
somehow - maybe a checkbox in the dependencies tab? - that could be a
convenient feature. The particular use case I'm thinking of is this:

>

I have a baseline API which I use in multiple projects. Part of the
functionality of this API comes from external jars. For example, I

consider

Jakarta's commons-lang and commons-collections to be part of this baseline
and any code which uses the baseline API should be able to rely on having
access to those classes. If I decide that another jar should be added to

the

baseline I'd prefer to add it just once, rather than separately in each
project that uses the baseline. This could be done with a library, but for
the fact that parts of the API are my own code, which I want to be able to
edit - ideally without having to switch out of whatever project I happen

to

be in at the time.

>

Does that seem reasonable? Is there a better way to manage this than with
modules? I suppose it could be done by defining a library containing all

the

external jars for the baseline and a module for my own source, but that

does

seem less convenient (two things to add to each dependent project, instead
of just one). I'm interested in peoples thoughts on this.

>

Vil.

>

Eugene Zhuravlev (JetBrains) wrote:

No, the behaviour is intentional. Libraries are properties of a module

and if one module depends on another, it means that it can

directly use another module's code, but not its libraries. If your

Project module needs the jar, it should be explicitly added to

the module's "Libraries" tab.

>

--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

>


0

I'll file an SCR then. Thanks!

Vil.

Valentin Kipiatkov (JetBrains) wrote:

Yes, this sounds reasonable. I think it's a good feature request. We could
implement in the version right after Aurora.


--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

It's filed at http://www.intellij.net/tracker/idea/viewSCR?publicId=19263

Vil.

Vilya Harvey wrote:

I'll file an SCR then. Thanks!


--
Vilya Harvey
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

0

>> We could implement in the version right after Aurora.
I understand that you are eager to start selling the 4.0 version.
However multi-module support isn't worth much without this feature. Please reconsider this issue for inclusion into Aurora.

Stephen

0

Stephen Kelvin wrote:

>>> We could implement in the version right after Aurora.

I understand that you are eager to start selling the 4.0 version.
However multi-module support isn't worth much without this feature. Please
reconsider this issue for inclusion into Aurora.

Stephen


You can always create a project/global library with needed jars and then
reference it from all modules interested, rather than defining a module
with those jars and then making other modules depend on them.

Or am I missing something?

Friendly,
Dmitry

--
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Stephen Kelvin wrote:

>.. multi-module support isn't worth much without this feature. Please reconsider this issue for inclusion into Aurora.

>

I agree.

Alain

0

You can always create a project/global library with
needed jars and then reference it from all modules
interested, rather than defining a module with those jars
and then making other modules depend on them.


Sure, but I had hoped that with multi-module support I would be able to mirror my actual module/package structure. We have a couple of larger projects subdivided into about ten modules, where most modules are used in multiple projects.
Each module is on a separate CVS root and has its own source, test source and library folders. Some of the libraries are internal to the module, while some should be made available to the project.

I had hoped that I only configure the project's own source folder and libraries and then simply include each module I need (supposing that the module definition file is checked in beneath each module's CVS root).

With your suggestion there is a lot more setup to do.
I'd probably stick with my current approach of having only a single module with each of my "modules" using its own content. Then include every jar found in the project and any module in the libraries.

0


Stephen Kelvin wrote:

With your suggestion there is a lot more setup to do.
I'd probably stick with my current approach of having only a single module with each of my "modules" using its own content. Then include every jar found in the project and any module in the libraries.


I agree. Currently, in idea we just include every jar that every
component might need, along with every source root. In the ant scripts,
each component is built against just its exact dependencies. The ant
path definitions (for sources, jars, etc) are defined in a xml snippet
that can be included in referenced in any other ant script. When module
A needs to use module B, it can include the results of building module B
and reference a path id that has B's public jars.

I'm definately of the opionion that an idea module should have a public
aspect that can be defined as the project sees fit. This would include
all or a subset of the actual code built from that module and all or a
subset of the jars used to build that module. (Similar to how eclipse
itself is extended.)

0

Hi Dmitry,

I just tripped over this in Build 963...

For now, I am doing as you suggest and making a project level library and then including that library in each module in the project.

I like the library concept and it's useful at times but it's not enough now that IntelliJ has modules.

You can fix this by adding check boxes indicating that a jar or library should be "exported" and used by any module depending on this module. (This is what Eclipse does to export jar files).

By the way, I really like where IntelliJ is going with it's module support. This is really needed functionality.

Thanks.

0

Please sign in to leave a comment.