Eclipse (Galileo, J2EE version 18.104.22.16800217-2310, but any relatively recent Eclipse should do):
Checkout the trunk with subclipse (location: https://svn.apache.org/repos/asf/lucene/dev/trunk), then run 'ant eclipse' and refresh your project.
If you don't have a project yet to refresh, click File>>New>>Java Project. Uncheck "use default location", and navigate to "solr home" and just open that. It'll churn for a while, but it'll get there in the end. At that point you should be able to right-click on one of the test cases and run a Junit test, but see the "-ea" notes below.
First, start up your server (here I'm using the default Jetty server) and start it with these options:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7666 -jar start.jar
"address" is the port you're going to attach to, the port you use is arbitrary. Now, in Eclipse hit the little down arrow next to the cute little bug icon and then "debug configurations>>remote java applications" and click the "new" icon in the upper left. Name your project and put the port in that corresponds to the "address" above.
You should now be able to set breakpoints etc. when you run this configuration.
Enabling Assertions for unit tests in Eclipse
By default, Eclipse does not run test with assertions enabled. This causes some tests to run incorrectly in Eclipse and excludes some checks in the source code.
Change this by checking the box "Add '-ea' to VM arguments when creating a new JUnit launch configuration".
This checkbox is available under Windows>Preferences>Java>JUnit
- Under some conditions, I've seen this process have thousands of compile errors, something like "class XXX defined in multiple places". This went away when I highlighted the project and clicked "refresh".
Think about installing the subclipse plugin, it'll allow you to update your source from within Eclipse. See: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA
- You can create patches for the committers to apply from within the IDE easily.
- By and large, you won't "run" a Lucene program, you'll really run unit tests. (Others, please chime in here!!!). The general development cycle for Lucene is to add functionality, add unit tests, make sure all unit tests run and check in (actually, submit a patch to check in, preferably attached to a JIRA issue). There's no "program" that you start up in your IDE to test changes, just use unit tests.
Running SOLR in Eclipse, Solr-1.4 Sept. 2009, see: http://lucidworks.com/blog/setting-up-apache-solr-in-eclipse/