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

Warning appears when use property from the file in pom.xml version tag. #89

Open
hexwit opened this issue Sep 14, 2022 · 3 comments
Open

Comments

@hexwit
Copy link

hexwit commented Sep 14, 2022

I am trying to use this plugin to read version value from the properties file.
I took a sample from official site:

<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>src/main/resources/version.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

and in pom.xml I use key from the version.properties file like this:

<version>${application.version}</version>

But when I run package goal, I see following output:

[WARNING] 
[WARNING] Some problems were encountered while building the effective model for my.project:server:jar:${application.version}
[WARNING] 'version' contains an expression but should be a constant. @ line 11, column 14
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] -------------------------< my.project:server >--------------------------
[INFO] Building server ${application.version}
[INFO] --------------------------------[ jar ]---------------------------------

I tried different phases, but result always is the same.
Why this warning appears and how to resolve it?

Thanks.

@slawekjaranowski
Copy link
Member

Try revision as placeholder.

https://maven.apache.org/maven-ci-friendly.html

@hexwit
Copy link
Author

hexwit commented Sep 15, 2022

Warning has gone, but I see such message:

[INFO] -------------------------< my.project:server >--------------------------
[INFO] Building server ${revision}
[INFO] --------------------------------[ jar ]---------------------------------

Here version still is not substituted for some reason.

But final artifact contains version number as expected.

@slawekjaranowski
Copy link
Member

Pleass look at #115

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