apt-getschwifty
apt-getschwifty

Reputation: 199

Cyclic dependencies on multi-module maven project

I have been writing a very simple blockchain in java for the last few weeks as a maven project with Intellij. When I began this project, I was okay with everything residing in a single module, even though there are technically two artifacts that need to be built for the project to work (An executable .jar for the application/control logic and a .war for all of the p2p stuff deployed via tomcat container). I used separate profiles to build the .jar and .war, and executed/deployed them manually.

I have, however, grown tired of this and believe that splitting this up into a multi-module project (a .war, .jar and .ear? maybe..) is the only way to achieve my goal of being able to build and execute/deploy everything all at once with a single command. I have begun to do this, but have become confused by cyclic dependencies between the two child modules. I have code on the application side that depends on the network side, and code on the network side that depends on the application side. How can I resolve this by creating another module and thus another pom.xml? Any suggestions would be greatly appreciated! Please bear with me, as I am still a novice in java/maven, this is my first real crack at an application with any degree of complexity.

Upvotes: 0

Views: 2148

Answers (1)

Sivaraj Velayutham
Sivaraj Velayutham

Reputation: 187

when your child modules c1 and c2 dependent on each other, meaning a class or packages, then the common package should be in a separate module c3. Add c3 as dependency in both c1 and c2 project.

you can not add c1 as dependency in c2 and c2 as dependency in c1. Because when maven tries to analyze your code, it can not find the which module to build first due to this cyclic dependency.

Upvotes: 1

Related Questions