开发者

call batch file from cygwin breaks after 1st command?

I'm have a "bat" file with some maven commands which are pretty long so I tried to create a single file with MVN commands to execute. I call my bat file in开发者_运维问答 cygwin as:

$./mvncommand.bat

Sample MVN commands in my file:

mvn install:install-file -DgroupId=org.openhealthtools.ihe -DartifactId=atna.auditor -Dversion=1.2.0 -Dfile=resources/lib/org.openhealthtools.ihe.atna.auditor_1.2.0.jar -Dpackaging=jar -DgeneratePom=false

mvn install:install-file -DgroupId=org.openhealthtools.ihe -DartifactId=atna.context -Dversion=1.2.0 -Dfile=resources/lib/org.openhealthtools.ihe.atna.context_1.2.0.jar -Dpackaging=jar -DgeneratePom=true

Strangely, only the first mvn install is executed and the all is ok. But how to make Cygwin call the rest of the mvn commands?

Thank you.

JR


Maven (mvn) is a batch file and running batch files from another batch file must be done with call.

So change what you have into

call mvn ...

and it should work.

This has nothing to do with Cygwin, by the way.


It's possible that your first mvn command is returning an error code. In Windows's cmd, this will cause all subsequent commands to not run. This might be the behavior you want, but you should consider using a *nix-like shell rather than a Windows batch file since you're already using Cygwin.

For example, you could put both commands in a file named mvncommand with your shell of choice.

#!/usr/bin/bash
mvn install:install-file -DgroupId=org.openhealthtools.ihe -DartifactId=atna.auditor -Dversion=1.2.0 -Dfile=resources/lib/org.openhealthtools.ihe.atna.auditor_1.2.0.jar -Dpackaging=jar -DgeneratePom=false

mvn install:install-file -DgroupId=org.openhealthtools.ihe -DartifactId=atna.context -Dversion=1.2.0 -Dfile=resources/lib/org.openhealthtools.ihe.atna.context_1.2.0.jar -Dpackaging=jar -DgeneratePom=true
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜