Resolving XSD's using Ivy

岁酱吖の 提交于 2019-12-05 21:53:11

Interesting problem. Caching the Schema files enables off-line validation.

As Tom stated I think only a single retrieve is needed. (My example fetches both jars and schema files)

<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]"/>

I've offered some changes to the ivy and settings files.

ivy.xml

I've used ivy extra attributes to assist with the generation of the Spring Schema URLs:

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info organisation="com.myspotontheweb.demo" module="spring"/>

    <configurations defaultconfmapping="compile->default">
        <conf name="compile" description="Compile dependencies"/>
        <conf name="schemas" description="XML schema files"/>
    </configurations>

    <dependencies>
        <!-- Compile depedencies -->
        <dependency org="org.springframework" name="spring-core" rev="3.0.6.RELEASE"/>

        <!-- Schema dependencies -->
        <dependency org="org.springframework" name="schemas" rev="3.0" conf="schemas->default">
            <artifact name="spring-beans"   e:framework="beans" type="xsd"/>
            <artifact name="spring-context" e:framework="context" type="xsd"/>
            <artifact name="spring-mvc"     e:framework="mvc"   type="xsd"/>
            <artifact name="spring-tool"    e:framework="tool"  type="xsd"/>
            <artifact name="spring-util"    e:framework="util"  type="xsd"/>
        </dependency>

        <dependency org="com.sun.java" name="schemas" rev="5" conf="schemas->default">
            <artifact name="javaee_5"    type="xsd"/>
            <artifact name="web-app_2_5" type="xsd"/>
            <artifact name="javaee_web_services_client_1_2" type="xsd"/>
            <artifact name="jsp_2_1"     type="xsd"/>
        </dependency>

        <dependency org="org.w3" name="schemas" rev="2001" conf="schemas->default">
            <artifact name="XMLSchema" type="xsd"/>
            <artifact name="xml"       type="xsd"/>
        </dependency>
    </dependencies>
</ivy-module>

ivysettings.xml

Configure ivy to use Maven repositories by default. Use a modules declaration to route the special schema modules to your URL resolvers.

<ivysettings>
    <settings defaultResolver="maven-repos"/>
    <resolvers>
        <chain name="maven-repos">
            <ibiblio name="central" m2compatible="true"/>
            ..
            Other Maven repositories go here
            ..
        </chain>
        <url name="spring-schemas">
            <artifact pattern="http://www.springframework.org/schema/[framework]/[artifact].[ext]"/>
        </url>
        <url name="javaee-schemas">
            <artifact pattern="http://java.sun.com/xml/ns/javaee/[artifact].[ext]"/>
        </url>
        <url name="w3-schemas">
            <artifact pattern="http://www.w3.org/2001/[artifact].[ext]"/>
        </url>
    </resolvers>
    <modules>
        <module organisation="org.springframework" name="schemas" resolver="spring-schemas"/>
        <module organisation="com.sun.java" name="schemas" resolver="javaee-schemas"/>
        <module organisation="org.w3"       name="schemas" resolver="w3-schemas"/>
    </modules>
</ivysettings>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!