text:  available in the packaged version of your project, so during development the method will fail.
  The approach I’ve taken to fulfil this requirement is to create a text (properties) file in the project resources, and have Maven process this. This allows Maven to inject the version number during compile. The following snippets need to be configured.
  pom.xml
  version=${project.version}
  The version file, such as /src/main/resource/version.prop
  <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.prop</include> </includes> </resource> </resources> </build>
  Java method to extract the version
  public String getAPIVersion() { String path = "/version.prop"; InputStream stream = getClass().getResourceAsStream(path); if (stream == null) return "UNKNOWN"; Properties props = new Properties(); try { props.load(stream); stream.close(); return (String)props.get("version"); } catch (IOException e) { return "UNKNOWN"; } }
  Note, I only filter the files *.prop, because if you have any templates in your log4j.properties file (such as ${catalina.base}) these will also get wiped out.
  Great post. Eliminates the many pages of maven docs one needs to read to get this working.