Denis Stephanov
Denis Stephanov

Reputation: 5241

Use parent module as dependency

I have multi-module java library with some classes, configs, and so on in structure like this:

/common-parent
--/common-a
--/common-b
/module-a
/module-b

module-a needs import only module common-a but in module-b I need import modules common-a and common-b.

Is possible to import both as one dependency? I tried import parent module common-parent into module-b but I still cannot see classes in these modules. Common-parent module use pom packaging and his sub-modules use default jar packaging. Thank you in advice.

Upvotes: 0

Views: 394

Answers (1)

kutschkem
kutschkem

Reputation: 8163

It does not work this way, the parent-child relation only does one thing: The child inherits configuration from the parent. If you declare the parent as dependency, you only depend on the parent, not on modules defined in its pom, nor on children which inherit from the parent.

In order for this to work, you need some module which declares a dependency on common-a and common-b, and depend on that.

Upvotes: 2

Related Questions