How to use Ivy to resolve locally

10,394

You definitely need to define a file system resolver and create your own ivysettings.xml.

You will have to give it a special directory where it can publish. This should be somewhere outside of your project.

    <filesystem name="local" checkmodified="true">
        <ivy pattern="${basedir}/../repo/[module](-[branch])/[revision]/[artifact](-[branch])-[revision].[ext]" />
        <artifact pattern="${basedir}/../[module]/[revision]/[artifact](-[branch])-[revision].[ext]" />
    </filesystem>

This will behave like a completely normal repository. On resolve artifacts will be copied to your cache and from there to your retrieve-location.

On publish artifacts will be copied there.

You can set the path to the ivysettings.xml:

<property name="ivy.settings.file" value="${path_to_file}/ivysettings.xml"/>

This will be read automatically by calling:

<ivy:settings />

which activates the settings.

You can also create a chain for the special module, that looks first in the filesystem and then in the repository:

<resolvers>
    <url name="remote"/>
    <filesystem name="local" checkmodified="true" />

    <chain name="ourOrg" dual="true" latest="time"> 
        <resolver ref="local"/>
        <resolver ref="remote"/>
    </chain>    
</resolvers>

  <modules>
    <!-- resolver für readybank module-->
    <module organisation="ourOrg" resolver="ourOrg"/>
  </modules>

IvyDe for eclipse has a workspace resolver, which works great for any projects that are open in eclipse.

Share:
10,394
IAmYourFaja
Author by

IAmYourFaja

my father is a principal at burgoyne intnl and got me this job programming lisp and development. I aspire to unittesting with a concentration in mobile platforms.

Updated on June 29, 2022

Comments

  • IAmYourFaja
    IAmYourFaja almost 2 years

    I have set our Eclipse projects up with Ivy and a URL resolver which looks for artifacts and ivy files on a web server here in the office. Everything works beautifully.

    I have a few projects that are dependencies for other projects, and I would like to tweak the Ivy config so that these dependencies can "publish locally", and so that the downstream projects that depend on them can resolve them locally. Doing so will allow a developer to make changes in one project, and see those changes ripple out in another project that depends on it; all without having to publish to our official (web server) repository.

    First I added a publish-locally task to a project (let's call it DepProj) that is a dependency for downstream projects:

    <target name="publish-locally" depends="clean,dist">
        <ivy:publish resolver="local" overwrite="true" pubrevision="${ivy.new.revision}">  
            <artifacts pattern="${distDir}/[artifact].[ext]" />   
    </ivy:publish>
    </target>
    

    Then I modified the ivy.xml file for one of DepProj's downstream projects, called DownstreamProj:

    <dependency org="ourOrg" name="DepProj" rev="latest.integration" conf="*->*"/>
    

    I'm now choking on connecting the two. I need to tweak our ivy.settings file to use a filesystem resolver. When DepProj publishes locally, you can see that it first runs clean, then dist. The dist target creates a JAR under DepProj/dist/DepProj.jar.

    I imagine I need to point the filesystem resolver (somehow) to this dist directory? But then again the DepProj is not the only project I want to publish locally with.

    I have most of the pieces of the puzzle here, I'm just having trouble connecting some dots.

    Can some kind SOer nudge me in the right direction? A helpful code example is always greatly appreciated too! Thanks!