Add value to file using maven

I have a value that I want to add at the end of the file, but I canโ€™t figure out which plugin to use.

Example: value I want to add: "myValue"

File:

value1

value2

myValue # after adding

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

I also looked at maven-shade-plugin , but from a few examples on their website I saw only adding 2 files instead of what I need (value to add to one file)

+4
source share
3 answers

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

I shudder every time I have to use Ant in my pom.xml, but in some cases this is the easiest option. Learn to hug him, this will save you some headaches :-)

You may also be able to write your own Maven plugin, but most likely it will be more.

Another option is to create a shell script to add the value, and then call it using the maven-exec-plugin . However, in this case you will have to deal with various operating systems.

+1
source

Codehaus gmaven-plugin is another option for such tasks.

0
source

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

0
source

All Articles