Hay
Hay

Reputation: 2281

IntelliJ with one Maven project depending on another Maven project: How to be efficient?

My team is regularly facing inconveniences when running a Maven project that depends on other Maven projects which were modified but not reinstalled to the local repository.

For the sake of simplification, let's say I have two Maven projects Business and Web. My Web project has in its dependencies the Business project, and a Jetty plugin which allows me to run a local web server for development.

In IntelliJ, both projects are opened on the same window using Maven Add project, so that I can navigate through the code easily between the two projects.

Currently, I have set up a Run Configuration in IntelliJ so that mvn clean install -DskipTests will run on the Business project, and then mvn clean jetty:run on Web. This allows me to run Web with the latest modifications made in Business. If I don't run clean install on the Business project, then Web will run on an older version of the source code of Business. In addition this will mess up the IntelliJ debugger as the source code being debugged will not match the runtime class.

In a real application, a Dependency Injection Bootstrap project may depend on Web, Business, Some Database Adapter X, Some Database Adapter Y, Some API Client Adapter... therefore the clean install may become costly. In addition it is easy to forget to build the dependee project, which is the reason why the Maven goals are always run before running Jetty.

Is there a way to be more efficient during development, so that a modification on a dependee project will be active when running the dependant projects without having to run any/many Maven goals?

Upvotes: 1

Views: 307

Answers (1)

Create a tiny parent project pom.xml which references both Business and Web as modules. Then tell Intellj to open the parent project - this will let Web access Business (if properly referenced) without having to install the artifacts locally.

Upvotes: 2

Related Questions