In this article I will show how to use SVN revision number as part of the version number of a webapp using the buildnumber-maven-plugin. Using that number makes things a lot easier in case you have to downgrade your application, reproduce a bug in a particular previous version, etc.
Here I will use the version format Major.Minor.SVNRevision. Major is a number manually assigned, Minor is a sequential number that is incremented automatically after every build, and SVNRevision is the revision number obtained from the SVN repository, you can easily modify this format to suit your needs. The whole number is generated by maven in the build process, ie when you execute mvn install on your project.
For this to work first of all you have to configure the scm section in your pom.xml:
<scm>
<connection>scm:svn:https://svnserver/projectname/trunk</connection>
<developerConnection>scm:svn:https://svnserver/projectname/trunk</developerConnection>
<tag>HEAD</tag>
<url>https://svnserver/projectname/trunk</url>
</scm>
Then, you must add the buildnumber plugin to the plugins section inside <build> tag
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>generate-buildnumber</id>
<phase>prepare-package</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<doUpdate>true</doUpdate>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
<useLastCommittedRevision>true</useLastCommittedRevision>
<buildNumberPropertyName>buildRevision</buildNumberPropertyName>
</configuration>
</execution>
<execution>
<id>generate-sequential</id>
<phase>prepare-package</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<buildNumberPropertiesFileLocation>src/main/resources/buildNumber.properties</buildNumberPropertiesFileLocation>
<format>{0,number,1'.'00}</format>
<items>
<item>buildNumber0</item>
</items>
<buildNumberPropertyName>buildSequential</buildNumberPropertyName>
</configuration>
</execution>
</executions>
</plugin>
The plugin has two executions configured.
The first one is responsible for getting the svn revision number from the repository, the create goal is executed upon the prepare-package phase, that phase is reached automatically when you issue a build command on maven (install, package, release); the <buildNumberPropertyName> tag value creates a variable name that hold the revision number, later we'll see how it is used.
The second execution creates the sequential part of the version number, it references the buildNumber.properties file that hold the last number used, which is automatically incremented by 1 after every build. The item tag indicates the name of the variable inside the properties file. The format of the generated number is 1.XX, where XX is the number obtained from the properties file, the plugin uses java.text.MessageFormat to format the number using {0,number,1'.'00} format in this case. Note that we use <buildNumberPropertyName> again to store the sequential number in a new variable.
The first one is responsible for getting the svn revision number from the repository, the create goal is executed upon the prepare-package phase, that phase is reached automatically when you issue a build command on maven (install, package, release); the <buildNumberPropertyName> tag value creates a variable name that hold the revision number, later we'll see how it is used.
The second execution creates the sequential part of the version number, it references the buildNumber.properties file that hold the last number used, which is automatically incremented by 1 after every build. The item tag indicates the name of the variable inside the properties file. The format of the generated number is 1.XX, where XX is the number obtained from the properties file, the plugin uses java.text.MessageFormat to format the number using {0,number,1'.'00} format in this case. Note that we use <buildNumberPropertyName> again to store the sequential number in a new variable.
Using the generated version number
Now that we already have the pom.xml configured to generate the version number, it's time to use it. I'll show you here how to put it in your application's home page but you can reference it elsewhere.
First, I'll declare two variables in the pom.xml that references the two variables created by the buildnumber plugin:
<properties>
...
<webapp.version>${buildSequential}</webapp.version>
<webapp.revision>${buildRevision}</webapp.revision>
</properties>
Then I'll add another plugin to my pom, maven-war-plugin that is responsible for the packaging and generation of the web application archive.
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>index.html</include>
</includes>
</resource>
</webResources>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${buildRevision}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
In the configuration of the plugin I indicate to filter index.html in order to replace variables included there by values computed from this pom. You can find more information about filtering in the plugin's site. I also added a default MANIFEST.MF file indicating the generated revision number as Implementation-Build value. That file is included inside the META-INF folder of the webapp.
Then, inside the index.html you can reference the variables declared earlier in the pom:
<html>
<head>
<title>Webapp's Name ${webapp.version} (Revision: ${webapp.revision})</title>
...
</head>
...
</html>
That's all, when your application is packaged and deployed, you'll see in your home page the title indicating the version number, for example: Webapp's Name 1.23 (Revision: 4567)
Nice Explanation
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGracia!
ReplyDeletesala de datos debida diligencia
Thanks for the best blog. it was very useful for me.keep sharing such ideas in the future as well.
ReplyDeleteembroidery digitizing
Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read.
ReplyDeleteembroidery digitizing
. I am realy very happy to visit your blog. Now I am found which I actually want. I check your blog everyday and try to learn something from your blog. Thank you and waiting for your new post.
ReplyDeleteThis post is Awesome about Embroidery Digitizing
Thanks for sharing.
I am really amazed at the ideal approach to viewing your subject. Where do you collect this information? I want to write great writing like you do. 야설
ReplyDeleteYour article has proven useful to me. It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content. 야설
ReplyDelete
ReplyDeleteEfficiently written information. It will be profitable to anybody who utilizes it, counting me. Keep up the good work. For certain I will review out more posts day in and day out. 국산야동
Thank you for sharing this information. I read your blog and I can't stop my self to read your full blog. Again Thanks and 온라인카지노 Best of luck to your next Blog in future.
ReplyDeleteI will recommend your website to everyone. You have스포츠토토 a very good gloss. Write more high-quality articles. I support you.
ReplyDeleteGreat blog article. Really looking forward to온라인카지노 read more.
ReplyDeleteThe creating on your site is excellent as well as I would love to create it like you. What did you consider composing? Taking a look at your article, I sympathize with you a great deal. Look, individuals sympathize with you a great deal. I wish to leave a message on the internet site like you. That was really considerate. Thanks. 카지노사이트
ReplyDeleteWhat you presented was well researched and well worded in order to get your stand on this across to all your readers 에볼루션카지노
ReplyDeletehiya great weblog! Does strolling a weblog which include this take a incredible deal of work? I've genuinely no understanding in programming but i used to be hoping to start my very own weblog in the close to future. Anyhow, should you've got any ideas or techniques for brand spanking new weblog proprietors please proportion. I recognise this is off subject matter however i just had to ask. Thank you i’m long gone to convey my little brother, that he ought to also visit see this website on everyday foundation to take up to date from newest news update. You certainly make it appear so easy with your presentation however i discover this count to be genuinely some thing which i think i would in no way recognize. It seems too complicated and very large for me. I’m looking forward in your next publish, i’ll attempt to get the grasp of it! 먹튀검증
ReplyDeletemost of whatever you say is astonishingly valid and it makes me contemplate the cause why i hadn’t checked out this with this light before. This specific piece simply did turn the light on for me personally as some distance as this trouble is going. Though there's virtually one issue i'm no longer too cozy with so even as i make the effort to reconcile that with the center topic of your function, permit me have a look at simply what all the rest of the readers have to say. Properly finished. I’m definitely digging the template/subject matter of this weblog. It’s easy, but effective. A number of times it’s very tough to get that “best stability” between usability and appearance. I need to say which you’ve executed a super process with this. Additionally, the blog hundreds very speedy for me on chrome. Exquisite weblog ! Notable work ! This is the kind of records which are alleged to be shared across the net. 메이저사이트
ReplyDeleteYour web site is excellent. I was really touched by this short article. I'm so delighted to locate the write-up I have actually been trying to find for a very long time. I covet the number of individuals sympathize with your writing. You find out a great deal of understanding from my writing. 바카라사이트
ReplyDeletehttps://bayanlarsitesi.com/
ReplyDeleteCihangir
Heybeliada
Yalova
Adana
LQK
Batman
ReplyDeleteArdahan
Adıyaman
Antalya
Giresun
WUVQ
Antalya
ReplyDeleteAntep
Burdur
Sakarya
istanbul
XVQ3
ağrı
ReplyDeletevan
elazığ
adıyaman
bingöl
BXTQC
E658F
ReplyDeleteorder peptides
Eryaman Alkollü Mekanlar
order turinabol
testosterone propionat for sale
Karaman Evden Eve Nakliyat
Konya Evden Eve Nakliyat
masteron for sale
Tekirdağ Fayans Ustası
Maraş Evden Eve Nakliyat
D6F4A
ReplyDeletereferans
C3AD3
ReplyDeletenevşehir sesli mobil sohbet
Çankırı Görüntülü Canlı Sohbet
mobil sohbet chat
konya sohbet uygulamaları
rastgele sohbet
Bartın Mobil Sohbet Sitesi
manisa canlı görüntülü sohbet odaları
balıkesir canlı görüntülü sohbet odaları
chat sohbet
2924B
ReplyDeleteen eski kripto borsası
May 2024 Calendar
paribu
kraken
referans kodu
kraken
January 2024 Calendar
April 2024 Calendar
telegram kripto
9FC53
ReplyDeletewhatsapp ücretli show
8E147
ReplyDeletewhatsapp görüntülü şov
5134BA34D7
ReplyDeletecobra vega
bufalo içecek
lifta
stag
yapay kızlık zarı
fx15
delay
performans arttırıcı
ereksiyon hapı
81F1FA1783
ReplyDeletethemra macun
stag
performans arttırıcı
bufalo çikolata
viga
sinegra
yapay kızlık zarı
geciktirici
telegram show
A5084C2756
ReplyDeleteyapay kızlık zarı
vega
skype şov
görüntülü show
stag
bayan azdırıcı damla
ücretli show
bufalo içecek
cobra vega
6966D4C0BE
ReplyDeletecanli web cam show
telegram görüntülü şov
bayan azdırıcı damla
kaldırıcı hap
ereksiyon hapı
whatsapp görüntülü show güvenilir
ücretli show
yapay kızlık zarı
cam show
8A5FCA71E2
ReplyDeletewhatsapp görüntülü show güvenilir
ücretli şov
viga
vigrande
lifta
whatsapp görüntülü şov
skype şov
yapay kızlık zarı
görüntülü show
BB51FF7848
ReplyDeleteskype show
lady era hap
vigrande
canli cam show
bufalo içecek
degra 100 mg
delay
fx15 zayıflama hapı
stag
FF0280FEB5
ReplyDeleteturk takipci satin al