Just define the default value in the <properties> section of the parent pom...
On 24 September 2014 10:34, JeremieB. <[email protected]> wrote: > Hello, > > I wonder if there is any easy way to do the equivalent of Velocity "quiet > references" with Maven poms ... ? > > Here is my use-case (in a corporate pom): > - I set a property "label" containing some versions and reference to > "${buildNumber}" > - This property "${buildNumber}" is optionally set by the > buildnumber-maven-plugin, ie the plugin is declared or not in the build > depending on projects, ie if they want to use a build number or not > The idea is to provide in a corporate pom a default label naming scheme, > including a build number but only if it is used and defined by inheriting > project. > > Problem is that if buildnumber-maven-plugin is not declared in a project, > the "label" property contains "${buildNumber}" literally, whereas if > undefined I would prefer it to be resolved as an empty string. > In Velocity I would write something like: > ${project.version}-$!{buildNumber} > > If I set a default value to empty string to the buildNumber property, then > the buildnumber-maven-plugin doesn't override this value, so this is not a > solution either. > > I could workaround this by using buildhelper:regex-property to remove the > "${buildNumber}" literal expression if it wasn't resolved, but it seems a > bit convoluted in a corporate pom, and requires proper ordering of plugins > executions so I don't find this very reliable or maintainable. > I kept it though, as all other solutions I could think of, imply more > manual > actions from users, or slow down the build too much... My main objective in > the corporate pom being to be the least obtrusive possible. > > Solutions I thought about: > - run the buildnumber-maven-plugin all the time, and set > "revisionOnScmFailure" to empty string --> slows down all builds for an > optional feature > - add this buildnumber-maven-plugin declaration in a profile, and set > "buildNumber" property to empty string if this profile is not activated --> > complex profiles activation/deactivation requiring CLI switches > > Do you think there's something better that I didn't think about ? > > Thanks, > Jeremie > > > > -- > View this message in context: > http://maven.40175.n5.nabble.com/Use-quiet-reference-notation-for-properties-tp5806363.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
