Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanding default values #116

Open
KyRobbins opened this issue Dec 4, 2023 · 3 comments
Open

Expanding default values #116

KyRobbins opened this issue Dec 4, 2023 · 3 comments

Comments

@KyRobbins
Copy link

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?

@KyRobbins
Copy link
Author

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

@slawekjaranowski
Copy link
Member

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.

@KyRobbins
Copy link
Author

Added #118 to add a test to expose the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants