make ivy not to download sources and license files

2019-01-28 13:04发布

问题:

Is there a way to configure ivy not to download sources & license files via ivy.xml ?

I'm currently trying to use default ivy repos + spring repository. my ivysettings.xml is bellow:

<?xml version="1.0" encoding="ISO-8859-1"?>

<settings defaultResolver="springSource" />
<include url="${ivy.default.settings.dir}/ivysettings-public.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-local.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml" />
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml" />
<resolvers>
    <chain name="springSource">
        <url name="com.springsource.repository.bundles.release">
            <ivy
                pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            <artifact
                pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
        </url>

        <url name="com.springsource.repository.bundles.external">
            <ivy
                pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            <artifact
                pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
        </url>

        <ibiblio name="public" m2compatible="true" />
        <ibiblio name="shared" m2compatible="true" />
        <ibiblio name="local" m2compatible="true" />
        <ibiblio name="main-chain" m2compatible="true" />
        <ibiblio name="default-chain" m2compatible="true" />
    </chain>
</resolvers>

回答1:

Use ivy configurations to specify your desired mapping to the dependencies of your dependencies (Called transitive dependencies):

Don't know what version of spring you're using, this example downloads spring version 3.0:

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>
    <configurations>
        <conf name="compile" description="Compile classpath"/>
    </configurations>
    <dependencies>
        <dependency org="org.springframework" name="org.springframework.core" rev="3.0.0.RELEASE" conf="compile->default"/>
    </dependencies>
</ivy-module>

When referencing a Maven module configurations refer to Maven scopes. The default scope in Maven would be compile, but you can reference any other public scope.

Additional note

I'm using a much simpler settings file:

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="spring-release"  root="http://repository.springsource.com/maven/bundles/release" m2compatible="true"/>
            <ibiblio name="spring-external" root="http://repository.springsource.com/maven/bundles/external" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

In my opinion the ibiblio resolver is the easiest way to integrate with a remote Maven repository. I think the confusing name is historical, dating back to the original name of the first Maven repository site. You'll need to additionally specify the m2compatible attribute, since the original Maven 1 repository format is now almost unknown.

Perhaps one day the ivy developers will create a new "maven" resolver that will make life easier for new users.