1277

maven repository proxy confusion

Question:

I am using maven 3.0 ( with nexus setup ) for building my projects and am getting build failures :

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact directory:apacheds-core:jar:${apacheds_version} in central (http://localhost:8081/nexus/content/repositories/central) at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:945) at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:940)

My basic confusion is : <strong>When maven sees a dependency in the pom.xml , how does it go about looking for artifacts in remote repositories</strong> ?

My current understanding is :

<ol><li>

It will first look in the local repo ( .m2/repository ).

</li> <li>

If it does <strong>not</strong> find there , then it will try to search the repository specified in settings.xml under <strong>repository</strong> tag. <strong>Question</strong> : Does it try all the repositories mentioned . <strong>or Just the first one</strong> ? Below I have mentioned 5 repos : does maven search all these one by one or just the first one ?

</li> </ol>

<repositories> <repository> <id>central</id> <url>http://localhost:8081/nexus/content/repositories/central</url> </repository> <repository> <id>remote</id> <url>http://localhost:8081/nexus/content/repositories/remote-proxy-nexus-central</url> </repository> <repository> <id>thirdParty</id> <url>http://localhost:8081/nexus/content/repositories/thirdparty</url> </repository> <repository> <id>codehaus</id> <url>http://localhost:8081/nexus/content/repositories/codehaus-snapshots</url> </repository> <repository> <id>public</id> <url>http://localhost:8081/nexus/content/groups/public</url> </repository> </repositories>

My last confusion is about proxies section in the settings.xml. What are these locations :

<proxy> <id>remote-proxy-nexus-central</id> <active>true</active> <protocol>http</protocol> <host>repo1.maven.org/maven2</host> <port>8080</port> </proxy>

Answer1:

I can tell you we use a local Nexus and have all our users have the following in their settings.xml:

<mirror> <id>our-mirror</id> <name>Org Public Mirror</name> <url>http://host/nexus/content/groups/public</url> <mirrorOf>*</mirrorOf> </mirror>

This causes any call by maven to go to Nexus to get a dependency. You are right about maven first looking in local .m2.

Nexus proxies many repositories and has a union of them all (for the maven processes calling it). This means that a developer's local maven knows only of a single repository: Nexus. Nexus will serve all the needed dependencies id they are in one of its proxied/hosted repositories.

As for Proxy, we have an organization proxy, but the Nexus is in the org (it has the proxy configured to allow access to the outer world), so maven does not need this specific configuration.

I hope this gives you some information to get started.

I strongly urge you to look into Nexus/Maven related configurations at: <a href="http://www.sonatype.org/" rel="nofollow">http://www.sonatype.org/</a>

Answer2:

The correct setup for using Maven with Nexus is documented in the book Repository Management with Nexus. The sample settings.xml is <a href="http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html" rel="nofollow">here</a>. Read the description and note that you need to add the overrides for the central repository to enable snapshots.

Once you have done that you do NOT configured a proxy in your settings.xml since it will be available in your local network without a proxy (typically). Instead you configure the proxy settings in Nexus so that it in turn can get out to the repositories like Central that you are proxying. The global proxy configuration is documented <a href="http://www.sonatype.com/books/nexus-book/reference/configxn-sect-customizing-server.html#_default_http_proxy_settings" rel="nofollow">here</a> and if required you can also configure specifics per proxy repository e.g. if you need a username/password for a repository you are proxying because it is private..

Recommend

  • lein uberjar doesn't pack the jar file under resource into the final jar
  • why doesn't this visNetwork in R show edge
  • Default CUDA addition rounding mode between cuda 5.0 and 7.5
  • Referencing external dependencies in GGTS by convention
  • force insert with spring data jpa
  • Grails 3 - How to publish to Artifactory
  • Google cloud datastore emulator init data
  • “git push” doing the same as “git fetch” from the remote
  • still not find package, after 'mvn install'
  • How to force Composer to download a local package?
  • How to resolve dependencies from one gradle project to another gradle project in my Eclipse workspac
  • Excel distinct count with conditions
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • How do you create a Fuseki SPARQL server using the Apache Jena Java API?
  • ImportError: cannot import name Pubnub
  • “mvn clean generate-source” could not resolve dependencies
  • How do I remove all but some records based on a threshold?
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • ADO and msqli connections very slow
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • How to get Eclipse Oxygen to run on Java 9
  • PHP buffered output depending on server setting?
  • Admob requires api-13 or later can I not deploy on old API-8 phones?
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Google Custom Search with transparent background
  • Jetty Server not starting: Unable to establish loopback connection
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Control modification in presentation layer
  • Get one-time binding to work for ng-if
  • Insert into database using onclick function
  • What is Eclipse's Declaration View used for?
  • Volley JsonObjectRequest send headers in GET Request
  • Can I make an Android app that runs a web view in Chrome 39?
  • Importing jscolor library in angular 2
  • XCode can't find symbols for a specific iOS library/framework project
  • apache spark aggregate function using min value
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • costura.fody for a dll that references another dll