简体   繁体   中英

unable to resolve Maven dependency placeholder reference value

my project has dependencies on some framework jars:

<groupId>my-compamy</groupId>     
<artifactId>my-project</artifactId>         
<version>1.0</version>    
<dependency> 
    <groupId>my-company</groupId> 
    <artifactId>child-jar1</artifactId> 
    <version>2.0</version>
</dependency> 

recently the framework team changed their packaging, in the repository, they put a parent pom (used to be separated child jars) like this:

<properties> 
    <reivison>2.0</revision> 
</properties>

<groupId>my-company</groupId>
<artifactId>framework-parent</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>

<modules>
    <module>child-jar1</module>
</modules> 

in the child-jar1 pom:

<parent>
    <artifactId>framework-parent</artifactId>
    <groupId>my-company</groupId>
    <version>${revision}</version>  <!-- can find the value! -->
</parent> 

<artifactId>child-jar1</artifactId>
<packaging>jar</packaging>

When I build my-project, I got error message like:

... Failed to collect dependencies at my-company:child-jar1:jar:2.0.

... cuased by: could not find framework-parent:pom ${revision}

and the child-jars are not downloaded.

it looks that it is the placeholder in the child pom caused the problem: my-project could not resolve the placeholder value in the dependent(chiild-jar1)'s pom. tried multiple approaches to resolve the referenced value from my-project side but nothing worked. Can this be resolved from my-project side without altering any dependency framework's setting? Please help.

There is a way to replace the palceholder with concrete value: add flatten-maven-plugin in the framework parent pom file build section (first to run) - this does not impact the framework's functionality but has to be done in the framework side. I gave this suggestion to the framework owner and they took it. It works.

Thanks to all comment providers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM