Maven 阶段/目标优先级问题
我在运行 mvn test
时想要替换两个 bash 脚本中的一些属性,这样一个脚本可能会在 test
阶段之前执行,而一个脚本可能会在之后执行,使用 >exec-maven-plugin
。
bash 脚本如下所示:
startMongo
#!/bin/bash
${mongodNixDirLocation}/mongod --fork --logpath "${mongodLogDir}" --port ${mongodbTestPort}
/bin/sleep 10
stopMongo
#!/bin/bash
mongoDbServer=`lsof -i tcp:${mongodbTestPort}| awk 'NR!=1 {print $2}'`
for i in $mongoDbServer; do
echo "Stopping mongo DB server instance: $i"
kill -s SIGINT $i
done
当我运行 mvn test
时,我似乎遇到了执行顺序问题。输出类似于 so。
exec-maven-plugin
正在尝试在进行正确的替换之前执行 startMongo
脚本 - 因此错误消息显示为执行 mongod
来自 /mongod
。
如果我运行 mvn process-test-resources,则替换会正确进行,并且我可以成功手动运行脚本。
我的 pom.xml 配置类似于 so。我如何正确配置正确的阶段才能使其发挥作用?
I have some properties in two bash scripts I want substituted when running mvn test
, such that one script might be executed before the test
phase, and one after, using the exec-maven-plugin
.
The bash scripts look like so:
startMongo
#!/bin/bash
${mongodNixDirLocation}/mongod --fork --logpath "${mongodLogDir}" --port ${mongodbTestPort}
/bin/sleep 10
stopMongo
#!/bin/bash
mongoDbServer=`lsof -i tcp:${mongodbTestPort}| awk 'NR!=1 {print $2}'`
for i in $mongoDbServer; do
echo "Stopping mongo DB server instance: $i"
kill -s SIGINT $i
done
I seem to be having issues with the order of execution when I run mvn test
. The output is like so.
The exec-maven-plugin
is trying to execute the startMongo
script before the proper substitutions have been made - hence the error message appearing to execute mongod
from /mongod
.
If I run mvn process-test-resources
, the substitutions are correctly made, and I can manually run the script successfully.
My pom.xml is configured like so. How can I appropriately configure the correct phases such that this will work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来问题出在以下行:
如果此脚本 -
startMango
- 需要过滤,则过滤将完成并将结果放置在target/test-classes
文件夹中。原始文件将不会被更新。如何将上面的行更改为:
对于
stopMongo
也是如此。我不确定它是如何手动工作的。
It looks like the problem is in the following line:
If this script -
startMango
- needs filtering, the filtering will be done and the result places intarget/test-classes
folder. The original file will not be updated.How about altering the above line as:
Likewise for
stopMongo
as well.I am not sure how it manually worked though.