Using Maven for development

If you want to look at the code and modify it for starting your own implementation, you can look at the code in /SolrStarterBook/projects/solr-maven/solr-plugins-scala.

Tip

Maven is one of the best known solutions for automating the build process and to resolve dependencies at the moment. It can be used with Java and any other JVM language. We can have a module containing a self-running Solr installation to test the software components we are developing in another module. This approach is well covered in the excellent proof of concept by Petri Kainulainen at http://www.petrikainulainen.net/programming/maven/running-solr-with-maven/. The examples provided are inspired by it and adapted to our needs. If you are not yet familiar with Maven, please start by reading how to install it: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html.

The Solr-Maven folder contains a Maven project for our code, organized for convenience in separated modules. In particular, the parent project includes the following modules:

  • solr-maven/webapp: This is the module for running a Solr instance with Maven
  • solr-maven/solr-plugins-java: This is a module containing example Java code
  • solr-maven/solr-plugins-scala: This is a module containing example Scala code

We can have a Solr instance running using a pair of Maven commands.

In order to build an entire Maven project (also installing copies of an artifact into the local repository for our dependencies), the following command is used vey commonly:

>> mvn package install

In our case, we execute this command from the parent folder. But, we can also execute it only for a certain module from its own folder. Another useful option is adding the clean directive on the Maven command, so that every artifact will be deleted and rebuilt from scratch. This can be useful during development.

In order to start the Solr instance included in the webapp module, we can also use the following command from the webapp module folder:

>> mvn jetty:run -Dsolr.solr.home=solr-app

In the preceding command, solr-app will be the directory containing the configuration to be used (in this case, a relative path inside the project). Feel free to use the provided examples as a base for your own experimentations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.38.14