Maven 2 & 3

Fail the build with a nice error message if a property to be interpolated in pom.xml is not defined

Details

  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

There are uses cases with pom.xml requiring an environment-specific property to be defined. If those property are not provided by the user in a settings.xm, profiles.xml or a command-line system property then m2 should fail the build with a nice error explaiing the reason.

Activity

Hide
Brett Porter added a comment -

This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the timing of executing the interpolation (I don't think the profiles are all resolved, so you may rely on a property that is only needed for a profile which is not acceptable)

Show
Brett Porter added a comment - This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the timing of executing the interpolation (I don't think the profiles are all resolved, so you may rely on a property that is only needed for a profile which is not acceptable)
Hide
Jerome Lacoste added a comment -

Is it always possible to know if a property is to be resolved?

In CruiseControl we've found out that some plugins were using a String which looked like a property. To CC it looked like a property and CC was failing because it couldn't resolve it. There was no way to find out whether the property was in fact a property or not.

We now just warn the user instead of failing.

Show
Jerome Lacoste added a comment - Is it always possible to know if a property is to be resolved? In CruiseControl we've found out that some plugins were using a String which looked like a property. To CC it looked like a property and CC was failing because it couldn't resolve it. There was no way to find out whether the property was in fact a property or not. We now just warn the user instead of failing.
Hide
Vincent Massol added a comment -

Here's a rule to know what is a property:

if there's an expression containing ${...} then it means it's a property isn't it?. What are the cases where you think this is non-deterministic?

If there's a case wich is ambiguous then we could simply add some markup in the pom to tell what are required properties that must be defined by the user. Maven would check thoses.

Show
Vincent Massol added a comment - Here's a rule to know what is a property: if there's an expression containing ${...} then it means it's a property isn't it?. What are the cases where you think this is non-deterministic? If there's a case wich is ambiguous then we could simply add some markup in the pom to tell what are required properties that must be defined by the user. Maven would check thoses.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: