1

Can someone tell me why after executing a .bat script only the first mvn deploy command is executed and then execution close. Why all command are not executed?

set GROUP_BASE=com.oracle.jdeveloper.jars
set VERSION=10.1.3.3.0.4157
set JDEV_HOME=C:/Oracle/jdevstudio10133
set REPO_URL=http://localhost:8081/nexus/content/repositories/thirdparty
set REPOSITORY_ID=thirdparty
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_lib -DartifactId=bc4jct -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/bc4jct.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_lib -DartifactId=adfm -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/adfm.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_jlib -DartifactId=bc4jui -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/jlib/bc4jui.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.jlib -DartifactId=osdt_core -Dversion=%VERSION% -Dfile=%JDEV_HOME%/jlib/osdt_core.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.ord_jlib -DartifactId=ordim -Dversion=%VERSION% -Dfile=%JDEV_HOME%/ord/jlib/ordim.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.xdoclet-1_2_1 -DartifactId=xdoclet-ibm-module-1.2.1 -Dversion=%VERSION% -Dfile=%JDEV_HOME%/xdoclet-1.2.1/xdoclet-ibm-module-1.2.1.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.jlib -DartifactId=jssl-1_1 -Dversion=%VERSION% -Dfile=%JDEV_HOME%/jlib/jssl-1_1.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.jlib -DartifactId=javax-ssl-1_1 -Dversion=%VERSION% -Dfile=%JDEV_HOME%/jlib/javax-ssl-1_1.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
Rich
  • 5,603
  • 9
  • 39
  • 61
senzacionale
  • 20,448
  • 67
  • 204
  • 316
  • possible duplicate of [Executing multiple commands from a Windows cmd script](http://stackoverflow.com/questions/197976/executing-multiple-commands-from-a-windows-cmd-script) – Helen Aug 26 '10 at 18:59

2 Answers2

2

Try with using the CALL command.

...
call mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_lib -DartifactId=bc4jct -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/bc4jct.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
call mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_lib -DartifactId=adfm -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/adfm.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
...

If you invoke a command without using CALL, control passes over to the new program and does not return (in your example this is what happens after the first mvn ...). CALL returns control to the caller and execution continues with the next instruction.

  • @Bobby: "start" opens up a new CMD window and I don't think you want a window for each command (especially if you have lots of them :D). I also think that "start" does not wait for the process to terminate, but I might be wrong about that. –  Jun 21 '10 at 14:22
  • @dpb: I've never noticed that that one would open a new cmd. :/ Also, I thought that was asked, that it runs 'asynchron'... – Bobby Jun 21 '10 at 14:43
  • I believe `CALL` is only relevant when calling another batch file. – aphoria Jun 21 '10 at 15:22
  • @aphoria CALL is valid for any executable (START calls ShellExecute and can open any registered type or url protocol, but the command will run in a new window etc) – Anders Jun 21 '10 at 16:23
  • @aphoria: Some tools actully use a batch file which can lead to unexpected things. `ant` is such a tool too. – Joey Jun 21 '10 at 18:22
  • @Anders You are correct. I guess I just haven't seen a reason to use `CALL` with an executable. Using `CALL` to call another batch file returns control to the original batch file when the secondary batch file is complete. What does using `CALL` with a .EXE do for you? I did some limited testing, but could not tell a difference. – aphoria Jun 21 '10 at 18:49
  • @Johannes I'm not sure what you are referring to. – aphoria Jun 21 '10 at 18:50
1

Try this for each line you are running mvn:

START /WAIT "" mvn deploy:deploy-file -DgroupId=%GROUP_BASE%.BC4J_lib -DartifactId=bc4jct -Dversion=%VERSION% -Dfile=%JDEV_HOME%/BC4J/lib/bc4jct.jar -Dpackaging=jar -DrepositoryId=%REPOSITORY_ID% -Durl=%REPO_URL%
aphoria
  • 19,796
  • 7
  • 64
  • 73