Apache IVY - Local Repository


Advertisements

A local repository is a private repository of a user. It is very useful in case a user is using a library whose version has been changed on other places and have breaking changes. In case of local repository, ivy will use the library present in the local if found and will not look into public or shared repositories.

Default Location

By default, local repository is present in ${ivy.default.ivy.user.dir}/local folder. If you want to change it, the use the ivy.local.default.root variable in ant file.

build.xml

<target name="resolve">
   <property name="ivy.local.default.root" value="/opt/ivy/repository/local"/>
   <ivy:resolve />
</target>

Other properties like ivy pattern and artifact pattern can also be customized as follows −

build.xml

<target name="resolve">
   <property name="ivy.local.default.root" value="/opt/ivy/repository/local"/>
   <property name="ivy.local.default.ivy.pattern" value="[module]/[revision]/ivy.xml"/>
   <property name="ivy.local.default.artifact.pattern" value="[module]/[revision]/[artifact].[ext]"/>
   <ivy:resolve />
</target>

Overriding ivysettings defaults

By default ivy has its configurations in ivysettings.xml present in ivy.jar.

ivysettings.xml

<ivysettings>
   <settings defaultResolver="default"/>
   <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"/>
</ivysettings>

To override local repository setting, update the contents of ivysettings-local.xml.

ivysettings-local.xml

<ivysettings>
   <property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local" override="false"/>
   <property name="ivy.local.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
   <property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
   <resolvers>
      <filesystem name="local">
         <ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
         <artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
      </filesystem>
   </resolvers>
</ivysettings>
Advertisements