0

I have a regular Maven project. I would like to set certain properties/variables in the JAR when building using mvn package, so that certain information can be picked up from individual JAR files.

For example, I could use:

mvn package -DbuildId=200

... and I would like to see this information stored (buildId = 200) stored in some file generated by maven. I know for a fact that certain properties are stored by Maven at build-time (for example, the files in META-INF/maven).

Is this possible without modification of the POM file, and without adding extra plugins? If so, what arguments do I need to pass?

Momo
  • 3,542
  • 4
  • 21
  • 34
  • Without modifying any POM file, how do you intend Maven to know there is a `buildId` system property to read and written somewhere? – Tunaki Jan 29 '17 at 21:53
  • @Tunaki I was thinking of just setting some variable in a file when building. That information could be used by some 3rd-party application that reads it. – Momo Jan 29 '17 at 21:55
  • But why would you expect Maven to even know there is a variable to write somewhere? You need to modify your build to take it into account. – Tunaki Jan 29 '17 at 21:56
  • @Tunaki Hmm yeah, I get your point. What I am suggesting is to (kinda) add values while building the application, in the command line. The example I gave (-DbuildId) does not and is not expected to work. – Momo Jan 29 '17 at 21:59
  • http://stackoverflow.com/questions/13876165/how-to-override-maven-property-in-command-line – Antoniossss Jan 29 '17 at 22:32
  • Possible duplicate of [How to override maven property in command line?](http://stackoverflow.com/questions/13876165/how-to-override-maven-property-in-command-line) – Antoniossss Jan 29 '17 at 22:32

0 Answers0