Tony Farias
Tony Farias

Reputation: 93

Using a local dependency in Eclipse with Ivy / Ant

I have an ivy.xml file with remote dependencies to a library I own, for example

<dependency org="myorg" name="myProjectLib" rev="default" conf="default"/>

In Eclipse , if I have the myProjectLib project in my workspace, and want to depend on that version, instead of the remote one I have to 1) go to the project Properties -> Java Build Path -> Projects ->Required Projects on BuildPath and add the local project dependency there and 2) comment out the remote project dependency in my ivy.xml file, in order to actually be using the local dependency when running the project locally .

<!-- <dependency org="myorg" name="myProjectLib" rev="default" conf="default"/> -->

This seems like a step too many for me . I don't have this issue in IntelliJ for example. In that, I can just set it to depend on the local project and do not have to change the ivy file. I often run into dependency issues in Eclipse by commenting out the remote dependency. Any ideas/ suggestions on another way to do this or how to simplify this workflow?

Upvotes: 0

Views: 798

Answers (1)

Nicolas Lalev&#233;e
Nicolas Lalev&#233;e

Reputation: 2013

When adding a project as a dependency manually, you should also consider the order of the classpath entries. If the IvyDE classpath container is before the dependent project, then the resolved jars by Ivy will take precedence over the projects in Eclipse. If you move manually the project dependency to be upper than the IvyDE classpath container, then you should see the expected behavior.

Then regarding an even more simpler configuration, you can configure the IvyDE classpath container to lookup for dependencies directly in the workspace. Both of your projects should have their dependencies managed by Ivy in Eclipse. And then see "Resolve dependencies in workspace" in the settings of the IvyDE classpath container.

More info about that feature can be found in the doc: https://ant.apache.org/ivy/ivyde/history/latest-milestone/cpc/workspace.html

Upvotes: 1

Related Questions