如何使用不同的参数运行相同的Maven配置文件

发布于 2025-01-23 03:46:28 字数 704 浏览 2 评论 0原文

工作当前使用ANT,需要迁移到Maven。如上所述,我需要运行相同的配置文件,但每次都有不同的参数。

当前的蚂蚁代码示例:

<target name = SomeTarget>
<var name = "PROP" value="123">
<antcall target = "OutTarget1">
<var name = "PROP" value="145">
<antcall target = "OutTarget1">
</target>

<target name ="OutTarget1">
<!-- some java code -->
<!-- run .SQL files -->
<!-- some java code on that again -->
<\target>

即使使用Maven Antrun插件,也没有支持。

工作要求我将所有目标创建为pom.xml中的配置文件。现在,我可以每次都有新属性时简单地重复配置文件的执行部分中的“ outtarget1”代码。但这使得很难调试。而且有很多目标呼叫其他目标。

如果仅仅是一个antcall,则在启动配置中添加参数。当它是相同的参数时,我不知道如何实现此目标,但每次都不同。

PS添加了Outtarget的作用。这基本上是相同的过程,但每次都有差异值。

Work currently uses ANT and need to migrate to MAVEN. As stated above , I need to run same profile but with different parameters each time.

Present Ant Code Example :

<target name = SomeTarget>
<var name = "PROP" value="123">
<antcall target = "OutTarget1">
<var name = "PROP" value="145">
<antcall target = "OutTarget1">
</target>

<target name ="OutTarget1">
<!-- some java code -->
<!-- run .SQL files -->
<!-- some java code on that again -->
<\target>

Doesn't seem like even with maven antrun plugin antcall is supported.

Work requires I create all targets as profiles in pom.xml. Now I can simply repeat the "OutTarget1" code in execution part of a profile for each time there is a new property. But that makes it quite hard to debug. And there's a ton of a t targets calling other targets.

If it was just one antcall , I add the parameter in launch configuration. I have no idea how to achieve this when it's same parameter but different values each time.

P.S. Added what OutTarget does. It's basically the same process but with diff values each time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

叹沉浮 2025-01-30 03:46:28

我不认为您要做的是一种很好的方法,但是如果这是紧迫的……您是否考虑过使用不同的设置 - [x] .xml,相同的配置文件的定义不同并启动Maven指向它们?

I don't think what you're trying to do is a good approach, but if it's urgent...have you considered using different settings-[X].xml, with the same profile defined differently and launch maven pointing to them?

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