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 example: we will manage the dependencies between some JavaScript files and bring them into a Java webapp.
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.
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".
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.
It gives a human readable name to the retrieve setup. This name will be used later in the context menu to actually launch a retrieve of the dependencies. For the sample project, let’s choose "javascripts".
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).
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]
.
Before doing a retrieve, the location where the dependencies are downloaded will be wiped out is this option is selected.
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
.
This is a comma separated 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 Ivy settings in the Java project: ${workspace_loc:ivyde-sample-webapp-js-repo/ivysettings.xml}
.
Finally, click OK to finish.
Now that the retrieve is set up, 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 gets 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
.
To see the result, we’ll launch the Java webapp and look at it in 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 loaded and the input field should have automatically been filled with a default value.