1

We've a nexus-server which has the common maven-public repository-group containing every external proxy-repository (e.g. maven-central). Besides that we have a local hosted repository. Let's call it MyProjectRepository. It's splitted in a release-repo and a snapshot-repo.

So, currently it looks like this:

  • MyProjectRepository
  • MyProjectRepository-Snapshots
    • ArtifactOne
      • Snapshot-5
      • ...
      • Snapshot-1
    • ArtifactTwo
      • Snapshot-3
      • ...
      • Snapshot-1

Okay, ArtifactTwo needs ArtifactOne as a dependency. So, I've added this in the dependencies section:

    <dependency>
        <groupId>com.company</groupId>
        <artifactId>artifactone</artifactId>
        <version>0.0.5</version>
    </dependency>

I've configured the repository section like this:

    <repository>
      <id>myprojectrepositoryss</id>
      <name>MyProjectRepository Snapshots</name>
      <url>http://mylocalnexus.com/nexus/repository/MyProjectRepository-Snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>

My settings.xml mirrors-section looks like this:

    <mirror>
       <!--This sends everything else to /public -->
       <id>nexus</id>
       <mirrorOf>external:*, !myprojectrepositoryss</mirrorOf>
       <url>http://mylocalnexus.com/nexus/repository/maven-public/</url>
     </mirror>

My settings.xml profiles-section look like this:

<profile>
  <id>nexus</id>
  <!--Enable snapshots for the built in central repo to direct -->
  <!--all requests to nexus via the mirror -->
  <repositories>
    <repository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>
  </repositories>
 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>

Despite having setup everything like described in the tutorial, my IDE states that the artifact in the given dependency cannot be found.

Failed to execute goal on project ArtifactTwo: Could not resolve dependencies for project com.company:ArtifactTwo:jar:0.0.3-SNAPSHOT: Failure to find com.company:artifactone:jar:0.0.5 in http://mylocalnexus.com/nexus/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced

Why does it search for the dependency in "maven-public"? Does anybody have a clue how to get this to work?

OddDev
  • 3,644
  • 5
  • 30
  • 53

2 Answers2

0

It searches in the maven-public group as desired and configured in the mirror URL in your settings file.

You just need to add your project repositories to the maven-public repository group and it will work just fine.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • How can I specify the following: "If an artifact is not found in the first repository, then continue searching in my other repositories" ? – Sorin Postelnicu Mar 15 '19 at 15:16
  • That happens automatically since the overall repository group will have a merged index. – Manfred Moser Mar 17 '19 at 04:04
  • Yeah, it seems my problem was I accidentally put a mirror with * and apparently this causes the search to be stopped if the artifact is not found in the first mirror. – Sorin Postelnicu Mar 18 '19 at 08:32
0

It is strange, but declaring a repository in <distributionManagement> to deploy the project snapshots or releases to, does not make it by default a repository to download project snapshots or releases from. My solution was to provide an explicit <repositories> section listing my snapshot and release repositories from the <distributionManagement> section.

Please note that the highly cached structure of local and remote repositories and the "habit" of Maven to locally mark an artifact it could not find remotely as not to be attempted during the day, highly complicates the analysis of the situation. Using the -U Maven option really helps to solve it.

Rusi Popov
  • 377
  • 1
  • 6