Home > Net >  Error throwing while substituting variable for version in pom.xml
Error throwing while substituting variable for version in pom.xml

Time:12-03

I am getting an error while am substituting variables for the versions in the parent block in the pom.xml file.

For the properties tab, it's working fine, but when am changing the version to a variable that is being exported before 'mvn clean install' in the parent block, the build is getting failed.

The error is shown below.

"Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:${env.SPRINGBOOTVERSION} from/to abc-repos (https://continuousintegration.abc.com/artifactory/abc-repos): Illegal character in path at index 122: https://continuousintegration.abc.com/artifactory/abc-repos/org/springframework/boot/spring-boot-starter-parent/${env.SPRINGBOOTVERSION}/spring-boot-starter-parent-${env.SPRINGBOOTVERSION}.pom"

Here the variables are not replaced for parent pom before the pom.xml gets resolved.


Below is the code block of pom.xml which was substituted.

<parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>${env.SPRINGBOOTVERSION}</version> ---------> replaced version by variable
        <relativePath />
    </parent>

The maven version here is 3.0.5

Any solution to this will be helpful.

CodePudding user response:

To clarify, you are setting the value for the substitution variable:

SPRINGBOOTVERSION

In your environment somehow, I.e. as an environment variable in the shell that runs your command, and it’s not working?

CodePudding user response:

IMO, maven will never ever support the behaviour you desire, the reason for that is when you are doing mvn install or mvn clean maven deploys artifacts along with pom files into local or remote repository, but the information about your build environment (i.e. ${env.SPRINGBOOTVERSION}) is stored nowhere, so, it is not a bug or lack of feature - maven just prevents storing invalid pom files in maven repository.

  • Related