In Maven, how can I recursively build -SNAPSHOT dependencies present on the filesystem but outside the reactor?

I have two projects as shown below in adjacent file system directories:

  • project_a (-SNAPSHOT)
  • project_b (-SNAPSHOT, depends on project_a)

I would like to build project_b and for Maven to detect that project_a exists on the filesystem and thus build it rather than looking in the local repo for its artifact.

I could build them in an aggregator and use a reactor to select project_b ie

mvn --projects project_b [goal]

      

However, this is problematic because

  • this two-project example is a simplification of my real build, which has dozens of projects, and I don't want me to have to maintain an aggregator project that lists all of them.
  • I only want to recursively build dependencies -SNAPSHOT

Do I have a neat way to get Maven to do a recursive build that looks up the filesystem to find the -SNAPSHOT dependency projects and build them?

+3


source to share


2 answers


You can play with the Maven Reactor plugin for example. try itmvn reactor:make -Dmake.folders=foo,bar



+1


source


I needed this a while ago and made a simple recursive cli wrapper in nodejs. https://github.com/kenglxn/mvnr/blob/master/README.md

Install from npm using



sudo npm install -g mvnr

      

Then just pass any maven command to mvnr and it will run that command for all mvn projects in the cwd directory.

+1


source







All Articles