如何使用不同的参数运行相同的Maven配置文件
工作当前使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为您要做的是一种很好的方法,但是如果这是紧迫的……您是否考虑过使用不同的设置 - [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?