2
votes

I am using my own version of the Nexus web app repository installed on my local machine. I have Nexus configured with only one repository, the one where I store my snapshots:

http://localhost:8081/nexus/content/repositories/MySnapshots/

Note that after the Nexus installation I removed all the default repositories and added just my own. (Perhaps this was a bad idea?)

When I do a mvn clean install I noticed that some of the 3rd party artifacts are downloading straight from the remote repository. For example, here is one of the output lines from the build:

Downloading: http://repo.maven.apache.org/maven2/com/sun/org/apache/xml/internal/resolver/...

The strange thing is that I see other artifacts are going through my local Nexus to ultimately get to the artifact:

Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/org/apache/maven/wagon/wagon-provider-api...

Notice how the first part of the download url is my local repository but everything after MySnapshots is from apache.org.

It's almost like my Nexus repository is acting like a proxy to maven.apache.org for some artifact downloads but for others it goes straight to the source.

Can anyone tell me why this is happening?

I would't be bothered so much by this if all my builds succeeded all the time but sometimes, when I am compile large projects, I get build failures due to not being able to find an artifact.

For example, when I try to build another project that depends on eclipse jdt stuff I get the following error:

Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/eclipse/jdt/core/eclipse.jdt.core
Could not find artifact eclipse.jdt.core:eclipse.jdt.core

I am not sure if this means that my Nexus is not configured properly or if there really is no artifact eclipse.jdt.com. If the downloads were not going through my local Nexus repository I would then investigate the pom/settings.xml files. Instead this makes me wonder if it's due to my Nexus configuration.

If you would like to see my settings.xml for Maven and my pom file for the project I am building when I see this you can view them here:

settings.xml: http://pastebin.com/NvLr5bEA

pom.xml: http://pastebin.com/PJ0P3RaK

2
what do you mean by large projects here ? - saurav
I am trying to compile the jaxb2 plugin myself. :P That project has like 15 maven modules. - Jan Tacci
can you provide here the complete log while building your module ? External links are not recommended . - saurav
Sorry, I deleted the one project already. :( - Jan Tacci

2 Answers

2
votes

If you like to use the local nexus as a proxy as usual than you have to configure the settings.xml like this:

 <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <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>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

The tricky thing is the mirror thing which reroutes every call to the configured nexus instance. Things you mentioned like eclipse parts can be problematic, cause only a few artifacts are available via maven central. Furthermore you should leave the defaults like maven central, release repository and the snapshots repository unchanged, cause these are the repository you need.

0
votes

I don't think its a proxy issue , upto my understanding for the first case when it is downloading from Maven Central Repo , it might be possible that same artifact is not available in your nexus repository , that's why it is going to Maven Central Repo.

In the second case it is available in your nexus so reactor didn't try to download it from Maven Central Repo.