views:

1340

answers:

4

I have this .bat script which I use to maven package my application. Problem is, just after it ends execution, it closes the console window. The last 2 lines somehow are completely ignored.

Does anyone know the trick to make this work? I just want to have a quick check if the build was successful.

@echo off
cls
cd C:\svn\project
mvn package -o -P local
sleep 3
pause
A: 

Here is a hack that I found here:

ping 1.0.0.0 -n 1 -w 5000 >NUL

This will ping an unreachable host with a pause in between. Also the standard output is redirected so you don't see it in your output. Not the best solution but will work in a pinch.

Andrew Hare
I don't think the OP's problem is to add a delay, but that mvn somehow avoids additional commands to be executed.
schnaader
+2  A: 

You could try to write

call mvn package -o -P local
schnaader
A: 

Windows Server 2003 Resource Kit Tools provides a command line sleep function:

http://malektips.com/xp_dos_0002.html

Chris Ballance
A: 

schnaader answer did it, thanks.

I had tried the sleep function before and tried now the ping hack, it seems mvn indeed ignores additional commands to be executed.

falmp
If my answer worked, then somehow the batch thread did go done the dumps together with the mvn thread or something like this. The same happens if you call a batch file with exit in it without using "call".
schnaader