How can I get Nexus to grab artifact files in proxy repositories? - maven

My setup is that I have a local Maven repository on my machine, and one on my team's machine that's managed by Nexus. I added a new proxy repository to Nexus. When I select this new proxy repository and hit "Browse Remote", I see everything (all the JARs, POM files, etc.) in the repository, as it should be. But when I click "Browse Storage", I see almost nothing ... only a handful of POM files, and none of the JAR files.
My Maven build is failing, presumably because it can't get the JAR files from Nexus (the JARs don't appear in my local repository, either, but the POMs do). The other virtual repositories on my Nexus all have the JAR files in storage and in my local repository; how can I get Nexus to grab the JAR artifacts from the remote repository?
I'm sure this is something basic, but I've searched and didn't come up with anything I can use. Thank you!

Enable remote repository index download, add the repository to the public group, make sure that Maven hits Nexus and most importantly read the free book about Nexus.
Here is the chapter about configuring Maven to work with Nexus.
Oh and for proxy repositories it will only download remote artifacts if they are needed e.g. by a Maven build accessing Nexus..

I just ran into this issue as well and thought it might help to have another answer.
I have my repository location at: http://serverName.company.com/nexus-2.3 and I copied/pasted that URL into my settings.xml file. That nexus server points to another company's nexus server so that we only have to point to one to pull down our stuff as well as theirs. Unfortunately, I wasn't able to do that.
That is, until I found out that you have to use the following URL instead of the one above:
http://serverName.company.com/nexus-2.3/content/groups/public/
The snippet of my settings.xml looks like:
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://serverName.company.com/nexus-2.3/content/groups/public/</url>
</mirror>
I spent far too long figuring this out. I hope this helps someone in the future.

Related

Replicate nexus repository in my local server

I work in an organisation and we use nexus repositories. I want a simple approach of how can I replicate few groups from nexus repository in to local server so that maven downloads the dependencies from local server and not from nexus.
If you use local server in the sense of base machine then you use clean install as a maven goal. The build code will be available under .m2/repository folder.
Install Nexus locally, create Proxy Repository for each of the repo or group that you want to have locally. In Proxy Repository you'd need to set up URLs to the remote repos.
Now point Maven to this local Nexus (e.g. with <mirrors> in settings.xml). First time Maven downloads a dependency it will go to Local Nexus which would grab the dependency from the remote one. This file is going to be cached in Local Nexus and further downloads won't hit the Remote Nexus.
PS: don't know why you would do this.

archetype-catalog of jcenter.bintray.com to old when proxing it with Sonatype Nexus

I have problems to reach some artefacts from jcenter/bintray over Sonatype Nexus.
I created a maven2 Nexus configuration which points to http://jcenter.bintray.com (remote storage location). I set "Download Remote Index" to true.
Nevertheless /nexus/content/repositories/com.bintray.jcenter/archetype-catalog.xml did not contain my desired artefact. The catalog itself is not empty.
Browsing jcenter.bintray.com/com/moowork/gradle/gradle-grunt-plugin/0.4/ reveals the artefact.
Any idea, any help?
Creating a proxy in Nexus with the following url works for me:
http://dl.bintray.com/srs/maven/.
At that url there are no maven catalog files, but you can navigate through the artifact structure. Nexus works on repos without catalog, too.
It looks like you have to point Nexus to the project specific repository, and not to the root url.

How to use Sonatype Nexus Repository Groups with Github raw repositories?

How can I tell Nexus to download the artifacts from a raw github maven repository when the Proxy Repository in Nexus is in a Repository Group?
Background: In our parent-pom we use a catch all mirror, so we don't have to configure each and every repository to the poms. This works flawless and is also common practice - example:
<mirrors>
<mirror>
<id>provided</id>
<url>http://nexus.host/content/groups/provided</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
But when using a raw github repository this dosn't works. How can I configure Nexus to do this?
Note: I already read "How to add Github raw repositories to Sonatype Nexus as Proxy repository?", but this doesn't tells you how it would run with Repository Groups.
Update: In a manual post step I created the nexus index files with the nexus-indexer-3.0.4-cli.jar, and commited/pushed them to github. Now nexus shows me in the "Browse Index" tab the files in the Proxy Repository, but the problem remains. Clients can not download the artifacts from Nexus.
After creating the proxy repository, you have to add it to the group through which you are accessing Nexus in your build tool. In your case it seems that group uses the id "provided" as visible from the url in the mirror.
See more about adding to repository groups in the Nexus book here and here

maven repositories

I'm new to maven. I'm still failing to grasp the concept of it.
For example I'm looking for com.extjs:gxt:jar:2.2.5 or org.syslog4j:syslog4j:jar:0.9.46. I can't find them in any repo. Yet they seem fairly common packages.
Does that mean I have to download them by hand ? Doesn't it defeat the whole idea of maven ?
Where can I find a good repository that will have all these artifacts so that I don't need to download the jars by hand ?
What am I doing wrong when using maven, this definitely does not seem the way to go...
You're not doing anything wrong. The issue is that those artifacts don't exist in maven central repository. By default, that's the only repository maven will download from. You can add additional repositories (see maven docs) to configure repositories that aren't mirrored to central automatically.
As #Michael said, you are not doing anything wrong.
The default Maven central repository is not going to provide every possible artifact on the earth.
Normally you can have two way to solve it:
1) The artifact you use may be provided by some organization, which they provide their own repository to host those artifact. Tell Maven to lookup those repositories so that Maven can retrieve the corresponding artifact.
or
2) Get the JAR etc and put in your local environment.
There are two most commonly used ways for the above work:
A) Have a "local" maven repository/proxy (e.g. Nexus, Artifactory), and make your Maven points to this repository. Adding new remote repository (1) is mostly done by adding extra repo to proxy under your local Maven repo. Manually handling 3rd party artifact (2) is done by deploying the JAR to your local repo.
B) All done locally by your local Maven. Adding new remote repo (1) is done by updating the settings.xml (or your project POM.xml). Manually handling 3rd party artifact (2) is done by installing 3rd party JAR to local repository.
you can use
<dependency>
<groupId>com.extjs</groupId>
<artifactId>gxt</artifactId>
<version>2.3.0-gwt22</version>
</dependency>

maven could not resolve dependency via my local nexus repository

I have setup an in-house Sonatype Nexus repository and configure the maven to check my local Nexus instead of getting artifacts directly from public repositories.
http://www.sonatype.com/books/nexus-book/reference/config-sect-intro.html
Our project was able to download the most artifacts except one artifact in Maven central.
Here is the build error:
Failed to execute goal on project shindig-gadgets: Could not resolve dependencies for project org.apache.shindig:shindig-gadgets:jar:3.0.0-SNAPSHOT: Could not find artifact com.ibm.icu:icu4j:jar:4.6 in nexus (http://my_nexus_repository:8081/nexus/content/groups/public) -> [Help 1]
I see that icu4j-4.6.jar does exist in the Maven central repository. On my local nexus repository, it doesn't exist. I see only icu4j-4.6.pom exists on my local nexus repository.
It's not like my nexus repository setting is totally broken. maven project has successfully downloaded numerous jar files from multiple public repositories via my local nexus maven repository except icu4j-4.6.jar.
I don't understand why I'm having a problem with only icu4j-4.6.jar. Would it be incorrectly cached on either my local maven or nexus maven repository?
If it was incorrectly cached, how can I clean the local maven or nexus maven repository?
The similar problem is described at
Missing maven dependency using nexus setup
icu4j-4.6.jar does not show up in the search list. Only icu4j-4.6.pom shows up in the search list. I don't think is Snapshot VS Release issue because icu4j-4.6.jar seems release jar.
Is it possible that the nexus repo just stopped responding for a while? You can try mvn -X (or -d?) to get detailed info about what is going on. You might also try configuring an alternative repo.
Perhaps you haven't enabled remote index downloads from Maven Central. This would explain why only the POM file appears in your local search (The only file which has been downloaded via the proxy repo).
There might be another issue causing the download failure for the jar itself.... I suppose try and solve one problem at a time :-)
Try adding -U to your mvn arguments to force an update of your local repository.
You could also have corrupt meta data in the repo. In which case, delete that artifact from the repo's cache and let it refresh.
If the artifact in question was cached in properly from the proxy repository, using mvn -U will fix the problem
However if you are seeing pom on your nexus ,this usually happens when the artifact from the proxy repository is not cached in properly. The way to fix is
1) Browse to the component in the Proxy Repository.
2) Invalidate the cache for the repository and reindex the Nexus repository.
3) run mvn clean -U

Resources