使用 maven 在文件中附加值 [英] Append value in a file using maven

查看:39
本文介绍了使用 maven 在文件中附加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文件末尾附加一个值,但我无法确定要使用哪个插件.

I have a value that I want to append at the end of a file, but I cannot figure which plugin to use.

示例:我要附加的值:myValue"

Example: the value I want to append: "myValue"

文件:

值 1

值 2

myValue # after append

myValue # after append

我知道我可以使用 antrun-plugin 来做到这一点,但是否可以使用 Maven 插件来做到这一点?

I know I can do it using the antrun-plugin, but is it possible to do this with a maven plugin?

我还查看了 maven-shade-plugin,但是从他们网站上的几个示例中,我只看到执行 2 个文件的附加,而不是我需要的(附加到一个文件的值))

I've also looked over maven-shade-plugin, but from the few examples on their website I only saw doing append of 2 files instead of what I need (value to append to one file)

推荐答案

很抱歉,但我认为您最好的选择确实是 Ant 插件.

Sorry to say, but I think your best option really is the Ant plugin.

每次必须在我的 pom.xml 中使用 Ant 时,我都会不寒而栗,但在某些情况下,这是最简单的选择.学会接受它,它会为你省去一些麻烦:-)

I shudder every time I have to use Ant in my pom.xml, but in some cases, it's the easiest option. Learn to embrace it, it will save you some headaches :-)

您也可以编写自己的 Maven 插件,但这可能需要更多的工作.

You could probably also write your own Maven plugin, but that would likely be more work.

另一种选择是创建一个 shell 脚本来附加值,然后使用 maven-exec-plugin 调用它.不过,在这种情况下,您将不得不处理不同的操作系统.

One other option would be to create a shell script to append the value, and then call that using the maven-exec-plugin. You'll have to deal with different operating systems in that case, though.

这篇关于使用 maven 在文件中附加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆