properties-maven-plugin icon indicating copy to clipboard operation
properties-maven-plugin copied to clipboard

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

Open hexwit opened this issue 2 years ago • 3 comments

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.

hexwit avatar Sep 14 '22 16:09 hexwit

Try revision as placeholder.

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

slawekjaranowski avatar Sep 14 '22 17:09 slawekjaranowski

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.

hexwit avatar Sep 15 '22 12:09 hexwit

Pleass look at #115

slawekjaranowski avatar Oct 22 '23 16:10 slawekjaranowski