2

How does Ivy read a Nexus repo acting as a Maven mirror?

I was thinking about using Gradle as my build system, and Gradle is built from Ant+Ivy (using Groovy). I have a Nexus repository on my local network that acts as a "mirror". In order for me to build my projects, I put a "mirror" entry in my .m2\settings.xml config file. I am able to build my Maven projects just fine but Gradle does not read the .m2 config and so my Gradle projects wont build.

I do not know how to configure Gradle to use the nexus repo as a mirror. Can anyone explain this or give me some hints? I suspect it has something to do with usage of a ivysettings.xml file maybe? This post implies that Gradle DOES in fact read the Maven config but I do not experience this.

djangofan
  • 28,471
  • 61
  • 196
  • 289
  • Gradle reads `settings.xml` only to locate the local Maven repository. Gradle doesn't ever read `ivysettings.xml`. You need to declare the proxy as a Maven repository as shown in the answer below. – Peter Niederwieser Aug 20 '13 at 05:39
  • Notice that a mirror in Maven means that it will pretty much ignore all repository declarations and will use the mirror instead, so adding the mirror as a repository is not the same thing. – Constantino Cronemberger Jun 13 '16 at 20:21

2 Answers2

6

I'm using Gradle with a Nexus repo and a Maven proxy and I did not have to modify any of those xml files. I just installed Nexus, created a user with a password through the admin UI, and added this config in my gradle init script (e.g. ${USER_HOME}/.gradle/init.gradle):

allprojects {
    repositories {
        // Third party dependencies are fetched from MavenCental through a Nexus proxy repository
        maven {
            credentials {
                username 'some_username'
                password 'some_password'
            }
            url 'http://dev.primalogik.com/nexus/content/groups/public/'
        }
    }

    dependencies {
        // Example of a compile time dependency
        compile group: 'com.google.gwt', name: 'gwt-dev', version: '2.5.1'
        ...
    }
}
Alberto
  • 5,021
  • 4
  • 46
  • 69
David Levesque
  • 22,181
  • 8
  • 67
  • 82
  • I tried something similar to that but it didn't solve my problem. I am forced to use Maven only builds because Gradle has some sort of problem rendering the dependencies through the mirror. Maybe this is the sort of question that is impossible to answer without having all the information. – djangofan Aug 19 '13 at 17:22
  • Can you elaborate on how it didn't solve your problem? What problem did your experience with Gradle dependencies? – David Levesque Aug 19 '13 at 17:26
  • Sorry, but it is very difficult to describe. It seems like downloading dependencies partially works but not fully. I would have to reveal too much info to allow someone to help me troubleshoot it. I just asked this question because I thought maybe I missed something that was simple and obvious. – djangofan Aug 19 '13 at 17:53
  • 2
    @djangofan Without more information this question cannot be answered. My advice is to accept this answer, it appears to match the information I found in the Gradle documentation. – Mark O'Connor Aug 19 '13 at 20:46
  • +1 This worked for me. When I first read your post, I wasn't sure about what you meant with the "root `build.gradle`". I have edited your post to make it clear that it is a standard gradle init script. – Alberto Sep 22 '15 at 07:33
0

The following answer describes how to configure a Maven repository manager in ivy:

I'm uncertain whether this actually helps with a Gradle build (I thought Gradle had stopped using ivy).

Update

Gradle documentation on configuring repositories:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185