Maven multi-module project and workspace dependency resolution through the command line

30 Views Asked by At

If I have a multi-module project like:

<project >
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>multi-module-parent</artifactId>
    <version>0.0.2-SNAPSHOT</version>
    <name>multi-module-parent</name>
    <packaging>pom</packaging>
    

    <modules>
        <module>model</module>
        <module>service</module>
        <module>api</module>
    </modules>
</project> 

Working in eclipse, I have enabled maven workspace dependency resolution in the project. Using the spring boot run configuration to launch the api project, it automatically detects changes in the model or service projects and restarts the api project with the changes.

For future development though, it would be nice to wrap a bunch of microservice apps in a docker-compose yaml file to ease development. It seems the most straight-forward way would be to run each api in a container using maven and have it listen to the changes made to the underlying model/services projects. I can't recreate that behavior when launching with maven though.

If I launch the apps like this ./mvnw clean package ./mvnw -f ./api spring-boot:run

it won't detect the latest changes or the projects in my workspace unless I run the maven install goal to push the artifacts to the local maven repo. It would slow things down considerably to have to rebuild and then relaunch all of the time.

So, how do I replicate the eclipse maven workspace dependency resolution while using the maven command line?

0

There are 0 best solutions below