0
votes

At our company, we use a base ant file that is included by everyone to do their builds. It contains the things we want to define globally and uniform, like build-test, test-coverage, build-release, publish on ivy, etc.

I would like to enforce that in the ivy resolve that is done for creating a release build, libraries that have test (integration) status are rejected. Basically, that for a release build, you can only use release-class libraries.

However, I cannot find a way to enforce this in the ivy resolve ant task (not in the ivy.xml file).

Does anybody have an idea on how to accomplish this?

1

1 Answers

1
votes

Option 1

Strictly speaking you have two sets of resolved libraries, so this could be solved by having two ivy files. One listing dependencies on the latest integration revisions the other the latest release versions.

The build.xml file would then have two resolution targets, controlled by a release property

<target name="resolve-int" unless="release.build">
    <ivy:resolve file="ivy-int.xml"/>
</target>

<target name="resolve-rel" if="release.build">
    <ivy:resolve file="ivy-rel.xml"/>
</target>

<target name="resolve" depends="resolve-int,resolve-rel"/>

Option 2

Use a property to determine the desired dynamic revision:

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>
    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="${dynamic.revision}"/>
    </dependencies>
</ivy-module>

build.xml

The property dynamic.revision has a default value of latest.integration

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="demo-ivy" default="resolve">

    <property name="dynamic.revision" value="latest.integration"/>

    <target name="resolve">
        <ivy:resolve/>
    </target>

    ..    

</project>

A release build would then override this value, possibly from the command-line as follows:

ant -Ddynamic.revision=latest.release