문제

I'm new to Gradle/Groovy so possibly I'm missing something obvious. Can you help?

We're using Ivy for dependency management. I'm trying out Gradle and want to integrate with our existing Ivy infrastructure. Normally this should be possible, but the layout of our Ivy is a bit idiosyncratic and well... I can't get it to work.

Take for example commons-lang-2.4.jar.

Typically, you'd fetch this file via ivy like so (cf. http://mvnrepository.com/artifact/commons-lang/commons-lang/2.4):

<dependency org="commons-lang" name="commons-lang" rev="2.4"/>

But we have to do it like so:

<dependency org="org.apache" name="commons-lang" rev="2.4" conf="compile"/>

That's because our Ivy is laid out taking into account the organization's url, e.g. like so:

<ivyrepository>/org/apache/commons-lang/2.4/commons-lang-2.4.jar

I have now tried to translate this to Gradle:

repositories {
    ivy {
        url 'http://svnserver/svn_public/trunk/ivyrepository'
        layout 'pattern', {
            artifact '[organisation]/[module]/[revision]/[artifact]-[revision].[ext]'
            ivy '[organisation]/[module]/[revision]/[module]-[revision].ivy'
        }
    }
}

dependencies {
    compile 'org.apache:commons-lang:2.4'
}

This is of course failing, as '[organisation]/[module]' translates to 'org.apache/commons-lang', and it should translate to org/apache/commons-lang!

So I tried this, naively thinking that replaceAll() would replace those dots with slashes:

repositories {
    ivy {
        url 'http://svnserver/svn_public/trunk/ivyrepository'
        layout 'pattern', {
            artifact '[organisation].replaceAll(\'.\',\'/\')/[module]/[revision]/[module]-[revision].jar'
            ivy '[organisation].replaceAll(\'.\',\'/\')/[module]/[revision]/[module]-[revision].ivy'
        }
    }
}

Alas, the function is not evaluated! Help!

도움이 되었습니까?

해결책

To get a Maven-style layout for the organisation part, use:

repositories {
    ivy {
        url ...
        layout 'pattern', {
            m2compatible = true
            ...
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top