19

For some reason I can't get Nexus to serve my SNAPSHOT artifacts via the default public group. I've read the relevant bit of the Nexus manual and search Google, but nothing I do seems to work.

I've implemented the stuff in section 4.2. (Configuring Maven to Use a Single Nexus Group) of the manual, so my settings.xml looks like:

<settings>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://my-server/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <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>

</settings>

Everything was working fine until I started building stuff on a clean machine (i.e. one I hadn't built any of the SNAPSHOT projects on) and it wouldn't down load the required SNAPSHOT dependencies. Maven gives me the following:

[INFO] Scanning for projects...
[INFO]       
[INFO] ------------------------------------------------------------------------
[INFO] Building MyCo Actions Base Classes 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.pom
[WARNING] The POM for com.myco:testing:jar:1.0.0-SNAPSHOT is missing, no dependency information available
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023s
[INFO] Finished at: Tue Mar 08 15:55:23 GMT 2011
[INFO] Final Memory: 99M/480M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project actions-base: Could not resolve dependencies for project com.myco:actions-base:jar:1.0.0-SNAPSHOT: Could not find artifact com.myco:testing:jar:1.0.0-SNAPSHOT in nexus (http://my-sever/nexus/content/groups/public) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

The problem being that testing-1.0.0-SNAPSHOT.jar doesn't exist, but testing-1.0.0-20110301.182820-1.jar does. How do I get Nexus to resolve the SNAPSHOT properly and serve me my JAR...?

Cœur
  • 37,241
  • 25
  • 195
  • 267
fatboab
  • 413
  • 1
  • 5
  • 12

4 Answers4

11

I ended up getting it all working my removing the local releases and snapshot repositories from the public group and making the mirror, only mirror the public group rather than everything. So my settings.xml ended up containing:

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>maven-releases</id>
          <url>http://myhost.com/nexus/content/repositories/releases</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>maven-snapshots</id>
          <url>http://myhost.com/nexus/content/repositories/snapshots</url>
          <layout>default</layout>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>        
        <repository>
          <id>madeUp</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>madeUp</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>madeUp</mirrorOf>
      <url>http://myhost.com/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
fatboab
  • 413
  • 1
  • 5
  • 12
8

Same problem for me while configure nexus to work as a mirror. After adding all repositories (release & snapshots) to the Public Repository group, you can find all snapshots by browsing the corresponding URL:

Configure nexus Browser public group

But maven will fail anyway to get the snapshots from the mirror, as described in this thread. It seams that maven does not retrieve snapshots from the mirror, until you explicitly told it to do so. As a solution, I added the same URL as a repository-Tag and it just works as expected:

<settings>

<mirrors>
    <mirror>
        <id>nexus-mirror</id>
        <name>Nexus Mirror</name>
        <url>http://my-server/nexus/content/groups/public/</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>nexus-public</id>
                <name>Nexus Public Repository</name>
                <url>http://my-server/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

</settings>

Even setting the updatePolicy-Tag to the whole mirror does not make any trouble. Since maven is clever enough to only update the snapshots in every build, but not the releases.

Adam Taras
  • 1,403
  • 1
  • 13
  • 15
  • We had trouble when trying to build the app in Jenkins. So we have to create a customized settings.xml file with these lines: true always then put this file in Jenkins, config build ->advanced->Settings file->Settings file in filesystem->File path. – Janet May 15 '18 at 17:06
1

I tried this too and it failed. There is a second description of the problem here. It may be that the Nexus public repo is interfering with things.

I ended up adding a second repository in settings.xml pointing to our local snapshot repository more directly.

<repository>
   <id>ummsSnaps</id>
      <url>https://team/nexus/content/repositories/snapshots</url>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
</repository>

And it worked.

Peter
  • 11
  • 1
0

Check that your snapshot repository is added to your public group. It looks like you've got the settings.xml configured correctly so it must just be that /public doesn't contain your snapshot repo.

Brian Fox
  • 6,782
  • 4
  • 27
  • 31
  • 1
    The snapshot repo was added to the public group, it's there by default if I remember correctly. – fatboab Jul 01 '11 at 14:40
  • 3
    I have the same problem. Exactly the same settings.xml + Public group contains those repositories in a sequence: Releases Snapshots 3dParty Central. Using OSS 2.6.3-01. While browsing Public via UI I can see all artifacts there but maven cannot download those. Is that a bug or expected behaviour? I thought that is the function of group repository – jaksky Oct 15 '13 at 12:27