0
votes

I'm writing a Java library for my project: I use Ivy for the dependencies management and the publishing of the JAR to my local repository.

When I update ivy.xml (i.e. to add a new external library), everything is OK: all artifacts are retrieved and used.

However, when I publish my library, the ivy-module xml generated by Ivy contains missing/wrong references (often to previous versions of the external libraries).

This is the target I have in my build.xml:

    <target name="publish" depends="jar" description="Publish this project in the ivy repository">
    <property name="revision" value="${version}" />
    <ivy:publish artifactspattern="${jar.dir}/[artifact].[ext]" resolver="projects" pubrevision="${revision}" status="release" update="true" overwrite="true" />
    <echo message="project ${ant.project.name} released with version ${revision}" />
</target>

And this is my ivy.xml:

<ivy-module version="2.0">
<info organisation="xyz" module="zyx"/>
<configurations defaultconfmapping="*->*,!javadoc,!sources" />
<dependencies>
    <dependency org="ch.qos.logback" name="logback-classic" rev="0.9.28" /> 
    <dependency org="commons-lang" name="commons-lang" rev="2.5"/>
    <dependency org="commons-io" name="commons-io" rev="2.0"/>
    <dependency org="org.simpleframework" name="simple-xml" rev="2.4.1">
        <exclude module="stax"/>
        <exclude module="stax-api"/>
    </dependency>
    <dependency name="AlmaUtils" rev="1.3.10"/>
    <!-- Reflections -->
    <dependency org="org.reflections" name="reflections" rev="0.9.5-RC2">
        <exclude module="logback-classic"/>
    </dependency>
    <!-- Bouncycastle cryptography -->
    <dependency org="org.bouncycastle" name="bcprov-ext-jdk16" rev="1.45"/>
    <dependency org="jdom" name="jdom" rev="1.1">
        <exclude module="xerces"/>
        <exclude module="xalan"/>
    </dependency>
    <!-- Scripting -->
    <dependency name="js-engine" rev="1.0"/>
    <dependency org="rhino" name="js" rev="1.7R2"/>
    <!-- JGA -->
    <dependency name="jga" rev="0.8.1"/>
</dependencies>

1

1 Answers

2
votes

Perhaps you should add the following target into your build.

<target name="clean-all" depends="clean" description="Purge ivy cache">
    <ivy:cleancache/>
</target>

This will wipe the slate clean and ensure that your build is completely clean.

Ivy is basically an optimized downloader, however, sometimes it can make incorrect caching decisions when you upgrade the version of a complex tree of dependencies. Maven builds are also affected by this problem when the local repository is very large.