{"id":25984,"date":"2021-12-18T09:10:51","date_gmt":"2021-12-18T09:10:51","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=25984"},"modified":"2022-04-13T16:57:12","modified_gmt":"2022-04-13T16:57:12","slug":"gradle-related-faqs","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/gradle-related-faqs\/","title":{"rendered":"Top Gradle interview questions and answers"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is Gradle build tool?<\/h2>\n\n\n\n<p>Gradle is a\u00a0<strong>build automation tool based on Groovy and Kotlin<\/strong>. It&#8217;s open-source and flexible enough to build almost any type of software. It also supports both the automatic download of dependencies and many repositories, including Maven and Ivy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Is Gradle a framework?<\/h2>\n\n\n\n<p>Gradle is&nbsp;<strong>a build automation tool for multi-language software development<\/strong>. &#8230; Gradle builds on the concepts of Apache Ant and Apache Maven, and introduces a Groovy- &amp; Kotlin-based domain-specific language contrasted with the XML-based project configuration used by Maven.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is DSL in Gradle?<\/h2>\n\n\n\n<p>Simply, it stands for &#8216;<strong>Domain-Specific<\/strong> Language&#8217;. IMO, in Gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it&#8217;s a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is closure in Gradle?<\/h2>\n\n\n\n<p>Note in Gradle DSL, closures are frequently (and idiomatically) used&nbsp;<strong>as the last method parameter to configure some object<\/strong>. This is a pattern called configuration closure. &#8230; Gradle uses this for configuration closures, where the delegate object is set to the object to be configured.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is assemble in Gradle?<\/h2>\n\n\n\n<p>Assemble&nbsp;<strong>will build your artifacts<\/strong>, and build will assemble your artifacts with additional checks. Build depends on assemble, so build is sort of a superset of assemble. You can have a look on the tasks that will be executed by using the &#8211;dry-run flag. e.g. gradlew build &#8211;dry-run.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Is Gradle only for Java?<\/h2>\n\n\n\n<p><strong>Gradle runs on the JVM<\/strong>&nbsp;and you must have a Java Development Kit (JDK) installed to use it. &#8230; Several major IDEs allow you to import Gradle builds and interact with them: Android Studio, IntelliJ IDEA, Eclipse, and NetBeans.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is EXT in build gradle?<\/h2>\n\n\n\n<p>ext is&nbsp;<strong>shorthand for project<\/strong>. ext , and is used to define extra properties for the project object. (It&#8217;s also possible to define extra properties for many other objects.) When reading an extra property, the ext. is omitted (e.g. println project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is apply from in Gradle?<\/h2>\n\n\n\n<p>The actual difference between apply from: and apply plugin: is that the former is to be used for&nbsp;<strong>script plugins<\/strong>&nbsp;given a path to the local file system or a URL to a remote location, and the latter is used for binary plugins using the plugin id.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Does Gradle use Groovy?<\/h2>\n\n\n\n<p>Gradle is\u00a0<strong>a Groovy script<\/strong>. Thus it can execute arbitrary code and access any Java library, build-specific Gradle DSL, and the Gradle API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How can you run Gradle build?<\/h2>\n\n\n\n<p>The Gradle command will run Gradle on the Gradle build script located in the same directory as the command prompt is located in. That means, that to run Gradle on a specific gradle build script you must change the directory in the command prompt into the directory where the build script is located.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Gradle build tool? Gradle is a\u00a0build automation tool based on Groovy and Kotlin. It&#8217;s open-source and flexible enough to build almost any type of software. It also supports&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5460],"tags":[],"class_list":["post-25984","post","type-post","status-publish","format-standard","hentry","category-gradle"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/25984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=25984"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/25984\/revisions"}],"predecessor-version":[{"id":26182,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/25984\/revisions\/26182"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=25984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=25984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=25984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}