Book Image

Infinispan data grid platform definitive guide

Book Image

Infinispan data grid platform definitive guide

Overview of this book

Table of Contents (20 chapters)
Infinispan Data Grid Platform Definitive Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Building Infinispan from source


Infinispan uses Maven as a build tool. The following steps describe the sequence of tasks to build Infinispan from the source code:

  1. You will need a copy of the Infinispan sources, which can be downloaded from Github, but it's important to note that the git version of Infinispan might contain unreleased and unstable changes, it's intended for developers and contributors.

  2. To get the source from Github, first of all, you must have a git client to clone the repository. To clone the Infinispan from Github, you can execute the following command:

    git clone https://github.com/infinispan/infinispan.git
    
  3. If everything went well, you should see a new folder called Infinispan with the following folder structure:

  4. But first, since Infinispan is a very big multi-modular project, we will probably run into an OutOfMemoryError exception when building it. To prevent the error, we must instruct Maven to use more memory by setting the MAVEN_OPTS environment variable to increase the memory of the JVM executing the following command:

    export MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=128m'
    
  5. On Windows, use:

    set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
    
  6. Now, we can finally build Infinispan using the following command:

    mvn clean package install -DskipTests
    

This command will first clean out any old build and binary and then it will package the module as a JAR file, and insert them into the target folder.

The DskipTests parameter will prevent the unit tests from being run and finally, the install command installs the artifacts in your local repo for use by other projects/modules, including inter-module dependencies within the same project.

The next step is to open the source code with your preferred IDE that provides basic support to Apache Maven such as Eclipse, IntelliJ IDEA, and Netbeans.

Here, we are going to present how to setup IntelliJ IDEA.

Setting up the environment

Assuming that you have downloaded and compiled the source code, let's import the Infinispan project to IntelliJ IDE. Perform the following steps:

  1. If no project is currently open in your IntelliJ (I'm using IntelliJ IDEA 14.0.3), click on Import Project and change the directory to the location where you cloned Infinispan.

  2. Automatically, IntelliJ will detect the pom.xml file in the infinispan root folder and import the Maven project. Select all the projects you want to import and press Next.

  3. At the end of the import process, IntelliJ will open all projects, as you can see in the following image:

  4. Before starting to code, on IntelliJ, you will need to set up a specific feature introduced in Infinispan 5, which uses annotation processing as part of the compilation, to allow log messages to be internationalized. To change IntelliJ, open the Preferences window and go to Compiler | Annotation Processor and select the Enable annotation processing option. In the Annotation Processors option, add a new Processor FQ Name by pressing the plus button and insert org.jboss.logging.LoggingToolsProcessor.

  5. Infinispan also requires the IntelliJ Scala plugin to work. To install the plugin, open the Preferences window, go the Plugins option, and click in the Browse Repositories button. In the Browse Repositories pane, search for the Scala plugin and click on Install plugin.

  6. You will need to restart the IDE for the plugin installation to take effect.

    Tip

    You can also download the code style file used by the Infinispan team and import it into IntelliJ IDEA. To download the JAR file, click on the following link:

    https://github.com/infinispan/infinispan/blob/master/ide-settings/intellij/IntelliJ_IDEA_Code_Style.jar?raw=true