Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is simple way to fail a build when a property is not set?

Tags:

maven-2

As stated in the title, how can I modify - in the simplest manner possible - a pom.xml in order to make it fails if a property is not set in the command line.

For example, mvn clean package will fail, when mvn clean package -Dfoo=bar will succeed.

I'm looking for something like the <prerequisites/> tag in the pom.xml (except that <prerequisites/> only allow me to check the Maven version)...

like image 794
Romain Linsolas Avatar asked Sep 09 '09 08:09

Romain Linsolas


People also ask

What is Maven profiles used for?

Maven profiles can be used to create customized build configurations, like targeting a level of test granularity or a specific deployment environment. In this tutorial, we'll learn how to work with Maven profiles.


1 Answers

You can use the requireProperty goal of the maven-enforcer-plugin to fail a build if a property is missing.

Note this only requires that the property is set, so it could have been set in the pom's properties section.

like image 161
Rich Seller Avatar answered Oct 04 '22 20:10

Rich Seller