Gradle with Eclipse

Gradle Inc. provides the Gradle tools and plugins for the Eclipse IDE. This tool allows you to create and import Gradle enabled projects into the Eclipse IDE. In addition, it allows you to run Gradle tasks and monitor the execution of the tasks.

The Eclipse project itself is called Buildship. The source code of this project is available on GitHub at https://github.com/eclipse/Buildship.

There are two options for installing Gradle plugins on Eclipse. These are as follows:

  • Via the Eclipse Marketplace
  • Via the Eclipse Update Manager

First, let's see how to install Buildship plugins for Grade build on Eclipse using Marketplace: Eclipse | Help | Eclipse Marketplace:

Figure 6: Installing Buildship plugins for Grade build on Eclipse using Marketplace

The second option for installing the Gradle plugins on Eclipse is from the Help | Install New Software... menu path to install the Gradle tooling as shown in the following figure:

Figure 7: Installing Buildship plugins for Grade build on Eclipse using install new software
For example, the following URL can be used for Eclipse 4.6 (Neon) release: http://download.eclipse.org/releases/neon.

Once you have installed the Gradle plugins by following any one of the methods described earlier, Eclipse Gradle helps you to set up Scala based Gradle projects: File | New | Project | Select a wizard | Gradle | Gradle Project.

Figure 8: Creating a Gradle project on Eclipse

Now, if you press Next>, you will get the following wizard to specify the name of the project for your purpose:

Figure 9: Creating a Gradle project on Eclipse specifying the project name

Finally, press the Finish button to create the project. Pressing the Finish button essentially triggers the Gradle init --type java-library command and imports the project. However, if you would like to get a preview of the configuration before the it is created, press Next > to get the following wizard:

Figure 10: Preview of the configuration before it is created

Finally, you will see the following project structure on Eclipse. However, we will see how to build Spark applications using Maven, SBT, and Gradle in a later chapter. The reason is that, before starting your project, it is more important to learn Scala and Spark together.

Figure 11: The project structure on Eclipse using Gradle

In this section, we have seen three build systems, including SBT, Maven, and Gradle. However, throughout the chapters, I will try to mainly use Maven because of its simplicity and better code compatibility. However, in later chapters, we will use SBT to create JARS from your Spark application.

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

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