假设我的maven项目位于/some/location/project
中,而我当前的位置是/another/location/
,如何才能在不切换到项目位置cd /some/location/project
的情况下运行maven build呢?
发布于 2011-06-26 01:56:50
您可以使用参数-f
(或--file
)并指定pom文件的路径,例如mvn -f /path/to/pom.xml
这将运行maven,就好像它是在工作目录的/path/to
中一样。
发布于 2011-06-26 00:06:49
我不认为maven支持这一点。如果您使用的是Unix,并且不想离开当前目录,则可以使用一个小的shell脚本、一个shell函数,或者只使用一个子shell:
user@host ~/project$ (cd ~/some/location; mvn install)
[ ... mvn build ... ]
user@host ~/project$
作为bash函数(可以添加到~/.bashrc中):
function mvn-there() {
DIR="$1"
shift
(cd $DIR; mvn "$@")
}
user@host ~/project$ mvn-there ~/some/location install)
[ ... mvn build ... ]
user@host ~/project$
我知道这并没有回答具体的问题,但可能会给你提供你想要的东西。我不熟悉Windows shell,不过您应该也能在那里找到类似的解决方案。
问候
发布于 2019-02-15 02:47:17
对我来说,是这样工作的:mvn -f /path/to/pom.xml [goals]
https://stackoverflow.com/questions/6478536
复制相似问题