How to avoid warning ” ‘version’ contains an expression but should be a constant” in maven for parent?

  Kiến thức lập trình

After readinfg the answer

I modified parent pom.xml and now it looks like this:

(based on https://github.com/apache/guacamole-client/blob/main/pom.xml):

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                        http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.guacamole</groupId>
    <artifactId>guacamole-client</artifactId>
    <packaging>pom</packaging>
    <version>${revison}</version>
    <name>guacamole-client</name>
    <url>http://guacamole.apache.org/</url>
    ...

    <properties>        
        <revison>1.0.0</revison>
         ...
    </properties>
    ...

But I still see warning when I do mvn clean package:

[WARNING] 
[WARNING] Some problems were encountered while building the effective model for tech.inno.guacamole:guacamole:war:1.0.0
[WARNING] 'version' contains an expression but should be a constant. @ tech.inno.guacamole:guacamole-client:${revison}, C:workmy_projectguacamole-clientpom.xml, line 29, column 14
[WARNING]
[WARNING] Some problems were encountered while building the effective model for tech.inno.guacamole:guacamole-client:pom:1.0.0
[WARNING] 'version' contains an expression but should be a constant. @ tech.inno.guacamole:guacamole-client:${revison}, C:workmy_projectguacamole-clientpom.xml, line 29, column 14
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]

maven version is 3.8.1

Is there way to fix it ?

P.S. After I applied the advice from the topic – warnings for child projects are disappeared and I still have warning for parent

LEAVE A COMMENT