Your main Maven project can't directly depend on source code stored in Git. Maven is quite extensible and you could write a plugin that will clone the Git repository, build the Maven project and install it to your local repository. However, I'm not aware of any existing plugins.
The simplest workflow as the only developer of the projects is:
- Clone (or pull) both Git repositories to
projectA
and projectB
- Change
projectB
, commit and optionally push your changes
- Run
mvn install
in projectB
- Go to
projectA
and check that you reference the correct version of projectB
(usually *-SNAPSHOT
while developing)
- Run
mvn test
in projectA
and it will take the fresh version of projectB
Optionally, you can create a root pom which include the main project and its dependencies as modules, so that they are built in the correct order.
It is not the workflow you should use when projects grow. Especially if you work together with other developers on the projects, you might consider using a remote repository for your Maven artifacts, e.g. with Nexus. Whenever a developer changes a project, they will deploy the new version to the remote repository using mvn deploy
. Maven will then automatically download dependencies from the remote repository.
References: