UsingEclipse - shark8me/lenskit GitHub Wiki
If you want to use LensKit from an Eclipse project, it's pretty easy
if your project uses Maven: just add LensKit as a dependency. You can
do this in the POM editor (edit your project's pom.xml
file), and
add lenskit-core
and whatever algorithm modules you need
(e.g. lenskit-knn
) as dependencies. It's similarly easy if you use
Gradle, Ant + Ivy, buildr, or some other Maven-compatible build tool,
though you may need to edit your build file manually.
If your project does not use Maven, you can download the
binary distribution and add the .jar
files it contains to your
project.
If you are working on Windows, you should probably consult Developing on Windows in addition to this document.
Developing LensKit in Eclipse
While most LensKit developers use IntelliJ IDEA, you can use Eclipse to develop LensKit itself. It's unfortunately a bit complicated to set up, though, especially if you want to run all the unit tests from within Eclipse.
Requirements
Working with the LensKit code in Eclipse requires the following plugins:
- egit (the Eclipse Git extensions, included in recent Eclipse downloads by default)
- M2e (the Maven plugin, included by default in recent Java-oriented Eclipse downloads)
- Groovy-Eclipse, also available from the marketplace. Hint: There are larger Groovy packages available in the marketplace, but the one called Groovy-Eclipse is sufficient for LensKit.
- Groovy-Eclipse M2E Integration. After installing Groovy-Eclipse from the Marketplace, this can be installed from the traditional software installer. Choose ‘Install New Software...’ from the ‘Help’ menu, select the GRECLIPSE site from the Software Sites drop-down, and install the ‘Groovy-Eclipse M2E Integration’. For some reason, this is not auto-detected by Eclipse.
We recommend using Eclipse Juno or later, as it includes M2e. You should be able to make earlier versions of Eclipse work, however, if you manually install M2e.
Importing the Source Code
There are several steps to importing the LensKit source code into Eclipse:
- Check out the LensKit source tree by selecting ‘File’ / ‘Import’ and choosing to clone an existing Git repository. Clone from http://github.com/grouplens/lenskit.git, or the URL of your fork of LensKit.
- Right-click the newly-imported ‘lenskit’ project and select ‘Configure’ / ‘Convert to Maven project’.
- Right-click the ‘lenskit’ project again, choose ‘Import’ / 'Maven'
/ ‘Existing Maven Projects’. It should auto-select the
pom.xml
files for all LensKit submodules; import them, and each of the LensKit modules should show up in the project explorer.
You may want to use a working set to group the LensKit projects together.
(Later, if additional submodules are added when you update your copy of the source, you can add them by repeating step (3); when you re-import existing Maven modules from the LensKit project, it will autoselect any projects that are in the directory tree but are not yet imported.)
After completing these steps, you should be ready to begin working on the LensKit code in Eclipse.
Setting Up Tests
The tests in lenskit-integration-tests
depend on the ML-100K
data set. Running the tests from Eclipse requires downloading a copy of the
dataset, and either putting an unzipped copy of it in the lenskit-integration-tests / data / ml-100k
folder (which you will have to create), or putting it somewhere else and setting an environment variable in the Eclipse run configuration to tell LensKit where you put it.
After that, you can run the integration tests any time you wish by using the built-in
Eclipse JUnit runner.
If you want to put the ml-100k dataset somewhere else, you will need to set the environment variable. To set the environment variable right click on lenskit-integration-tests, and choose 'Run As ...' / 'Run Configurations ...'. Create a new JUnit run configuration. Move to the Arguments tab. Under VM arguments add:
-Dlenskit.movielens.100k=ml-100k
Coding Style
The etc/eclipse-codestyle.xml
file contains an Eclipse code style
that will configure most of the LensKit style guidelines. See the
Code Guidelines for more details on our coding
style.
Various Notes
When you run Maven builds under Eclipse, you will likely see this error:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
This doesn't seem to cause any problems and can be ignored.
Eclipse and IntelliJ disagree about some uses of @SuppressWarnings. You can ask Eclipse not to nag you about uses of @SuppressWarnings that it considers unnecessary by following these directions.
Configuring Java and Maven
Most LensKit development will work fine without any additional Eclipse configuration. If you want to be able to run the full integration test suite, including the archetype tests (disabled by default), some additional configuration is required.
First, the integration tests must be run with an external Maven; they don't work with the embedded Maven included with Eclipse. Register your Maven installation (you may need to download Maven) under ‘Maven / Installations’ in the Eclipse settings manager.
Second, it must be run with a real JDK, not just a JRE. On Linux or
Mac, you likely already have one configured (hopefully). On Windows,
even if you have a JDK installed, Eclipse runs with the JRE. You need
to add your JDK to Eclipse's list of installed JREs (add the JDK root
directory, e.g. C:\Program Files\Java\jdk1.7.0_17
). Then run the
Maven build for the integration tests with this JRE and your external Maven.