Non-Java dependencies



Ivy is a generic dependency manager and can manipulate jars as well as any other kind of resources. IvyDE leverages this feature by bringing dependency management to non Java Eclipse projects.

In this document we will document how to work with IvyDE and non Java dependencies with a concrete exemple: we will manage the dependencies between some javascript files and bring them into a Java webapp.

Import the sample project into Eclipse

The full project sample can be downloaded from there. Unzip it somewhere and import it into Eclipse (see "Existing Projects into Workspace" in the "Import" menu).

The Eclipse project is already configured with an IvyDE classpath container so we can run the Java webapp. We will just have to add the retrieve of the javascript files.

Configure the non-Java dependencies

Configure the Ivy nature

In order to manage dependencies with Ivy, it is required for the Eclipse project to have the "Ivy" nature.

In the sample project, an Ivyde classpath container is already configured, so the Eclipse project already has the "Ivy" nature.

In case your project doesn't has it, right click on the project and in the menu "Configure" select "Add Ivy dependency management".

Add a retrieve setup

Now that the project has the Ivy nature, a new entry should have appeared in the properties of your project. This is where non Java dependencies are managed.

Now select "New..." to create a retrieve setup.

Name

It gives a human readable name to the retrieve setup. This name will be used later in the context menu to actually launch a retreive of the dependencies.
For the sample project, let's choose "javascripts".

Ivy file

The ivy file which declares the dependencies to retrieve.
For the sample project, we will use the same one has the one which is used for the Java dependencies (it is not required).

Retrieve pattern

It defines where the dependencies should be retrieved.
For the sample project we want them there: src/org/apache/ivyde/sample/webappjsrepo/js/[artifact]-[revision].[ext].

Delete old retrieved artifacts

Before doing a retrieve, the location where the dependencies are dowloaded will be wiped out is this option is selected.

Configurations

This is a comma separated list of configuration names which will be used for the resolve (* means All).
For the sample project, we want it to be js.

Types

This is a comma seperated list of type names which is be retrieved (* means All).
For the sample project, we want them all: *.

Now in the "Settings" tab, the setup entries are the same as the global ones. Click on "Enable project specific settings" to customize for your setup.

For the sample project, we want to use the ivysettings in the java project: ${workspace_loc:ivyde-sample-webapp-js-repo/ivysettings.xml}.

Finally, click OK to finish.

Launch a retrieve

Now that the retrieve is setup, a new entry should be available in the "Ivy" context menu. The menu entry should be "Retrieve 'xxx'" where "xxx" is the name you gave to the retrieve setup. For the sample project, it will be "Retrieve 'javascripts'".

Select the entry to actually launch the retrieve. The Eclipse project get automatically refreshed with the retrieved files. For the sample project look into src/org/apache/ivyde/sample/webappjsrepo/js/jquery-1.7.1.min.js.

Launch the sample webapp

To see the result, we'll launch the Java webapp and look it it your browser locally.

Right click the Java class org.apache.ivyde.sample.webappjsrepo.HTTPServer and select "Run As" / "Java Application".
Now open the web page http://localhost:8888/index.html
If working properly, the javascript files should have been properly loaded and the input field should have automatically been filled with a default value.


Printer Friendly