artifact version in the dependency-reduced-pom generated by maven-shade-plugin

I have a maven project using the maven-shade-plugin. The project’s pom.xml defined the project version as

    <groupId>com.company</groupId>
    <artifactId>server</artifactId>
    <packaging>jar</packaging>
    <version>${revision}</version>
    <name>Server</name>
    <url>http://maven.apache.org</url>
    <properties>
        <revision>3.0.1-SNAPSHOT</revision>
    </properties>

When we run the maven build, we pass in the revision

mvn -B -Drevision=${{ env.ARTIFACT_VERSION }}-${{ github.run_number }} install verify deploy

The problem is when maven-shade-plugin generated the dependency-reduced-pom.xml, it is not reading the -Drevision=… from the system parameter. The dependency-reduced-pom.xml has

 <version>${revision}</version>

Any suggestions to fix this issue? Thanks.

  • First why using install verify deploy. Using deploy is sufficient. Furthermore have you configured the flatten-maven-plugin in your pom file? (maven.apache.org/maven-ci-friendly.html) Ah which Maven version do you use?

    – 




  • @khmarbaise, thanks. It is a single project setup, it does not use the flatten-maven-plugin. The maven version is 3.6.2. I was wrong, the version in the generated dependency-reduced-pom.xml is “${revision}”. It doesn’t replace it with the default revision value defined in the pom.xml. I will update my original post.

    – 

  • You have to use the flatten-maven-plugin (check referenced documentation) otherwise the replace will not being done correctly as you already stated. Also I recommend to upgrade your Maven version to most recent one (3.9.6 maven.apache.org/download.cgi)

    – 

Leave a Comment