Help the world stop coronavirus! Stay home!

Prev Next

Maven / Gradle interview questions

Could not find what you were looking for? send us the question and we would be happy to answer your question.

What is Gradle framework?

Gradle is an open source build automation system that builds based on the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration.

Advantages of using Gradle.

Gradle combines both Ant and Maven, taking the best from both of these frameworks; Flexibility from Ant tool and convention over configuration, dependency management and plugins from Maven.

Gradle provides support for multi-project builds.

It allows to use existing Maven/Ivy repositories.

Free and open source.

Scalable nature.

What is Gradle wrapper?

A wrapper is a batch script and it is one of the ways to perform Gradle build. When executed the first time, it automatically downloads Gradle and then initiate the build.

It helps to setup Gradle workspace quickly for first-time users (Zero installation) and also ensure all the developers use the same version of Gradle.

Why Gradle is preferred over other build tools?

Gradle build script is written using groovy API which has the syntax similar to Java so it is easy to understand.

Gradle supports ant tasks, ivy and Maven repositories for dependency management. It also has a maven Pom.xml converter to Gradle build script.

It is open source.

provides strong support for multi project builds.

supports build cache.

What is the Gradle build script file name?


What is the latest version of Gradle available in the market?

Gradle build tool latest version is 3.5 as of May 2017. The version on your local Gradle installation can be checked using gradle -v command.

How do you run Gradle build?

Execute Gradle build using gradle command.

What are the core components of Gradle build script?

Project and task are the core compoents. Groovy organizes projects as a list of tasks.

To view the list of available projects, use the command gradle projects, for the tasks list the command is gradle tasks.

How do you find Gradle project dependencies?

Use the Gradle command gradle dependencies that lists the dependencies of the selected project. It includes both direct and transitive dependencies.

The main difference between Maven build.xml and Build.gradle script.

Maven build.xml is xml document that includes start and end tags. Build.gradle is a Groovy script which has syntax similar to Java.

How do I force Gradle to download dependencies always?

you may refresh dependencies in your cache using the command line option --refresh-dependencies. Also deleting the cached files under ~/.gradle/caches would get the next Gradle build to download them again.

What is Gradle project and task?

Every Gradle build is made up of one or more projects. What a project represents depends on what it is that you are doing with Gradle. For example, a project might represent a library JAR or a web application. It might represent a distribution ZIP assembled from the JARs produced by other projects. A project does not necessarily represent a thing to be built. It might represent a thing to be done, such as deploying your application to staging or production environments. Don't worry if this seems a little vague for now. Gradle's build-by-convention support adds a more concrete definition of what a project is.

Each project is made up of one or more tasks. A task represents some atomic piece of work which a build performs. This might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository.

Create a Gradle task and explain how to execute it.

The Gradle build file defines the project and its tasks. The below list a simple task to print "Hello world!".

task hello {
    doLast {
        println 'Hello World!'

Run Gradle hello on the command line in the directory of the build file to execute hello task. If the Gradle output should be suppressed, use the -q (quiet) parameter.

gradle hello

What is Gradle Daemon?

The Daemon is a long-lived process that helps with the faster build process, by avoiding the cost of JVM startup for every build and also caches information about project structure, files, tasks, and more in memory.

How Gradle achieves faster performance?

Gradle improves build speed by reusing computations from previous builds and also uses cache information.

Difference between settings.gradle &

The settings.gradle is a Groovy script that defines build related settings and not project related. It is evaluated against a Settings object and with this Settings object, you can add sub projects to your build, modify the parameter from the command line (StartParameter) and access the Gradle object to register lifecycle handlers.

The file is a simple Java Properties file. It's a simple key-value store, that only allows string values.

List the gradle build configuration files.
  • build.gradle, script that defines the build configuration,
  • and settings.gradle.
How do I add gradle dependencies?

To add a dependency to your project, specify a dependency configuration such as compile under the dependencies block of your build.gradle file.

dependencies {
   compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
   testCompile group: 'junit', name: 'junit', version: '4.+'
What is the Gradle command to view the list of available projects?

Use gradle projects command.

Types of plugin in Gradle.

There are 2 general types of plugins in Gradle, script plugins and binary plugins.

Script plugins are additional build scripts that further configure the build and usually implement a declarative approach to manipulating the build.

Binary plugins are classes that implement the Plugin interface and adopt a programmatic approach to manipulating the build.

In which programming language should one develop plugins for Gradle?

One can develop plugins for Gradle in any JVM language such as Java, Scala etc.

Explain spring boot gradle plugin.

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle, allowing you to package executable jar or war, execute Spring Boot applications, and use the dependency management provided by spring-boot-dependencies.

What is Gradle build language?

Gradle provides a domain specific language (DSL) for describing builds. This build language is available in Groovy and Kotlin.

Default file name of the Groovy build script?

It is build.gradle. Kotlin DSL script files use the .gradle.kts file name extension.

What are allprojects and subprojects sections in Gradle build file.

A multi-project gradle build will have rootProject and the subprojects, both together is considered as allprojects. The build starts from rootProject however it usually has no code, subproject does. allproject section can have dependencies seen by all projects while subproject dependencies seen only by those sub projects.

Usually subproject only apply Java plugin as it got code.

subprojects {
    apply plugin: 'java'

How do I find the Gradle version?

Open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version as shown in the below picture.

What are the features are Spring Boot Gradle Plugin?

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It collects all the jars on the classpath and builds a single, runnable jar, which makes it more convenient to execute and transport your service.

plugins {
	id 'org.springframework.boot' version '2.2.1.RELEASE'
Difference between declaring repositories in the buildScript section of the Gradle build or in the root level of the build.
buildScript {
    repositories {

The repositories in the buildScript block are used to fetch the dependencies of your buildScript dependencies. For example, your plugin dependencies are listed here.

repositories {

The repositories on the root level are used to fetch the dependencies that your project depends on. So all the dependencies you need to compile your project.

Difference between api and implementation in Gradle.

The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.

dependencies {
    api 'org.apache.httpcomponents:httpclient:4.5.7'
    implementation 'org.apache.commons:commons-lang3:3.5'

Dependencies appearing in the "api" configurations will be transitively exposed to consumers of the library, and as such will appear on the compile classpath of consumers. Dependencies found in the "implementation" configuration will, on the other hand, not be exposed to consumers, and therefore not leak into the consumers' compile classpath.

GIT Interview Questions

Comments & Discussions