Ethan
Ethan

Reputation: 6913

Gradle prefer repository on duplicate entries

I have a build tool thats tied the version to the SCM. I can't set the version of a jar when I build it locally. If someone were to change what I'm working on locally it would push the version number (which I can get), but when I publish to my local repo (Ivy) Gradle seems to prefer the external repo.

build.gradle

repositories {
    mavenCentral()

    ivy {
        url "${System.properties['user.home']}/.ivy2/local/"
        layout "pattern", {
            artifact "[organization]/[module]/[revision]/[artifact](-[classifier]).[ext]"
            ivy "[organization]/[module]/[revision]/ivy.xml"
        }
    }

    ivy {
        url "https://repo/"
        layout "pattern", {
            artifact myPattern
            ivy myIvyPattern
        }
    }
}

Without changing the build for the jar that I'm editing. How can I have gradle always prefer the local repo? I have a feeling that resolutionStrategy might be the best way, but I don't know how accomplish this.

Edit 1

To help clarify, Artifactory has a jar (published by jenkins) with version 1.2.3. I have a jar that I build locally that saves into my local repository as 1.2.3. When I build a project having both repositories in my repository closure (with my local one on top) Gradle seems to pull in the one from Artifactory.

Edit 2

Dependency definition

dependencies {
    compile ('company:project:1.2.+')
}

Upvotes: 0

Views: 458

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123900

I don't really understand what you are saying, but Gradle searches repositories in their declared order, and picks the first matching module that it finds (as least as long as fixed versions are used).

Upvotes: 2

Related Questions