How to specify a relative path to the local Ivy repo in Gradle?
Asked Answered
G

1

10

I'm migrating from Ant/Ivy to Gradle, and am trying to understand how you specify a relative path to the local Ivy repo. Standalone Ivy sets the variable ${ivy.default.ivy.user.dir} by default to .ivy2 in the user home directory, and places the local repo there.

I can simulate this as follows:

repositories {
    ivy {
        url "C:/Users/RYAN/.ivy2/local"
        layout 'pattern', {
            artifact "[organisation]/[module]/[revision]/[artifact](-[classifier])-[revision](.[ext])"
            ivy "[organisation]/[module]/[revision]/[artifact](-[classifier])-[revision](.[ext])"
    } 
}

But I don't want to specify an absolute path. I see there's a GRADLE_USER_HOME environment variable, but Gradle doesn't set it by default--I have to specify it command line.

Does Gradle provide a way to access a default local Ivy repo?

Golconda answered 18/4, 2012 at 23:34 Comment(0)
E
15

How about using:

url "${System.properties['user.home']}/.ivy2/local"
Endoderm answered 19/4, 2012 at 23:55 Comment(3)
Thanks, that does work. I'd still like to access/use some of the Ivy default properties, but this will work for avoiding the absolute path.Golconda
I don't think Gradle has such a shortcut ... (i.e. like the mavenCentral() repo one) ... You can always request this feature on the Gradle forums.Endoderm
Optionally ... you can always make sure that the ivy.default.ivy.user.dir system property is set .. and use it to replace 'user.home' in my example.Endoderm

© 2022 - 2024 — McMap. All rights reserved.