All the dependencies of your projects are managed using Nuxeo IDE.
Nuxeo SDK Classpath
A Nuxeo SDK is necessary to create a Nuxeo project. A Nuxeo SDK is a Nuxeo-based Tomcat distribution (5.5 or more recent) of Nuxeo on which you will deploy your customizations. It provides the classpath for your projects.
You can install several Nuxeo SDKs for your different projects. For instance, you can use a Nuxeo CAP SDK for one project, a Nuxeo CMF SDK for another, etc. However you can use only one SDK at a time in an Eclipse workspace.
Nuxeo SDK are installed from the Eclipse preferences. This is also where you select the Nuxeo SDK to use in the workspace.
To install a Nuxeo SDK:
- UNzip the downloaded Nuxeo Platform distribution.
- In the Nuxeo SDK preference page (Eclipse Menu -> Window -> Preferences -> Nuxeo -> Nuxeo SDK), click on Add....
- Select the directory where you unzipped your Nuxeo distribution.
Be sure to select the right directory: the one containing the
- Check the added Nuxeo SDK and click on the OK button to finish. Checking the box at the left of the SDK is required to mark it as the current Nuxeo SDK used in the Eclipse Workspace.
As you develop your new features, you may want to use external libraries that are not provided by the Nuxeo SDK. In that case you can add new JARs to the project's classpath by declaring custom User Libraries. You can easily do so by using the Eclipse preferences:
- Open Eclipse preferences and go to Nuxeo.
- Click on User Libraries.
- Click on the Add button and select the library's JAR on your computer. The JAR is added in the libraries list. The library's metadata should be automatically filled in. If not, fill them in, as they they are required to deploy your project correctly.
- Click on the Apply button. The library's classes are now available in Eclipse and you can use them.
As we will see in the next section, Nuxeo IDE provides a mean to automatically update the POM with the project dependencies. This also includes any user library you declared.
You must fill the user library metadata (the Maven GAV information) otherwise synchronizing the POM will ignore your additional library.
As you develop your customizations, you add new dependencies. All the dependencies are listed in the
pom.xml file. Usually, you need to update your
pom.xml manually and might forget a dependency, which will make your project build fail.
Nuxeo IDE provides a way to update your
pom.xml file with the new dependencies. Before deploying your project, you can synchronize your project's
pom.xml file. Then, Nuxeo IDE scans your project with all undeclared dependencies and adds them to the POM.
To synchronize your project's POM:
- Right-click on the
pom.xmlfile file then click on Nuxeo > Synchronize POM.
- You will be prompted to select the artifacts you want to add to the
pom.xmlfile. The missing artifacts are discovered by the Nuxeo IDE by scanning the sources of your project, and finding any class that you reference and that is not yet in the POM.
- Click Finish. Then look again at the pom.xml file. Now you have your dependency there.
Attaching Sources for Project Dependencies
You may surely want at some point to be able to browse the sources of the dependencies used by your project. This is useful when you need to understand the code or if you want to put breakpoints in the code outside your project. As we've seen the project dependencies are either the ones provided by the current Nuxeo SDK, or the ones you explicitly added as user libraries.
In order to do this, you must download the sources (if they are not yet already present in the Nuxeo SDK) and attach it to the corresponding JAR from the project classpath. You can do that by using the Nuxeo SDK classpath properties dialog as follows:
- Right-click on the Nuxeo SDK entry in your project tree and then click on Properties to open the Nuxeo SDK classpath properties dialog.
- Select the JAR for which you want to attach sources. You can use the filter text box to quickly find the JAR by name.
Click on Download. Sources are downloaded from Nuxeo Maven repositories. This means, the dependencies must have a correct Maven GAV information (in case the JAR is a user library).
For now, only Nuxeo Maven repositories are scanned for sources.
In the case the dependency is not located in a Maven repository known by Nuxeo IDE, you can add sources by simply copying the corresponding source JAR from Maven to
NuxeoSDK/sdk/sourcesdirectory (where "NuxeoSDK" is the install directory of the Nuxeo SDK). Then you need to reload the SDK by removing and adding it again in Nuxeo SDK preferences page.