1

Higuys,

I am not an expert in maven and this is what I am trying to achieve. I have a main maven project but it has a dependency on another project. So when I push any change in this another project, I execute some integrations tests for which i need those changes which i submitted in this another project and hence I wish to have the dependency directly from the Git repo.

Also the second step after getting the dependency directly in the Pom.xml of main project I wish to build this sub- project

Could someone throw some light on this issue.

Regards

ajax
  • 317
  • 8
  • 17

1 Answers1

0

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:

  1. Clone (or pull) both Git repositories to projectA and projectB
  2. Change projectB, commit and optionally push your changes
  3. Run mvn install in projectB
  4. Go to projectA and check that you reference the correct version of projectB (usually *-SNAPSHOT while developing)
  5. 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:

Community
  • 1
  • 1
nif
  • 3,342
  • 20
  • 18