Java Developer

ot-clean, How to access maven artifact version at runtime?

I wanted to display the version number in help section during application runtime. It turns out that Maven has very interesting feature called resource filtering.

You can add <resources/> fragment into the pom.xml.


It says that maven should look into help.txt file and try to perform replacements (same as in pom.xml). Now we can put ${project.version} directly inside help.txt.

Version - ${project.version}

Below you can see full help.txt file file.

   ___ _____     ___ _    ___   _   _  _
  / _ \_   _|__ / __| |  | __| /_\ | \| |
 | (_) || ||___| (__| |__| _| / _ \| .` |
  \___/ |_|     \___|____|___/_/ \_\_|\_|

          Supported arguments

-d      - By default no directories are going to be deleted. You have to provide
          this argument if you really want to delete them.


Version - ${project.version}
Source  -
Author  - Grzegorz Gajos /
Sponsor - Open Tangerine /

By the way, all other maven variables are accessible also.

The ot-clean series

This blog post is one of the series about the ot-clean. Simple open source tool that maintains your projects directories cleaned from all the garbage. Feel free to look at the source code or readme page for more information. You can also submit pull request or post suggestion. This text participates in open source blogging competition.

Project status

Build Status

All posts from the ot-clean series

Like it? Share it on , , ,

About the author

Grzegorz Gajos, Software Architect with international consulting and programming background. Co-founder of Open Tangerine Software House. Quality evangelist. An experienced entrepreneur, out of the box thinker and problem solver.