0

Working with a multi-module project. Want to run maven commands as follows:

mvn clean compile

Then maven install phase without again executing maven compile

Arpit
  • 23
  • 9

2 Answers2

0

Not possible.

You would need to call the goals directly, phases cannot be run separately.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Please elaborate on how to separately run goals. Tried `mvn clean install -DskipTests` followed by test goal execution `mvn surefire:test`. But the goal fails, as its unable to find classes – Arpit May 10 '20 at 07:30
  • I am not sure whether the tests are compiled if you skip tests. Generally, this is not the idea of Maven. The idea is to call `mvn clean install` and do _all_ the stuff in one run. – J Fabian Meier May 10 '20 at 08:27
  • Does running `mvn clean install -dskipTests` followed by `mvn test` the right approach? It will compile tests, but will code already compiled in the first step be skipped? – Arpit May 10 '20 at 14:31
  • Probably. But the best approach would be to just call `mvn clean install` because it already runs the tests. – J Fabian Meier May 10 '20 at 15:46
0

you can (now) skip phases by directly calling the goal via

mvn <plugin>:<goal>

e.g.

mvn compiler:compile

see this answer for details.

for install it should be mvn install:install

Andreas Covidiot
  • 4,286
  • 5
  • 51
  • 96