开发者

Ivy custom url resolver

开发者 https://www.devze.com 2023-01-14 08:43 出处:网络
I am trying to create custom resolver in my ivysettings.xml file: <ivysettings> <settings defaultResolver=\"default\"/>

I am trying to create custom resolver in my ivysettings.xml file:

<ivysettings>
    <settings defaultResolver="default"/>
    <resolvers>
        <chain name="default">
            <url name="scala-tools">
                <ivy pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/ivy-[revision].xml" />
                <artifact pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
                <artifact pattern="http://scala-tools.org/repo-releases/[organisation]/[module]/[revision]/[artifact].[ext]"/>
            </url>
            <!--<ibiblio name="ibiblio"/>-->
        </chain>
    </resolvers>
</i开发者_如何学Cvysettings>

As you can see, I have just one UrlResolver that will try to find my dependencies in scala-tools repo. If I specify my dependencies correctly than ivy will try to find it in http://scala-tools.org/repo-releases/org.scala-lang/scala-library/2.8.0/scala-library-2.8.0.jar and http://scala-tools.org/repo-releases/org.scala-lang/scala-library/2.8.0/scala-library.jar (yep, according to my instructions in ivysettings.xml) Obviously, it doesn't find anything. To get thing working I must specify dependencies in this way:

<ivy-module version="2.2">
    <info organisation="org.yoba" module="Yoba"/>
    <dependencies>
        <dependency org="org/scala-lang" name="scala-library" rev="2.8.0"/>
        <!--<dependency org="org.scala-lang" name="scala-library" rev="2.8.0"/>-->
        <dependency org="org/scala-lang" name="scala-compiler" rev="2.8.0"/>
        <!--<dependency org="org.scala-lang" name="scala-compiler" rev="2.8.0"/>-->
    </dependencies>
</ivy-module>

Q:How to change artifact pattern / something else to force ivy to make it's job right way?

1: http://scala-tools.org/repo-releases/ scala-tools repo


ivy.xml

I checked the POM for scala-compiler and discovered that it references the module scala-library. This means only need one dependency declaration is required in the ivy file:

<ivy-module version="2.0">
    <info organisation="org.yoba" module="Yoba"/>
    <dependencies>
        <dependency org="org.scala-lang" name="scala-compiler" rev="2.8.0" conf="default"/>
    </dependencies>
</ivy-module>
  • The version number needs to be "2.0"
  • Included the default mapping to avoid downloading the optional dependencies

ivysettings.xml

I recommend using the ibiblio resolver when downloading from any Maven compliant repository.

<ivysettings>
    <settings defaultResolver="scalatools"/>
    <resolvers>
        <ibiblio name="scalatools" root="http://scala-tools.org/repo-releases" m2compatible="true"/>
    </resolvers>
</ivysettings>

If you need to download other libraries the settings file can be enhanced, so that ivy only retrieves the scala modules from the scala repository

<ivysettings>
    <settings defaultResolver="central"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
        <ibiblio name="scalatools" root="http://scala-tools.org/repo-releases" m2compatible="true"/>
    </resolvers>
    <modules>
        <module organisation="org.scala-lang" resolver="scalatools"/>
    </modules>
</ivysettings>
0

精彩评论

暂无评论...
验证码 换一张
取 消