I want to display the build version and build date on the footer of a JSF application. The pages are XHTML. I'm looking for ways to get the information from pom.xml or other artifacts.
I found the following that uses maven-replace plugin. http://www.vineetmanohar.com/2010/09/how-to-display-maven-project-version-in-your-webapp/
Are there any other techniques you use?
I'm looking for something like this with JSF - Displaying the build date
One approach that will work: use Maven filtering to put a file in your WAR or JAR containing the required information. Then in your Java webapp, load that file's contents as a ClassPath resource
InputStream
.Create a file (let's say "buildInfo.properties") under
src/main/resources
containing something like:Note that due to an open defect, you need to define the
timestamp
property as follows in the<properties>
block of your pom:During your build, this file will be filtered with the value of project.version (which you define with
<version>
in your pom.xml, when you specifyIn your Java code (JSF bean, whatever), have code like the following:
If your framework supports loading properties as "Resource Bundles" from the classpath (i.e. like in Spring), no need for the preceding Java code that loads the properties file.