tags:

views:

87

answers:

0

Forgive the double post but I am keen on an answer to this.

I would like some advice as to the approach I am taking. I am using Ivy for dependency management and am able to download and use all my jar files no issues. I would like to also run the <schemavalidate> task in Ant and would like to use Ivy to download the xsd's and dtd's as specified, thereby eliminating the need for a network connection after the initial download and also reducing my build time. I think I have a solution but wanted to run it by some extra eyes for a sanity check and suggestions for possible improvements. Below is the relevant parts of my build scripts. The first call to retrieve uses my default ivysettings.xml and second call uses a settings file specific for retrieving xsd's and dtd's. Any feedback would be appreciated.

build.xml:

<project etc>
    ...

    <target name="resolve" description="Retrieve dependencies with ivy">
        <ivy:retrieve refresh="true"
                  sync="true"
                  conf="compile,war,runtime,test,findbugs"
                  pattern="${ivy.lib.dir}/[conf]/[artifact]-[revision].[ext]"/>
        <ivy:settings id="xsd.settings" 
                      file="${search.server.home}/ivysettings-xsd.xml"/>
        <ivy:retrieve settingsref="xsd.settings"
                  refresh="false"
                  sync="false"
                  conf="xmlentities"
                  pattern="${ivy.lib.dir}/[conf]/[artifact].[ext]"/>
    </target>
    ...
</project>

ivy.xml:

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra"&gt;
    <dependencies>
        <!-- Jar files defined here but removed for brevity -->
        ...
        <dependency org="beans" name="spring-beans" rev="3.0" conf="xmlentities->default">
            <artifact name="spring-beans" type="xsd"/>
        </dependency>
        <dependency org="context" name="spring-context" rev="3.0" conf="xmlentities->default">
            <artifact name="spring-context" type="xsd"/>
        </dependency>
        <dependency org="mvc" name="spring-mvc" rev="3.0" conf="xmlentities->default">
            <artifact name="spring-mvc" type="xsd"/>
        </dependency>
        <dependency org="tool" name="spring-tool" rev="3.0" conf="xmlentities->default">
            <artifact name="spring-tool" type="xsd"/>
        </dependency>
        <dependency org="util" name="spring-util" rev="3.0" conf="xmlentities->default">
            <artifact name="spring-util" type="xsd"/>
        </dependency>
        <dependency org="javaee" name="javaee" rev="5" conf="xmlentities->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="xmlschema" name="xmlschema" rev="2001" conf="xmlentities->default">
            <artifact name="XMLSchema" type="xsd"/>
            <artifact name="xml" type="xsd"/>
        </dependency>
    </dependencies>
</ivy-module>

ivysettings-xsd.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
    <settings defaultResolver="namespaces"/>
    <resolvers>
        <chain name="namespaces" returnFirst="true">
            <url name="w3-org-ns" checksums="">
                <artifact pattern="http://www.w3.org/2001/[artifact].[ext]"/&gt;
            </url>
            <url name="javaee-ns" checksums="">
                <artifact pattern="http://java.sun.com/xml/ns/javaee/[artifact].[ext]"/&gt;
            </url>
            <url name="spring-ns" checksums="">
                <artifact pattern="http://www.springframework.org/schema/[organisation]/[artifact].[ext]"/&gt;
            </url>
        </chain>
    </resolvers>
</ivysettings>

Ben