I’ve got three questions here. First, does pom.xml of maven have any difference from other xml file?
Second, if I would like to rename a file in the same directory as the pom.xml by scripts, can I do it in pom.xml? If possible, then how should I do it?
Last, how can I get the current time in pom.xml?
In fact, what I want to achieve is that I would like to backup the current package(.war) by appending it with the timestamps before I mvn package it. I want the whole process automated by the pom.xml instead of manually processing it.
Hi there,
I find a way to get the timestamp, will it work?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactID>buildnumber-maven-plugin</artifactId>
<execution>
<phrase>package</phrase>
<configuration>
<format>{0, date, yyyy-MM-dd HH:mm:ss}</format>
<items>timestamp</items>
</configuration>
<execution>
</plugin>
will it work? if it works, how can I obtain the timestamp variable? $items or $timestamp?
Thanks
pom.xmlis just another XML file and there is no difference from others. It follows the same XML standards.Now for Question 2 and 3, First of all, when you will run
mvn clean, it will flush off all the files, including thewarfrom the target folder.You can run ANT tasks to rename and backup the current war, but it cannot be executed before clean.
I would suggest you the following approach:
maven-antrun-pluginas a part ofpackagegoal.ANTtarget, rename and backup the current packaged war.Alternatively:
What I would suggest is: In the
WARpom.xml, specify the<version>element with the current timestamp and the desired version. This way, each war would be copied into different directories in the maven local repository.PS: You cannot generate timestamp in maven as per my knowledge. Pass it through some external variable