
Setting up our environment
In order to start working with rules, there are a couple of things that we need to consider. First of all, we will be relying on Maven to provide the structure for our projects. I strongly recommend you read about Maven if you are not familiar with it as most of the Drools and jBPM infrastructure is nowadays aligned with Maven, therefore, you will feel much more comfortable when you know how it works. I recommend the following link from the Maven project website if you are completely new to the subject:
https://maven.apache.org/guides/getting-started/index.html
This is not a strong requirement for Drools; however, it is a recommended way to use it. Most of the integration with the project tooling and other modules relies on Maven serving as the standard for project structure and project life cycle and dependency management.
In order to get started, we need to make sure that we have the following software installed on our computer:
- Java 8 JDK, notice that Drools doesn't require JDK 8, yet all the book examples were created using that. To avoid problems with the examples, we recommend using this version.
- Maven 3.1.x or newer version to compile, test, and package our projects.
- GIT 1.9.x or newer version for source version control.
We will be using Git to get the project examples from our repository hosted on Bitbucket. If you are not familiar with Git, we recommend you to take a look at their official documentation at http://git-scm.com/docs.
In order to get a copy of the examples in our local environment, we will clone the remote repository by executing the following command in the terminal:
>git clone https://bitbucket.org/drools-6-developer-guide/drools6-dev-guide.git
Depending on the platform (operating system) that you are running, you can use a Git client to interact with the remote repositories. Feel free to look at the different alternatives for your operating system, here is a list provided by the Git project at http://git-scm.com/downloads/guis.
Now, you have a copy of all the examples of this book in your local environment. To make sure that everything is correctly set up, go to the drools6-dev-guide/
directory and run the following command:
> mvn clean install
This command tells Maven to clean all the previously compiled classes and packaged resources and remove them from our projects to start a fresh compilation process. In order to compile all the Java classes, Maven needs to make sure that it has all the third-party dependencies required by this projects. In our case, Drools is one of the third-party libraries that will need to be downloaded by Maven if we don't have it locally. However, this will not only compile the Java classes, but also run all the tests defined in the projects and package every project if, and only if, all the tests are successful.
This process of downloading, compiling, and running the tests might take some time the first time you run it in your local environment. This is mostly due to the initial downloads and unless you are using nightly builds (SNAPSHOTS), it should only happen the first time you run the command. Notice that the repository hosting the examples doesn't host any third-party libraries, not even Drools.
If you are behind a proxy, read the Maven guide to set up your proxy configurations at https://maven.apache.org/guides/mini/guide-proxies.html.
If this command ends with BUILD SUCCESS, we are good to go. It should look similar to the following:

Now, we know that the JDK and Maven are working correctly, we are ready to move forward and create our first Drools project.