Maven 阶段/目标优先级问题

发布于 2024-12-27 18:43:58 字数 1034 浏览 1 评论 0原文

我在运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恏ㄋ傷疤忘ㄋ疼 2025-01-03 18:43:58

看起来问题出在以下行:

<executable>src/test/resources/startMongo</executable>

如果此脚本 - startMango - 需要过滤,则过滤将完成并将结果放置在 target/test-classes 文件夹中。原始文件将不会被更新。

如何将上面的行更改为:

<executable>${project.build.directory}/test-classes/startMongo</executable>

对于 stopMongo 也是如此。

我不确定它是如何手动工作的。

It looks like the problem is in the following line:

<executable>src/test/resources/startMongo</executable>

If this script - startMango - needs filtering, the filtering will be done and the result places in target/test-classes folder. The original file will not be updated.

How about altering the above line as:

<executable>${project.build.directory}/test-classes/startMongo</executable>

Likewise for stopMongo as well.

I am not sure how it manually worked though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文