开发者

Maven exhibits strange behaviour from cmd windows 7

开发者 https://www.devze.com 2023-03-19 22:45 出处:网络
I am using maven in a project here at work and I\'ve come up to a rather strange (at least for me) problem. When I do an: mvn package everything seems ok but the output of mvn disappears as soon as ma

I am using maven in a project here at work and I've come up to a rather strange (at least for me) problem. When I do an: mvn package everything seems ok but the output of mvn disappears as soon as maven completes. To test it more I just did a: mvn --help and I could not see the output. As soon 开发者_JS百科as the command finishes the prompt is cleared. I am doing my work now using redirections: mvn package > out and then: type out in order to see the output. Any help would be greatly appreciated!

Thanx!

Solved: To whoever finds this useful. At the end of mvn.bat there was the line

    cmd /C exit /B %ERROR_CODE%

which I had to comment out like this:

    @REM cmd /C exit /B %ERROR_CODE%


Check if the MAVEN_TERMINATE_CMD is set to on. If it is unset it:

set MAVEN_TERMINATE_CMD=

Check that the mvn.bat script in maven's bin directory doesn't contain an exit command without the /b option. It should end with the following line:

cmd /C exit /B %ERROR_CODE%

If neither alternative solves your problem, set the MAVEN_BATCH_PAUSE variable to on:

set MAVEN_BATCH_PAUSE=on

before you run maven. This should cause mvn.bat to wait for a keystroke before exiting.


The following is an example of how to use mvn in a batch file under Windows 7 and Maven 3.2.1

:: ensure variables do not propagate outside this batch call
setlocal

:: save current directory and change to ".."
pushd ..

:: tell mvn.bat to exit after done, not to spawn cmd (why is this by default..)
set MAVEN_TERMINATE_CMD=on
:: spawn new cmd prompt to handle the mvn call, which blocks and exits
cmd /c mvn clean install

:: do something fancy here

:: cd to saved directory (pushd)
popd
:: pause the script and require pressing a key to continue
pause
0

精彩评论

暂无评论...
验证码 换一张
取 消