4

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?

Peter Mularien
  • 2,578
  • 1
  • 25
  • 34
Jan Olaf Krems
  • 2,274
  • 1
  • 14
  • 11

1 Answers1

2

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

Thorn G
  • 12,620
  • 2
  • 44
  • 56
  • well, I already find typing "exec:exec" cumbersome, if possible I'd rather type "mvn run" or "mvn exec". Sorry, forgot to mention that in the question. It just seems weird to have the only way possible to start the application ("mvn exec:exec") not working by default. – Jan Olaf Krems Dec 03 '12 at 21:16
  • That's a different question, then. If it's a matter of saving keystrokes, alias it in your shell, or set up a run configuration in Eclipse/Netbeans/your IDE of choice. – Thorn G Dec 03 '12 at 21:32