1

We are trying to group maven dependencies inside a seperate maven POM-typed project.

We would like to use this as both a POM-type dependency inside the dependencies node aswell as a BOM (Bill of Materials) inside the de dependencyManagement.

We have an 2 repository inside the company. (Apache Archiva - 2.2.0). One of them is for Snapshots and one of them for releases.

When I try to use the snapshot version, everything works fine, but when i want to use the released version, i keep getting an error because it keeps looking for the dependency inside the central maven repository (where our pom is not located)

To me it seems like the POM-dependency is being searched inside the snapshot repository only.

<properties>
    ...
    <dependency.bla-slf4j-logback-BOM.version>1.0.1</dependency.bla-slf4j-logback-BOM.version>
    ...
</properties>
<dependencies>
    ...
    <dependency>
        <groupId>my.groupid</groupId>
        <artifactId>bla-slf4j-logback-BOM</artifactId>
        <version>${dependency.bla-slf4j-logback-BOM.version}</version>
        <type>pom</type>
    </dependency>
    ...
</dependencies>
<dependencyManagement>
    <dependencies>
        ...
        <dependency>
            <groupId>my.groupid</groupId>
            <artifactId>bla-slf4j-logback-BOM</artifactId>
            <version>${dependency.bla-slf4j-logback-BOM.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        ...
    </dependencies>
</dependencyManagement>

errormessage:

[ERROR]     Non-resolvable import POM: Failure to find my.groupid:bla-slf4j-logback-BOM:pom:1.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 234, column 22 -> [Help 2]

used command:

mvn dependency:tree
  • maven version: Apache Maven 3.2.2
  • archiva version: Apache Archiva - 2.2.0

I checked our archiva, the artifact is present at the expected location. I also checked the local maven directory, the pom dependency was downloaded correctly.

Any ideas why this doesn't work for a released version of our POM-project (1.0.1), but does work for a Snapshot version (1.0.1-SNAPSHOT) of our POM-project.

stefaan dutry
  • 1,096
  • 1
  • 10
  • 21
  • do you have element in your section ? – Hisham Khalil May 12 '16 at 14:17
  • the and element are configured in the settings.xml file. I've tried putting it inside the project's pom aswell, but this yields the same result. This configuration has no problem getting any other dependencies that are located in our internal archiva repository. (This is the first time we're trying to use an import of a POM (from our maven repository) in the dependencyManagement section though) – stefaan dutry May 13 '16 at 06:48
  • try to mirror the default "central" maven repo in your setting.xml: UK UK Central http://yourrepo.com/maven central – Hisham Khalil May 13 '16 at 07:20
  • This seems to have worked. If I understand it correctly, then this means that for import-related dependencyManagement entries, it will always contact the central repository. Given that our repository has a proxy towards the actual central maven repository, i don't think this will ever give any problems. Can someone confirm this? – stefaan dutry May 13 '16 at 08:31
  • yes this is the way to go to get your dependencies resolved "proxying the maven central repo" – Hisham Khalil May 13 '16 at 09:26

1 Answers1

1

The solution was to add the following block of xml to the maven settings.xml file.

<mirrors>
    <mirror>
        <id>ourcentral</id> 
        <name>our central</name>
        <url>http://mavenrepourl.goes.here</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>

This causes it to check our internal maven repository as the central maven repository. (our maven repository has the default central repository as remote repository)

Special thanks to: Hisham kh

stefaan dutry
  • 1,096
  • 1
  • 10
  • 21