properties-maven-plugin
properties-maven-plugin copied to clipboard
Expanding default values
Not sure if I'm doing something obviously wrong, but noticing odd behavior where nested placeholders aren't being properly parsed.
Setting up the simple example:
local.properties
defined.value=myValue
some.value=${defined.value:${user.home}}
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>read-properties</id>
<phase>pre-clean</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<useDefaultValues>true</useDefaultValues>
<files>
<file>${project.basedir}/local.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</build>
${some.value}
is resolving as myValue}
(Note the unwanted }
).
Looking at the logic in https://github.com/mojohaus/properties-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/properties/DefaultValuesAwareExpansionBufferImpl.java#L32-L43 (and related logic in https://github.com/mojohaus/properties-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/properties/ExpansionBuffer.java#L60-L81)
It doesn't seem, offhand, that nested placeholders are being properly accounted for, or am I making a silly mistake?
Any thoughts on this? I can work on a change if it's appropriate, I just wanted to check if I'm using it incorrectly first, since the documentation seems to indicate that the above use case should be valid. https://www.mojohaus.org/properties-maven-plugin/#:~:text=localhost%7D%3A%24%7Bport%3A8080%7D-,%24%7Bunknown%3A%24%7Bfallback%7D%7D,-fallback%20value
Your example looks ok.
You can try to add a Unit Test into: src/test/java/org/codehaus/mojo/properties/PropertyResolverTest.java with your case.
Looks like a bug.
Added #118 to add a test to expose the issue.