Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven not able to inherit repository

My project is structured like this.

Artifact A
|- depends on hadoop-client.jar
|- cloudera repository is added to pom

pom.xml

 <repository>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
    <releases>
        <updatePolicy>always</updatePolicy>
    </releases>
    <id>central</id>
    <name>libs-release</name>
    <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
</repository>

Now, A compiles fine, has been packaged as jar and pushed to artifactory (jfrog one)

Artifact B
|- depends on A
|- doesn't have cloudera repo in pom

pom.xml

<dependency>
    <groupId>groupId</groupId>
    <artifactId>artifact_a</artifactId>
 </dependency>

Artifact B is not able to use repo which was added in A and gives error on compilation.

"Could not find artifact org.apache.hadoop:hadoop-client:jar:2.0.0-cdh4.2.0"

Am i missing anything ? Don't want to add cloudera repo in pom of Artifact B.

like image 264
Mohit Verma Avatar asked Oct 15 '25 04:10

Mohit Verma


1 Answers

Maven does only inherit repository information from parent POMs, but not from dependencies. You can create a third POM C which declares the repository and from which A and B inherit - that will work.

Fell into the same pit a while back… ;)

like image 116
rec Avatar answered Oct 17 '25 21:10

rec