Mystery maven property '${...}' in assembly

Viewed 578

EDITED

I encountered a strange parameter when using the <filtered>true</filtered> feature of maven-assembly-plugin.

In:

some unfiltered text
foo expands to '${params.foo}'
bar expands to '${params.bar}'
"..." expands to '${...}'

Out:

some unfiltered text
foo expands to 'FOO'
bar expands to 'BAR'
"..." expands to 'MavenProject: net.jsharp:assembly-example:1 @ /path/to/my/code/pom.xml'

params.foo and params.bar are defined in my pom.xml. ... is not. I can't find any settings.xml that could be defining it, so it would appear to be coming either from the super pom or some peculiarity of how filtered parameter expansion works, but I can't work out what it is. No sign in mvn help:effective-pom

What is this mysterious ${...} variable?

Reproducible example here: https://gist.github.com/jpassaro/0892106beca2a066fae21320be41dcbf

ORIGINAL QUESTION (and context)

In some shell scripts I have to interpolate maven properties. I do this as follows:

# '${...}' vars should be understood as being populated by maven
foo='${project.foo}'
bar='${project.bar}'

Greatly to my surprise, when it is run through the assembler, the following shows up:

# 'MavenProject: <group-id>:<artifact-id>:<version> @ <path-to-project>/dependency-reduced-pom.xml' vars should be understood as being populated by maven
foo='FOO'
bar='BAR'

What is this mysterious ${...} variable?

(maven 3.5.4, OSX, java 1.8)

2 Answers

The value of property ${...} resolves to MavenProject.toString(). The same happens with ${..} and ${....}, but not with ${.}.

The resolution of this property happens inside ReflectionValueExtractor. This class is actually responsible to resolve values by transforming properties like ${project.build.outputDirectory} to method chains like project.getBuild().getOutputDirectory(). It seems the class can't handle properties with anything between two dots and returns project instead.

The property ${...} and its resolution seems to be undocumented behaviour since it is documented neither in the POM Reference nor in the Complete Reference.

Those variables or properties are indeed coming from maven. They are either defined in the pom.xml or in the active profile you use (see your settings.xml, most likely in your user's home folder)

Related