0

I have two modules at the same hierarchy level, each a child of the same parent pom.xml: foo (jar) and bar (war). foo is a dependency of bar:

<dependency>
    <groupId>parentArtifact</groupId>
    <artifactId>foo</artifactId>
    <version>1.0</version>
</dependency>

When I run mvn install in bar, foo does not get rebuilt. It does if I run a build at the parentArtifact level but I don't want to do it, for speed (there are other modules).

How can I force a rebuild of foo every time a build is run in bar?

2
  • I don't understand because but I don't want to do it, for speed (there are other modules). but in the title you've written: to rebuild.. so go to the root level and rebuilt it via mvn clean package or use mvn clean verify if you have integration tests.
    – khmarbaise
    Feb 7, 2022 at 6:31
  • there are 7 modules in the parent but I want to run only 2 (bar + its dependency foo)
    – amphibient
    Feb 7, 2022 at 17:26

1 Answer 1

0

Go to the parent level and run

mvn clean install -pl bar -am

This will build bar and all dependencies of bar.

2
  • I am trying to do it at the sub-module level where other sub-modules are rebuilt if they are depenencies
    – amphibient
    Feb 7, 2022 at 17:26
  • I cannot be done at the submodule level. At least not with Maven alone. Feb 8, 2022 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.