0

The main pom file receives the version value as a maven command-line argument.

What I want to achieve is to prevent the build from executing if the argument is either non-existing in the command (not passed), or if it has empty string value, something like -DbuildVersion= or -DbuildVersion="".

The reason is that the generated JARs should not end up without the version number, or worse - with the dummy value set in the buildVersion property.

================= Solution: For anyone having the similar need - use Maven Enforcer Plugin. http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html

developer10
  • 1,450
  • 2
  • 15
  • 31
  • Usually each pom file has a version like `1.0.0-SNAPSHOT` which will result in the appropriate artifacts...So I don't see the problem?Why do you need the `buildVersion`? How could you produce artifacts without a version number? Can you show your pom file which makes this possible? – khmarbaise Apr 30 '17 at 13:32

1 Answers1

1

I was going to suggest the Maven Enforcer plugin (http://maven.apache.org/enforcer/maven-enforcer-plugin/), but it seems that it's not possible yet -> Run Maven Enforcer Plugin rule on command line. Wouldn't be fine for you to wrap the build process in a scrip that would make that validation for you?

Community
  • 1
  • 1
rjsperes
  • 65
  • 1
  • 8
  • Actually, I've already stumbled upon the Maven Enforcer Plugin and it indeed worked. The link you provided seems obsolete now. – developer10 Apr 28 '17 at 16:48