Skip to content

Windows Batch file exists after maven command completes

September 7, 2010

Hi folks,

It’s been while since my last post. However here we go again.

Recently I have involved with some  java projects. Here we used Apache Maven build tool to build and deploy the project. To avoid the repetition of typing maven build command (a lengthy one with custom build profiles) several times a day, I decided to create the following batch file.

echo OFF

cd “my_project_folder”

mvn clean install

echo ON

pause

Everything went fine with above set of commands excepts the pause command never executes. So I could never have a good look at the maven build results. After some research I found the solution.

mvn itself is a batch file. So with execution of mvn clean install line, my original batch file delegates the control to the maven batch file. But after the maven execution completes it never returns the control to the original batch file. So any command after the mvn clean install line never executes.

In order to return the control to the calling batch file you need to use it as

call mvn clean install

Solved.

Regs,

Lasith.

Advertisement

From → Uncategorized

2 Comments
  1. Narayan permalink

    was facing same issue.
    got mad trying start /wait.
    Thanks for solution.

    Regards,
    Narayan.

  2. Thank you very much – excactly what I’ve needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.