Will
Will

Reputation: 8631

Maven: Sibling inheritance

I have a problem similar to the egg and the chicken.

I have two sibling child modules. The Exception handling package is in MDP module. The MDP module also seeks reference of the Transformer module.

<dependency>
    <groupId>dcconverter</groupId>
    <artifactId>transformer</artifactId>
    <version>${converter-shell}</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
 <dependency>
    <groupId>dcconverter</groupId>
    <artifactId>validate</artifactId>
    <version>${converter-shell}</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

So in order to build the MDP Module the Transformer must be built before as it is a dependency. I wish to implement ExceptionHandling within the Transformer module. It can not access the MDP classes unless I declare the MDP module as a dependency. Here in lies the problem of the egg and the chicken.

Now, I could move the exception handling into the Validate module which has no sibling dependencies which solve the problem. However I still need to list all siblings with a dependency on Validate. Is this good practice? Or is there a way around these inter-dependent siblings?

Upvotes: 1

Views: 208

Answers (1)

nwinkler
nwinkler

Reputation: 54427

Keep it simple! Make sure every artifact has well defined responsibilities and interfaces. Why don't you create a separate module just for the exception handling functionality? You could then include this in any other modules that require this functionality.

If you run into issues like you're currently seeing, it usually means that your dependencies are too complex. Try to break it down as much as possible. The overhead of adding another module should be fairly low compared to the added flexibility and reusability you're getting.

Upvotes: 2

Related Questions