Spec file
BuildRequires: ivy-local
ant -Divy.mode=local test
%mvn_artifact ivy.xml lib/sample.jar
%files -f .mfiles
%files -javadoc -f .mfiles-javadoc
`-Divy.mode=local` tells Ivy to use XMvn local artifact resolution instead of downloading from the Internet
If there is an `ivy-settings.xml` or similar file, which specifies remote repositories, it needs to be disabled, otherwise it would override local resolution.
`%mvn_artifact` supports installing artifacts described by Ivy configuration files
Ivy files manipulation
A subset of macros used to modify Maven POMs also work with `ivy.xml` files allowing the maintainer to add/remove/change dependencies without the need of making patches and rebasing them with each change. You can use dependency handling macros `%pom_add_dep`, `%pom_remove_dep`, `%pom_change_dep` and generic `%pom_xpath_*` macros. For more details, see corresponding manpages.
# Remove dependency on artifact with org="com.example" and
# name="java-project" from ivy.xml file in current directory
%pom_remove_dep com.example:java-project
# Add dependency on artifact with org="com.example" and
# name="foobar" to ./submodule/ivy.xml
%pom_add_dep com.example:foobar submodule
Using the `ivy:publish` task
Ivy supports publishing built artifact with `ivy:publish` task. If your `build.xml` file already contains a task that calls `ivy:publish`, you can set the resolver attribute of the `ivy:publish` element to `xmvn`. This can be done with simple `%pom_xpath_set` call. Then when the task is run, XMvn can pick the published artifacts and install them during the run of `%mvn_install` without needing you to manually specify them with `%mvn_artifact`.
Spec file using the `ivy:publish` task
BuildRequires: ivy-local
%pom_xpath_set ivy:publish/@resolver xmvn build.xml
ant -Divy.mode=local test publish-local
%mvn_install -J api/
The publish target may be named differently. Search the `build.xml` for occurences of `ivy:publish`.
`%mvn_install` will install all the published artifacts.