Launching Solr from Maven for rapid development

If you are developing on top of Apache Solr, you might consider integration Solr with your maven build, by launching it from the maven-jetty-plugin. This brings several advantages, such as the possibility to shorten the time to get started in the project, unify the dev environment of the team with a fixed Solr version, do automated integration tests by launching and stopping Solr in the pre/post integration-test phase of the lifecycle and also creation of a single WAR contained the standard Solr with the custom plugins and configuration.

Here’s a way to do it:

1) Since solr.war is not yet available on public maven repo (SOLR-1218) make sure you deploy the solr.war file in any of your maven repo. In this post I’ll assume that solr.war is found inder org.apache.solr:solr-webapp:1.4.0 of you maven repo.

2) Use the maven webapp archetype to create an empty web project:

mvn archetype:generate

choose the maven-archetype-webapp option.

3) Change the pom.xml to:

<project xmlns="" xmlns:xsi=""
  <name>ubersearch Maven Webapp</name>

4) Copy the solr config files in the folder src/main/resources of the project. This will allow you to change them especifically for your project

$ ls src/main/resources/
elevate.xml            protwords.txt            solrconfig.xml            stopwords.txt
mapping-ISOLatin1Accent.txt    schema.xml            spellings.txt            synonyms.txt

5) Copy solr’s standard web.xml to the src/main/webapp/WEB-INF/ folder

6) Launch solr by calling the jetty plugin:

mvn jetty:run-exploded

7) Access Solr at http://localhost:8080/<artifactId>/admin/