1

I'm working with a specific environment in which the version of a maven dependency is kept on a file.

e.g.

$ cat version_of_dependency
1.2.3

What I wanted to do is make the project pom.xml automatically read the file and fill the dependency, everytime its build lifecycle is triggered (for example, a simple mvn clean install).

Ideally, I wanted something like:

<dependency>
      <groupId>my_dependency_gid</groupId>
      <artifactId>my_dependency_artifact</artifactId>
      <version>$(cat version_of_dependency)</version>
</dependency>

Is there a way to do something like this? One option would be to have a properties file, but I wanted to keep the format of the version file untouched. Also, we wanted to avoid running a shell script before compiling.

Thanks!

felipeek
  • 1,193
  • 2
  • 10
  • 31
  • To be honest if you don't use the pom to define the versions and the dependencies itself there is something wrong in that environment. – khmarbaise Oct 20 '19 at 14:19

1 Answers1

0

I guess the best you can get is to run a maven goal before to set the version (like in https://stackoverflow.com/a/48913512/927493).

External files (may it be property files or not) cannot be used to define versions inside a POM. So you need to update the POM before you build.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142