I wish to move my Maven repos from Archiva to the NXRM3 I use for npm. I have created a blob store for the new Maven Repo and have created the Maven repo. I modified my
~/.m2/settings.xml to use the new repo according to the example from
https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/maven-repositories, as well as modifying my
pom.xml. But when I enter
mvn deploy -DskipTests in a terminal, I get
Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ftp:3.5.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ftp:jar:3.5.2, org.codehaus.plexus:plexus-utils:jar:1.1: org.apache.maven.wagon:wagon-ftp:jar:3.5.2 was not found in http://10.1.2.2:9001/repository/my-mvn-repo/ during a previous attempt.
This works fine with Archiva, and the “missing” jars are in
~/.m2/repository. What’s wrong?
Is your maven repository a proxy?
You’d really want to look at the requests on the Nexus side.
My Maven repository type is hosted. The blob store is in the same directory as my npm blobs and uses the same permissions.
How? What am I to see? I marked the _Log Viewer and tried a Maven command but I see nothing the appears to relate to that, only two lines (later) about
- Task 'Storage facet cleanup'.
I tried uploading the jars & poms I downloaded from Maven Central. I still got
Unresolveable build extension though I could see them in the repo.
I removed the
<extentions> element (used to FTP to Archiva) from my
pom.xml and added
nexus-staging-maven-plugin from Deployment with the Nexus Staging Maven Plugin. Still no luck:
Unresolveable build extension: Plugin org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.sonatype.plugins:nexus-staging-maven-plugin:jar:1.6.13, org.codehaus.plexus:plexus-utils:jar:1.1: Could not find artifact org.sonatype.plugins:nexus-staging-maven-plugin:jar:1.6.13...
~/.m2/settings etc. are copied from Configuring Apache Maven except for id, password, etc and using an IP vs localhost.
There is a request.log file in the /nexus3/log folder that you can use to see the incoming requests (and what response code is returned).
10.1.2.2 - - [25/Oct/2022:15:49:17 -0400] "GET /repository/my-mvn-repo/org/sonatype/plugins/nexus-staging-maven-plugin/1.6.13/nexus-staging-maven-plugin-1.6.13.pom HTTP/1.1" 404 - 1967 10 "Apache-Maven/3.8.6 (Java 1.8.0_265; Mac OS X 10.15.7)" [qtp334146290-672]
10.1.2.2 - - [25/Oct/2022:15:49:17 -0400] "HEAD /repository/my-mvn-repo/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar HTTP/1.1" 404 - 1932 5 "Apache-Maven/3.8.6 (Java 1.8.0_265; Mac OS X 10.15.7)" [qtp334146290-659]
10.1.2.2 - - [25/Oct/2022:15:49:17 -0400] "GET /repository/my-mvn-repo/org/sonatype/plugins/nexus-staging-maven-plugin/1.6.13/nexus-staging-maven-plugin-1.6.13.jar HTTP/1.1" 404 - 1967 7 "Apache-Maven/3.8.6 (Java 1.8.0_265; Mac OS X 10.15.7)" [qtp334146290-675]
Why are these being looked for in my repo vs the maven-central proxy that NXRM3 comes configured with? Is there something I need to add/change to the
settings.xml show in the docs?
Check your settings.xml as well as your pom.xml - one of those is likely configured to hit the my-mvn-repo repository instead.
So how do I configure settings.xml and a pom.xml so that maven-central libraries come from there, yet I deploy and download in-house libraries to our in-house NXRM3? And keep their blobs separate–as I do with npm–so that when I back up, I back up only our libraries, not all the copies in the proxy?
Obviously I’m not getting this. Setting up npm was simple; Maven has been frustrating.
So if I change “my-mvn-repo” to “maven-central” I can run
mvn package on a module with only maven-central dependencies (it’s fast!). What do I need to do so that I can publish this module to my-mvn-repo and my other modules can find it there as a dependency?
I think I’m close: I add a
settings.xml for “my-mvn-repo” and a profile. In my
pom.xml I add this server, with it’s NXRM3 URL to
distributionManagement/repository. I give that
nexus-staging-maven-plugin. But I’m getting a 404 when I run
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy (injected-nexus-deploy) on project my-utils: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy failed: Nexus connection problem to URL [http://10.1.2.2:9001/repository/my-mvn-repo/ ]: 404 - Not Found -> [Help 1]
The way I would normally suggest doing this is to have three repositories on your Nexus Repository Manager instance. One would be a maven-central proxy, one a hosted repository containing your in-house libraries, and a group repository with both the proxy and hosted repositories as it’s children. Then you configure your development machines to use the group repository for all dependencies and let Nexus Repository Manager figure out where to fetch them from. This gives you a way to track what dependencies your projects are pulling in and a central location to block things (some of our other paid tooling can help automate this sort of thing).
You can keep the proxy using a different blob store if you like, but see Keeping Disk Usage Low for suggestions on how to keep its disk-space low.
Also, for deployment of your private libraries, you’ll configure the pom.xml to deploy to the hosted repository. It will need to be different to the group repository you normally download from as you won’t be able to deploy to the group.
At the moment I’m not deploying anywhere. See my edited post above about the 404. (I can deploy to a file, but I need it in Nexus.)
I don’t understand “It will need to be different to the group repository you normally download from…” I have a project with multiple modules. I deploy
my-util as part of this package, and it’s a dependency to other modules and other projects. How does that work if groupId is different. In Archiva I routinely deploy to and read from the same in-house private repo.
You can certainly deploy and read from a hosted repository. However there are a bunch of advantages to making your repository manager provide both the hosted and the proxy dependencies to the developer. See the section on component repositories at Administration Best Practices
nexus-staging-maven-plugin and have gone with the Maven deploy plugin. We’ve less than a dozen jars to manage and zero staging, so this suits our requirements. Thank you for your help straightening me out on mirror vs internal.
If you want to using staging for nexus repository manager 3 you’ll want the nxrm3-maven-plugin. Keep in mind that staging is a paid feature (part of Nexus Professional).