Gradle Flashcards

Learn gradle for interview

1
Q

What is Gradle and how does it fit into the context of a Developer Productivity Engineer at Starling?

A

Gradle is a build automation tool that is widely used for Java projects. As a Developer Productivity Engineer at Starling, understanding Gradle is essential as it plays a crucial role in managing the build process and dependencies of the local development environment used by engineers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can you explain the basic structure of a Gradle build file?

A

A Gradle build file typically consists of a set of tasks and dependencies defined in a Groovy or Kotlin DSL. It includes sections for configuring plugins, defining dependencies, and specifying tasks to be executed during the build process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you define dependencies in a Gradle build file?

A

A Gradle build file typically consists of a set of tasks and dependencies defined in a Groovy or Kotlin DSL. It includes sections for configuring plugins, defining dependencies, and specifying tasks to be executed during the build process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of the repositories block in a Gradle build file?

A

The repositories block in a Gradle build file is used to specify the locations from which Gradle should retrieve dependencies. These repositories can be local directories, remote Maven or Ivy repositories, or other sources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Gradle handle transitive dependencies?

A

Gradle automatically resolves and includes transitive dependencies, which are dependencies required by other dependencies. This helps simplify dependency management by allowing you to declare only direct dependencies in your build file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Gradle plugins, and how are they used?

A

Gradle plugins are reusable pieces of functionality that can be applied to a project to extend or customize its build process. They are typically configured in the plugins block of the build file and provide additional tasks, conventions, or behaviors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you create custom tasks in Gradle?

A

Custom tasks in Gradle are defined by extending the org.gradle.api.DefaultTask class and implementing the desired functionality. These tasks can then be configured and added to the build process like built-in tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the gradle.properties file?

A

The gradle.properties file allows you to define project-wide properties and configuration settings for Gradle builds. These properties can be referenced in the build script to parameterize tasks and settings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does Gradle handle incremental builds?

A

Gradle optimizes build times by performing incremental builds, which means it only executes tasks that have changed inputs or outputs since the last build. This helps speed up the build process, especially for large projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between compile, implementation, and api dependencies in Gradle?

A

in earlier versions of Gradle, compile was used to include dependencies for both compiling and runtime, implementation is used for dependencies that should be internal to the module, and api is used for dependencies that are exposed to consumers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you exclude certain transitive dependencies in Gradle?

A

You can exclude transitive dependencies by using the exclude keyword within the dependency declaration. This allows you to specify specific dependencies to be excluded from the resolution process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Gradle wrapper, and why is it useful?

A

The Gradle wrapper is a script (gradlew or gradlew.bat) that allows you to run Gradle builds without requiring a local installation of Gradle. It ensures that the correct version of Gradle is used for the project, making builds more reproducible and consistent across environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how can you configure multiple build flavors or variants in Gradle?

A

Gradle allows you to define product flavors and build variants using the android or java plugin. This enables you to create different versions of your application or library with varying configurations or features.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of the settings.gradle file in a Gradle project?

A

The settings.gradle file is used to configure settings for a Gradle multi-project build. It specifies the structure of the project hierarchy and defines which subprojects are included in the build.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you profile and optimize Gradle builds for performance?

A

Gradle provides tools like the –profile option and build scans to analyze and optimize build performance. Techniques such as parallel execution, caching, and dependency optimization can be applied to improve build times.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does Gradle integrate with Continuous Integration (CI) systems like TeamCity?

A

Gradle builds can be executed as part of CI pipelines using tools like TeamCity. Gradle provides plugins and integration points to facilitate this, allowing you to automate the build, test, and deployment process.

17
Q

Can you explain the concept of build caching in Gradle?

A

Build caching in Gradle improves build performance by caching task outputs and reusing them in subsequent builds. This reduces the need to re-execute tasks that produce the same outputs, resulting in faster build times.

18
Q
A