Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-includes/wp-db.php on line 1038
Resolve Dependencies With Ivy - Max Did It
Max Did It
1 Comment
Tagged ,

Resolve Dependencies With Ivy

In my last post, I wrote about how you can use Apache Ivy to automatically store your compiled components and libraries in a local repository. Now, why should you even do that? What’s the point?

The point is, that now you can use Ivy to

  • automatically copy the libraries you need into your project’s folder structure,
  • always retrieve the latest version of a library,
  • download libraries from remote repositories, provided you have access and
  • get dependencies that aren’t even in any of your repositories.
Ivy: Work, Work

“Work, Work”. Apache Ivy can take a bunch of manual tasks off your hands. © 2012 Max Knoblich

This is how I use Ivy to make working with libraries easier:

Define And Resolve Dependencies

In my last post, I already mentioned the ivy.xml. This file is usually put in the same folder as Ant’s build.xml and contains information like the name of the project to be built and it’s version number.

This is also where you tell Ivy which libraries your project depends on. Just like the project itself, you have to set the dependencies name, version and organistation name, since this is the format they are stored in the repository. Dependencies are stored in the dependencies tag (surprise!), which is a child element of the ivy-module tag.

<ivy-module version="2.0">
		<dependency org="de.maxdidit" name="linked-list" rev="1.0.0" />

This enables Ivy to copy the SWC files from your local or remote repository and put them into your project folders. To make Ivy actually do that, you need to go to your project’s build.xml and call the respective Ant tasks.

<target name="retrieve">
	<!-- Resolve and retrieve dependencies -->
	<ivy:resolve refresh="true" showprogress="true" />
	<ivy:retrieve pattern="${library-path}/[module]-[revision](-[artifact]).[ext]" />

The resolve tag looks up where the dependencies are and can also resolve dependencies recursively. If a library relies on other files to work properly, Ivy can try to get these files as well.

The retrieve tag then actually copies the files into your project, relying on the pattern you pass to it. This is where you put the folder and the name format you want your libraries to appear in.

Always Use The Latest Version

Another neat feature is that you can tell Ivy not to get a specific version of a SWC, but always the latest one present in the repository. This comes in handy if you or someone else updates a certain library very often. This is simply done by putting the latest.integration keyword into the “rev” property in your ivy.xml file.

<ivy-module version="2.0">
		<dependency org="de.maxdidit" name="linked-list" rev="latest.integration" />

You can also tell Ivy to use the latest version up until a certain major release. If you want the latest 1.x.x release of a SWC, but can’t use the 2.0.0 release due to too many changes, you can do that to. The syntax for the different cases you can model can be found in the documentation of the dependency tag.

Access Local Files

So, what about libraries that have not been put into your repository? While many third party Java libraries are already available in public remote Maven repositories, Actionscript SWC files are still mostly downloaded from the developers homepage. You can publish them into your repository after downloading them, but I have decided against that step, since it isn’t really necessary.

Ivy makes it relatively easy to access files that are not in any of your repositories. This is simply done by putting an artifact tag into a dependency tag in the ivy.xml. You can put additional information about a dependency into the artifact tag, one of which is where Ivy should download the library if it can’t be found in the repository.

This can point to a local file or a remote URL.

<dependency org="org.mockito" name="mockito" rev="1.4M3">
	<artifact name="" type="swc" ext="swc" url="file:///c:/tools/mockito/mockito-1.4M3.swc" />

After doing this, Ivy will try to resolve and copy the file into your project like any other SWC from your repository.

Next Up: Inheriting From Other Ivy Files

Now, maybe you have certain dependencies that a couple, maybe even most of your projects rely on. You can copy those into each ivy.xml everytime you start a new project. You can also put them into a single XML file once and then inherit from that file each time you need to. I will write about that in the next blog post.


1 Comment has been posted so far - Leave a Comment

Notice: Undefined variable: avatar_size in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-content/themes/maxdidit11/comments.php on line 45

Mit ivy hab ich noch nix gemacht, komme aus der Php welt. Klingt aber recht interessant. Hast du dir mal composer angeschaut? Das kommt zwar vom den Entwicklern des symfony frameworks sollte aber sprach unabhängig funktionieren.

Gruß max

Btw.... nette Zeichnung :-)


Notice: Undefined variable: post_id in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-content/themes/maxdidit11/comments.php on line 147

Notice: Undefined variable: args in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-content/themes/maxdidit11/comments.php on line 183
Leave A Comment

Your email address will not be published. Required fields are marked *

Connect with Facebook


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • RSS Feeds

    Notice: Undefined variable: output in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-content/plugins/category-rss-widget-menu/rss.php on line 127

    Notice: Undefined variable: output in /is/htdocs/wp10582507_LGPWONUTVE/www/wp-content/plugins/category-rss-widget-menu/rss.php on line 90