You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2010/08/26 01:30:56 UTC

[Solr Wiki] Update of "HowToContribute" by ErickErickson

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "HowToContribute" page has been changed by ErickErickson.
The comment on this change is: Directed folks to Steven Rowe's patch for installing IntelliJ.
http://wiki.apache.org/solr/HowToContribute?action=diff&rev1=46&rev2=47

--------------------------------------------------

  Running SOLR in Eclipse:
  See: http://www.lucidimagination.com/developers/articles/setting-up-apache-solr-in-eclipse.
  
+ == IntelliJ (9.0.3) ==
+ There used to be a long, complex song-and-dance for doing this, but Steven Rowe did a really cool patch, see: [[https://issues.apache.org/jira/browse/LUCENE-2611|LUCENE-2611]]. Essentially, all you have to do is download the patch, run "ant idea", bring up IntelliJ and set the project-level java SDK. See the comments at the JIRA. I haven't tried to run SOLR after this setup, but since the previous version of these instructions didn't try either, it's no loss.
- == IntelliJ (Maia-IU-95.24) ==
- === Cheap, easy way to get basic functionality running ===
- In a word, cheat. Follow the instructions above to get the source code AND copy the Eclipse .project and .classpath files to the Lucene and SOLR directories. Yes, the Eclipse ones. But you do NOT need to open Eclipse or make any Eclipse projects, just have the .project and .classpath files in the right place.
  
+ This patch has not been committed yet, and there's no guarantee it will be. Even if it's not, though, applying this patch is so much easier than doing things by hand that it's worth the effort.
- Fire up IntelliJ and click "create new project>>import project from external model (Eclipse)" and click some "next" buttons until the new projects dialog appears. In the "Select Eclipse directory" textbox, navigate to ~/apache/trunk/lucene". I just let the defaults stay "Create module near .classpath files" Project File Format is ".idea (directory based). Now click through until you get to a "finish" button and wait a bit.
- 
- You should now be able to run tests by finding a test file, crtl-click (right click) on a test file and "run". IntelliJ seems to figure out that it's a junit test.
- 
- Note: Out of the box, testPorterStemFilter fails with the error "cannot find porterTestData.zip". Apparently, the test that calls for this file is looking for org/apache/lucne/analysis/porterTestData.zip and can't find it. You can solve this (and, I assume related issues) by specifying a "library" and clicking the "attach jar directories", then point it at ~/apache/trunk/lucene/src/test". Now make your module rely on the new library. 
- 
- Then I did the same thing for SOLR, *except* I created a new "module" rather than "project". The first JUnit test I ran worked perfectly.
- 
- IntelliJ seems to have Subversion support built-in, no real need to install a plugin.
- 
- I haven't tried to set up SOLR to run from within IntelliJ yet, if anyone has feel free to add the instructions.
- 
- === More flexible setup without using Eclipse .project files ===
- 
- This turns out not to be too bad, but tedious. Cheating by using the Eclipse files kinda works, but then you're stuck with all of the contrib packages, etc. Here's a general outline. I'll expand it if the dev list (which I (Erick Erickson) monitor) shows that there's enough interest... 
- 
- Instead of an "all at once" setup, I created a series of modules, for instance "lucene", "lucene_test" etc. You can group them any way you want (IntelliJ has a "Move Module to Group" option). So my structure looks like this:
- 
- {{{
-  Lucene
-  Lucene_test
-  contrib (group)
-    highlight
-    memory
-    queryparser
- }}}
- 
- After you've gotten the source code, you can set up various modules and create groups, moving things around by the context-menu choices. By and large, the trick is to then make each module dependent on other modules as needed, as well as on the main Lucene library in ~/apache/trunk/lucene/lib that contains the jars for junit, ant, etc.
- 
- So, first "create new module from existing source" for, say, Lucene. In this setup, I created it from the source at ~/apache/trunk/lucene/src/java This gives the starter kit. Then I created the "Lucene_Test" module, but now you have no choice to "create from source", instead you just choose "create module from scratch", but then navigate to the source at ~/apache/trunk/lucene/src/test. Set up a library to point to ~/apache/trunk/lucene/lib. Make both the modules depend on this library, and additionally make the Lucene_Test module depend on the Lucene module (see the "module settings>>dependencies" tab). You should now be able to get the test cases to run. See the note above about how to find resources, e.g. "porterTestData.zip". I haven't run all the tests from inside IntelliJ yet, but this should start things rolling.
- 
- That's about it for Lucene itself, but for the contrib modules it's almost as straight-forward. Go through the same "create module from scratch" and optionally move the new module to a group or sub-group. You can create a new module from the source at, say, ~/apache/trunk/lucene/contrib/queryparser. Resolve as above by making this module dependent upon other modules (in this case, Lucene and Lucene_test), and the "project library" at ~/apache/trunk/lucene/lib (note, you should have created this when you initially set up the original Lucene and Lucene_test modules).
- 
- NOTE: some contrib modules depend upon other contrib modules, so you may have to create several contrib modules to resolve all of these. Highlighter is a case in point.
- 
- Test should now run for the contrib module. One quirk I'm seeing is that bringing up the context menu for a contrib test directory wants to run the Lucene_Test tests. But going one level down and bringing up the context menu for, say, org.apache.lucene.queryParser runs the tests in that module.
- 
- As usual, the first time one does all this it's mysterious and often requires several false starts, but pretty soon it takes "just a few clicks of the mouse".
  
  === Installing code style ===
- To install the Lucene/SOLR codestyle files, get the IntelliJ codestyle file from this site and put it in the magic place so IntelliJ can find it. On my Mac that is in ~/Library/Preferences/IntelliJ90/codestyles and restart IntelliJ.
+ To install the Lucene/SOLR codestyle files, get the IntelliJ codestyle file from this site and put it in the magic place so IntelliJ can find it. On my Mac that is in ~/Library/Preferences/IntelliJ90/codestyles and restart IntelliJ. On a Windows7 box, this magic directory was in /Users/<username>/.IntellijIdea90/config/codestyles.
  
  Now click on the "Settings" icon (the little in the toolbar) and click "codestyle". You should see the new code style configuration in the select box. NOTE: the name in the select box is the name from the <code_scheme....> tag in the xml file. It is NOT the name you put on the file, which can be a bit confusing..