Jan Olaf Krems
Jan Olaf Krems

Reputation: 2294

Always run lifecycle phase (e.g. package) before goal (e.g. exec:exec)

I'm trying to get into maven and started writing just a small library. As part of the library code I want to have a small demo java application one can use to see what the library is doing and how to use it. One thing that really annoys me right now is that in order to execute that demo I have to execute two commands: mvn package and mvn exec:exec or mvn package exec:exec.

Is there any way to configure maven to automatically run "package" before "exec:exec"? So that I can run mvn exec:exec on a fresh checkout and compilation will implicitly happen before execution?

Upvotes: 4

Views: 543

Answers (1)

Thorn G
Thorn G

Reputation: 12776

mvn package exec:exec

You can specify multiple goals for Maven to execute as part of the same command.

Additionally, when you configure the exec plugin, you can bind the execution to the package phase: Lifecycle Intro

Upvotes: 2

Related Questions