DevOps / Gradle interview questions
1. 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.
2. 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 an...
3. 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 th...
4. 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 suppo...
5. What is the Gradle build script file name?
build.gradle.
6. 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.
7. How do you run Gradle build?
8. 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 .
9. 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.
10. 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.
11. 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.
12. 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 projec...
13. 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,...
14. 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.
15. How Gradle achieves faster performance?
Gradle improves build speed by reusing computations from previous builds and also uses cache information.
16. Difference between settings.gradle & gradle.properties.
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 ob...
17. List the gradle build configuration files.
build.gradle , script that defines the build configuration, gradle.properties, and settings.gradle .
18. 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 ...
19. What is the Gradle command to view the list of available projects?
Use gradle projects command.
20. 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 a...
21. 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.
22. 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.
23. What is Gradle build language?
Gradle provides a domain specific language (DSL) for describing builds. This build language is available in Groovy and Kotlin .
24. Default file name of the Groovy build script?
It is build.gradle . Kotlin DSL script files use the .gradle.kts file name extension.
25. 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 o...
26. 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.
27. 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' }
28. Difference between declaring repositories in the buildScript section of the Gradle build or in the root level of the build.
buildScript { repositories { mavenCentral() } } 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 { mavenCentral() } The repositories on the root level are used to fetc...
29. 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' implementatio...
30. What is the dependencyInsight task in Gradle?
Every Gradle project provides the task dependencyInsight to render the so-called dependency insight report from the command line. Given a dependency in the dependency graph, you can identify the selection reason and track down the origin of the dependency selection. You can think of the dependenc...
31. What are the Gradle build phases?
Initialization : Gradle supports single and multi-project builds. During the initialization phase, Gradle determines which projects are going to take part in the build, and creates a Project instance for each of these projects. Configuration : During this phase the project objects are configured....