22 December 2020

#Gradle

#Gradle

Key Concepts


Topic Sub-Topics Basic Intermediate Advanced Expert
Introduction to Gradle What is Gradle, History of Gradle, Maven vs Gradle, Ant vs Gradle, Advantages
Gradle Build Lifecycle Tasks, Phases, Execution Model, Incremental Build, Task Dependencies
Gradle Wrapper What is Wrapper, Creating Wrapper, Using Wrapper, Advantages of Wrapper
Gradle Build Scripts build.gradle, settings.gradle, init.gradle, Script Blocks, Plugins
Gradle Plugins Core Plugins, Java Plugin, Application Plugin, War Plugin, Custom Plugins
Dependency Management Repositories (MavenCentral, JCenter, Ivy), Dependency Configurations, Exclusions
Gradle Tasks Defining Tasks, Default Tasks, Task Graph, Task Ordering, Custom Task Types
Multi-Project Builds Settings.gradle for Multi-Projects, Subprojects, Dependency Between Projects
Gradle DSL Groovy DSL, Kotlin DSL, Differences, When to Use
Custom Plugins Writing Custom Plugins, Applying Custom Plugins, Publishing Plugins
Gradle Performance Build Cache, Parallel Builds, Configuration On Demand, Daemon, Profiling
Gradle with Java Projects Java Plugin, SourceSets, Test Configuration, JAR Tasks, Application Plugin
Gradle with Web Projects War Plugin, Ear Plugin, Spring Boot Plugin, Web Dependency Management
Gradle and Testing JUnit/TestNG Integration, Test Logging, Test Filtering, Code Coverage (Jacoco)
Gradle and CI/CD Integration with Jenkins, GitHub Actions, GitLab CI, Docker, Kubernetes
Gradle Publishing Publishing to Maven Repository, Ivy Repository, Artifactory, Nexus
Gradle Advanced Scripting Custom DSL Extensions, Script Reuse, Convention Plugins, BuildSrc
Gradle API & Internals Gradle API Overview, Task API, Project API, Configuration API
Gradle Troubleshooting Debugging Builds, Logging, Stacktraces, Common Errors
Gradle Best Practices Build Optimization, Dependency Locking, Version Catalogs, Modularization

Interview question

1. Introduction to Gradle

  1. What is Gradle, and why is it used?
  2. How is Gradle different from Maven and Ant?
  3. Explain the advantages of Gradle over other build tools.
  4. What languages can be used for writing Gradle build scripts?
  5. What is the role of Groovy in Gradle?
  6. Can Gradle build scripts be written in Kotlin?
  7. What is the significance of build.gradle file?
  8. Explain the difference between build.gradle and settings.gradle.
  9. What is the init.gradle file used for?
  10. How do you execute a Gradle build?
  11. Explain the default tasks in Gradle.
  12. What is Gradle?s daemon, and why is it used?
  13. How does Gradle provide incremental builds?
  14. What are the limitations of Gradle?
  15. How does Gradle manage backward compatibility?
  16. What is a Gradle script block?
  17. What is Gradle?s execution model?
  18. How does Gradle support polyglot builds?
  19. What is the role of the Gradle Tooling API?
  20. Can Gradle be used without installing it manually?

2. Gradle Build Lifecycle

  1. What are the three main phases of the Gradle build lifecycle?
  2. Explain the initialization phase in Gradle.
  3. What happens during the configuration phase?
  4. What is executed in the execution phase?
  5. What are Gradle tasks?
  6. How can you list all available tasks in a Gradle project?
  7. What is a task dependency in Gradle?
  8. How do you define a custom task in Gradle?
  9. Explain the difference between dependsOn and mustRunAfter.
  10. How do you define default tasks in Gradle?
  11. What are up-to-date checks in Gradle?
  12. How do you skip tasks in Gradle?
  13. Explain task ordering in Gradle.
  14. What is the purpose of the finalizedBy keyword?
  15. How can you configure a task dynamically?
  16. What is the difference between task graph and task execution?
  17. How can you run multiple tasks in Gradle?
  18. What is the use of gradle.projectsEvaluated hook?
  19. How do you create incremental tasks in Gradle?
  20. What is task avoidance API in Gradle?

3. Gradle Wrapper

  1. What is the Gradle Wrapper?
  2. What are the advantages of using the Gradle Wrapper?
  3. How do you generate a Gradle Wrapper?
  4. What files are created when you run gradle wrapper?
  5. What is the role of gradlew and gradlew.bat files?
  6. How does the Gradle Wrapper download the required distribution?
  7. Can the Gradle Wrapper work offline?
  8. How do you upgrade Gradle using the Wrapper?
  9. What is the difference between gradle and ./gradlew?
  10. How do you ensure all team members use the same Gradle version?
  11. How does the Wrapper handle different Gradle versions?
  12. Where is the Gradle distribution downloaded?
  13. How can you verify the Gradle Wrapper version?
  14. Can you customize the Wrapper properties?
  15. What is the gradle-wrapper.jar file?
  16. What happens if the wrapper JAR is missing?
  17. How do you regenerate the wrapper JAR file?
  18. Can you define a custom Gradle distribution URL?
  19. Is it recommended to commit Gradle Wrapper files to VCS?
  20. What are common issues faced with Gradle Wrapper?

4. Dependency Management

  1. What is dependency management in Gradle?
  2. What are repositories in Gradle?
  3. Difference between mavenCentral(), jcenter(), and google()?
  4. How do you declare dependencies in Gradle?
  5. What are dependency configurations?
  6. Explain implementation, api, compileOnly, runtimeOnly.
  7. What is transitive dependency in Gradle?
  8. How do you exclude a transitive dependency?
  9. How do you define project dependencies in Gradle?
  10. What is dependency resolution strategy?
  11. How do you check all dependencies in a Gradle project?
  12. What is dependency conflict resolution in Gradle?
  13. How do you force a specific dependency version?
  14. What is the difference between dynamic and fixed versions?
  15. How does Gradle handle version ranges?
  16. What is dependency locking in Gradle?
  17. How can you manage external vs local dependencies?
  18. How do you configure custom repositories in Gradle?
  19. What is a flatDir repository in Gradle?
  20. How do you troubleshoot dependency resolution errors?

5. Gradle Plugins

  1. What are plugins in Gradle?
  2. Difference between core, community, and custom plugins?
  3. How do you apply a plugin in Gradle?
  4. What is the Java plugin in Gradle?
  5. What does the Application plugin do?
  6. Explain the War plugin in Gradle.
  7. What is the difference between apply plugin: and plugins {} block?
  8. How do you create a custom plugin in Gradle?
  9. What is the purpose of the buildSrc directory?
  10. How do you apply plugins across multiple projects?
  11. What is a convention plugin?
  12. What are script plugins?
  13. How do you publish a custom Gradle plugin?
  14. What is the gradlePlugin DSL?
  15. What is a binary plugin?
  16. Difference between id plugin syntax and legacy plugin application?
  17. How do you apply external plugins?
  18. How do you check which plugins are applied?
  19. What is the role of extensions in plugins?
  20. How do you debug plugin application issues?

6. Multi-Project Builds

  1. What is a multi-project build in Gradle?
  2. What is the role of settings.gradle in multi-project builds?
  3. How do you define subprojects in Gradle?
  4. How do you configure common settings across subprojects?
  5. What is the allprojects block?
  6. What is the subprojects block?
  7. Difference between project dependency and external dependency?
  8. How do you create project dependencies in multi-project builds?
  9. What is the difference between flat and hierarchical project structures?
  10. How do you run a task only for a specific subproject?
  11. How do you build all subprojects in Gradle?
  12. How do you exclude a subproject from the build?
  13. What is composite build in Gradle?
  14. Difference between multi-project and composite builds?
  15. How do you test individual subprojects?
  16. How do you share tasks between subprojects?
  17. What is the role of project() function?
  18. How do you reference another project?s task?
  19. What is project evaluation order in multi-project builds?
  20. How do you optimize large multi-project builds?

7. Gradle DSL (Groovy & Kotlin)

  1. What is Gradle DSL?
  2. Difference between Groovy DSL and Kotlin DSL?
  3. Which DSL should be preferred for new projects?
  4. How do you convert Groovy DSL to Kotlin DSL?
  5. What are closures in Groovy DSL?
  6. How do you define properties in Gradle DSL?
  7. What is the role of ext in Groovy DSL?
  8. How do you use val and var in Kotlin DSL?
  9. What is the difference between = and set methods in Kotlin DSL?
  10. How does IDE support differ between Groovy and Kotlin DSL?
  11. Can you mix Groovy and Kotlin DSL in the same project?
  12. How do you migrate from Groovy to Kotlin DSL?
  13. What is the syntax difference for applying plugins in both DSLs?
  14. How do you configure dependencies in Kotlin DSL?
  15. What is the .kts file extension used for?
  16. What are advantages of Kotlin DSL?
  17. What are disadvantages of Kotlin DSL?
  18. How do you debug DSL errors?
  19. Which DSL provides better type safety?
  20. Which DSL provides more flexibility?

8. Testing & CI/CD Integration

  1. How do you configure JUnit in Gradle?
  2. How do you configure TestNG in Gradle?
  3. What is the role of test task?
  4. How do you configure test logging?
  5. How do you filter specific tests in Gradle?
  6. How do you set system properties for tests?
  7. How do you configure parallel test execution?
  8. How do you generate code coverage reports?
  9. How do you integrate Jacoco with Gradle?
  10. What is the difference between check and test tasks?
  11. How do you configure test reports in Gradle?
  12. How do you fail a build if tests fail?
  13. How do you run specific test classes in Gradle?
  14. How do you integrate Gradle with Jenkins?
  15. How do you configure Gradle in GitHub Actions?
  16. How do you configure Gradle in GitLab CI/CD?
  17. How do you integrate Gradle with Docker builds?
  18. How do you configure Gradle with Kubernetes deployments?
  19. How do you automate publishing artifacts in CI/CD?
  20. How do you optimize Gradle builds in CI/CD environments?

9. Gradle Performance & Troubleshooting

  1. What is the Gradle build cache?
  2. How do you enable and configure the build cache?
  3. Difference between local and remote build cache?
  4. How do you enable parallel builds in Gradle?
  5. What is configuration on demand in Gradle?
  6. What is Gradle daemon?
  7. How do you enable and disable Gradle daemon?
  8. What are common performance tuning options in Gradle?
  9. How do you analyze build performance?
  10. How do you use --profile in Gradle?
  11. What is dependency resolution caching?
  12. How do you handle slow dependency resolution?
  13. How do you debug a Gradle build failure?
  14. How do you enable debug logs in Gradle?
  15. How do you troubleshoot OutOfMemory errors in Gradle?
  16. How do you handle circular dependencies in Gradle?
  17. What is dependency substitution?
  18. How do you fix version conflict issues?
  19. How do you verify task execution order?
  20. What are common Gradle troubleshooting strategies?

10. Best Practices & Advanced Features

  1. What are best practices for writing Gradle scripts?
  2. How do you modularize large Gradle projects?
  3. How do you reuse common build logic?
  4. What is convention over configuration in Gradle?
  5. How do you enforce dependency versions?
  6. What is a version catalog in Gradle?
  7. How do you implement version catalogs?
  8. What is dependency locking, and why use it?
  9. How do you enforce consistent dependency versions across projects?
  10. What are best practices for multi-project builds?
  11. How do you keep Gradle builds reproducible?
  12. What are common anti-patterns in Gradle builds?
  13. How do you implement security best practices in Gradle?
  14. How do you validate build scripts?
  15. How do you enforce code style checks in Gradle?
  16. How do you automate publishing with Gradle?
  17. How do you implement release automation with Gradle?
  18. How do you configure continuous builds in Gradle?
  19. How do you integrate static analysis tools with Gradle?
  20. What are the latest trends and improvements in Gradle?

Related Topics