Saturday, January 4, 2014

Setting up a Solr dev environment

While I'm waiting for my next class to begin, I wanted to contribute some Solr code.  I take so much from that project so it's only fair...

I use IntelliJ, SVN, and Maven for my non-Android development - Lucene/Solr has an SVN repo and it looks like some people use IntelliJ but the project seems to favor Ant over Maven but when looking through the Ant commands, there are hooks into Maven.  Haven't had a chance to explore that much yet.

I run Mountain Lion so this is Mac OS X specific.

  1. Checked out source:

    svn co http://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x branch_4x

    Edit: Most development should occur in trunk.  It'll get backported to the 4x branch as required.
  2. Ran "ant idea" to generate the IntelliJ artifacts from branch_4x/ but got an error:

    "branch_4x/lucene/common-build.xml:411: Ivy is not available"

    No worries, downloaded Apache Ivy and put the jar where the docs said to:

    sudo cp ~/Downloads/apache-ivy-2.3.0/ivy-2.3.0.jar /usr/share/ant/lib/
  3. "ant idea" works now - took almost 8 mins probably due to my slow connection.
  4. In IntelliJ 12 I ran "Open Project" on branch_4x/.  Included at the end of "ant idea" are instructions to set up the project.  I elected to create branch_4x/lucene/build.properties and included:

    idea.jdk = project-jdk-name="1.6" project-jdk-type="JavaSDK"

    Though it looks like we should be running Java 7?  We'll see.

    Edit: trunk is Java 7, branch_4x is Java 6.
  5. So here's where it got a little tricky and it's mostly my fault for not reading carefully.  Ran "ant example" from branch_4x/solr/.
  6. Setup remote debugging in IntelliJ by creating a remote configuration.  I took the docs recommendation of localhost:5900.  Take the command line string and from branch_4x/solr/example ran:

    java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5900 -jar start.jar

    I resisted using example/start.jar because I didn't want to use the example, I wanted to use my stuff!  That wasn't the case, duh.
  7. From IntelliJ, debug the remote configuration that was just made.  Browsed to localhost:8983 in a browser and it looked good.

    Edit: You'll need to install Python3 as well to get "ant precommit" to complete successfully.

No comments:

Post a Comment