0

This is a similar (but opposite) question to Can we start the maven build from the point where it failed: Am wondering if there is an option to stop the build at (or after) a particular project. Something like a --stop-after option in the same vein as --resume-from?

Use case: This would sometimes be a useful feature to me, e.g. to create a standalone JAR that is a dependency for other modules but has its own dependent modules that need to be built first:

    /------Parent pom------\
    |          |           |
Module 1 -> Module 2 -> Module 3

Here's a simplified example but illustrates the point: Let's say we have a parent pom.xml that lists modules 1, 2 and 3 that are each dependent on the next in that order. So to build Module 2, we need Module 1 to be built first. But we're only interested in building Module 2 and don't want to go any further once this has been done (Module 3 takes ages or does stuff we don't want to do e.g. rebuild the database). So here we'd want to run Maven from the parent director and both resume from and stop after Module 2.

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
  • Could you clarify your use-case? This really sounds like a XY problem: you don't want to stop the build. – Tunaki Nov 17 '15 at 15:05
  • @Tunaki OK, have added more details of the use case to the question. – Steve Chambers Nov 17 '15 at 15:11
  • 1
    @Tunaki Thanks for the duplicate link. Although `--also-make` looks promising it doesn't quite do what would be ideal since in the example case it would always look to build Module 1 before Module 2. `-projects` isn't ideal either as it requires all dependencies that need to be built to be manually specified. But guess this is just a Maven limitation... – Steve Chambers Nov 17 '15 at 15:22
  • Yes that's how Maven is: you can't build Module 2 without building Module 1 since it's a dependency and they both belong to the same multi-module project. – Tunaki Nov 17 '15 at 15:26
  • 1
    Cruel, was about to post an answer. You can define what modules are built per profile by defining the `` node underneath each ``. Change your `` element in the root pom to only contain `module1` amd `module2` then define all 3 modules underneath the profiles you wish to build all 3. – ug_ Nov 17 '15 at 15:28
  • @Tunaki Well you can with `-rf` if it's already been built... – Steve Chambers Nov 17 '15 at 15:28
  • 2
    @ug_ I thought about profiles also but I don't think it fits in this use-case. OP wants to build Module 2 or Module 3, in a sort of dynamic manner. We would have to define profiles for each scenario, which is really crumbersome – Tunaki Nov 17 '15 at 15:30

0 Answers0