Append value in a file using maven

狂风中的少年 提交于 2021-01-27 07:23:39

问题


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

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

file:

value1

value2

myValue # after append

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

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)


回答1:


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

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 :-)

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

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.




回答2:


The Codehaus gmaven-plugin is another option for tasks like these.




回答3:


You can use maven filtering to achieve what you are looking for.



来源:https://stackoverflow.com/questions/14896059/append-value-in-a-file-using-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!